ozone: evdev: Sync caps lock LED state to evdev
[chromium-blink-merge.git] / content / browser / devtools / service_worker_devtools_manager.h
blob3024e593896fe55bd5601fcc765eef2f27a58b83
1 // Copyright 2014 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
5 #ifndef CONTENT_BROWSER_DEVTOOLS_SERVICE_WORKER_DEVTOOLS_MANAGER_H_
6 #define CONTENT_BROWSER_DEVTOOLS_SERVICE_WORKER_DEVTOOLS_MANAGER_H_
8 #include <map>
10 #include "base/basictypes.h"
11 #include "base/memory/singleton.h"
12 #include "base/memory/weak_ptr.h"
13 #include "content/browser/devtools/worker_devtools_manager.h"
14 #include "content/browser/shared_worker/shared_worker_instance.h"
16 namespace content {
18 class ServiceWorkerDevToolsAgentHost;
19 class ServiceWorkerContextCore;
21 // Manages WorkerDevToolsAgentHost's for Service Workers.
22 // This class lives on UI thread.
23 class CONTENT_EXPORT ServiceWorkerDevToolsManager
24 : public WorkerDevToolsManager {
25 public:
26 class ServiceWorkerIdentifier {
27 public:
28 ServiceWorkerIdentifier(
29 const ServiceWorkerContextCore* context,
30 base::WeakPtr<ServiceWorkerContextCore> context_weak,
31 int64 version_id,
32 const GURL& url);
33 ServiceWorkerIdentifier(const ServiceWorkerIdentifier& other);
34 ~ServiceWorkerIdentifier();
36 bool Matches(const ServiceWorkerIdentifier& other) const;
38 const ServiceWorkerContextCore* context() const { return context_; }
39 base::WeakPtr<ServiceWorkerContextCore> context_weak() const {
40 return context_weak_;
42 int64 version_id() const { return version_id_; }
43 GURL url() const { return url_; }
45 private:
46 const ServiceWorkerContextCore* const context_;
47 const base::WeakPtr<ServiceWorkerContextCore> context_weak_;
48 const int64 version_id_;
49 const GURL url_;
52 // Returns the ServiceWorkerDevToolsManager singleton.
53 static ServiceWorkerDevToolsManager* GetInstance();
55 // Returns true when the worker must be paused on start because a DevTool
56 // window for the same former ServiceWorkerIdentifier is still opened or
57 // debug-on-start is enabled in chrome://serviceworker-internals.
58 bool WorkerCreated(int worker_process_id,
59 int worker_route_id,
60 const ServiceWorkerIdentifier& service_worker_id);
61 void WorkerStopIgnored(int worker_process_id, int worker_route_id);
63 void set_debug_service_worker_on_start(bool debug_on_start) {
64 debug_service_worker_on_start_ = debug_on_start;
66 bool debug_service_worker_on_start() const {
67 return debug_service_worker_on_start_;
70 private:
71 friend struct DefaultSingletonTraits<ServiceWorkerDevToolsManager>;
72 friend class ServiceWorkerDevToolsAgentHost;
74 ServiceWorkerDevToolsManager();
75 ~ServiceWorkerDevToolsManager() override;
77 AgentHostMap::iterator FindExistingWorkerAgentHost(
78 const ServiceWorkerIdentifier& service_worker_id);
80 bool debug_service_worker_on_start_;
82 DISALLOW_COPY_AND_ASSIGN(ServiceWorkerDevToolsManager);
85 } // namespace content
87 #endif // CONTENT_BROWSER_DEVTOOLS_SERVICE_WORKER_DEVTOOLS_MANAGER_H_