// Copyright 2019 The Chromium Authors // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. #ifndef COMPONENTS_PERFORMANCE_MANAGER_PUBLIC_GRAPH_WORKER_NODE_H_ #define COMPONENTS_PERFORMANCE_MANAGER_PUBLIC_GRAPH_WORKER_NODE_H_ #include <string> #include "base/containers/flat_set.h" #include "base/observer_list_types.h" #include "base/types/token_type.h" #include "components/performance_manager/public/execution_context_priority/execution_context_priority.h" #include "components/performance_manager/public/graph/node.h" #include "components/performance_manager/public/graph/node_set_view.h" #include "components/performance_manager/public/resource_attribution/worker_context.h" #include "third_party/blink/public/common/tokens/tokens.h" class GURL; namespace url { class Origin; } namespace performance_manager { class WorkerNodeObserver; class FrameNode; class ProcessNode; PriorityAndReason; // Represents a running instance of a WorkerGlobalScope. // See https://developer.mozilla.org/en-US/docs/Web/API/WorkerGlobalScope. // // A worker is the equivalent of a thread on the web platform. To do // asynchronous work, a frame can create a dedicated worker or a shared worker // with Javascript. Those workers can now be used by sending an asynchronous // message using the postMessage() method, and replies can be received by // registering a message handler on the worker object. // // One notable special case is that dedicated workers can be nested. That means // that a dedicated worker can create another dedicated worker which is then // only accessible from the parent worker. // // Service workers are different. Instead of being created by the javascript // when needed, a service worker is registered once and affects all frames and // dedicated/shared workers whose URL matches the scope of the service worker. // A service worker is mainly used to intercept network requests and optionally // serve the responses from a cache, making the web site work offline. // // A client, from the point of view of the worker, is the frame or worker that // caused the worker to start running, either because it explicitly created it, // or a service worker is registered to handle their network requests. class WorkerNode : public TypedNode<WorkerNode> { … }; // Pure virtual observer interface. Derive from this if you want to be forced to // implement the entire interface. class WorkerNodeObserver : public base::CheckedObserver { … }; // Default implementation of observer that provides dummy versions of each // function. Derive from this if you only need to implement a few of the // functions. class WorkerNode::ObserverDefaultImpl : public WorkerNodeObserver { … }; } // namespace performance_manager #endif // COMPONENTS_PERFORMANCE_MANAGER_PUBLIC_GRAPH_WORKER_NODE_H_