Supervised user whitelists: Cleanup
[chromium-blink-merge.git] / content / browser / devtools / shared_worker_devtools_manager.h
blob6a2a828f9bfda49fa3cc65b39519526bd4ae3a5a
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_SHARED_WORKER_DEVTOOLS_MANAGER_H_
6 #define CONTENT_BROWSER_DEVTOOLS_SHARED_WORKER_DEVTOOLS_MANAGER_H_
8 #include <map>
10 #include "base/basictypes.h"
11 #include "base/gtest_prod_util.h"
12 #include "base/memory/singleton.h"
13 #include "content/public/browser/devtools_agent_host.h"
15 namespace content {
17 class DevToolsAgentHostImpl;
18 class SharedWorkerDevToolsAgentHost;
19 class SharedWorkerInstance;
21 // Manages WorkerDevToolsAgentHost's for Shared Workers.
22 // This class lives on UI thread.
23 class CONTENT_EXPORT SharedWorkerDevToolsManager {
24 public:
25 using WorkerId = std::pair<int, int>;
27 // Returns the SharedWorkerDevToolsManager singleton.
28 static SharedWorkerDevToolsManager* GetInstance();
30 DevToolsAgentHostImpl* GetDevToolsAgentHostForWorker(int worker_process_id,
31 int worker_route_id);
32 void AddAllAgentHosts(
33 std::vector<scoped_refptr<SharedWorkerDevToolsAgentHost>>* result);
35 // Returns true when the worker must be paused on start because a DevTool
36 // window for the same former SharedWorkerInstance is still opened.
37 bool WorkerCreated(int worker_process_id,
38 int worker_route_id,
39 const SharedWorkerInstance& instance);
40 void WorkerReadyForInspection(int worker_process_id, int worker_route_id);
41 void WorkerDestroyed(int worker_process_id, int worker_route_id);
42 void RemoveInspectedWorkerData(WorkerId id);
44 private:
45 friend struct DefaultSingletonTraits<SharedWorkerDevToolsManager>;
46 friend class SharedWorkerDevToolsAgentHost;
47 friend class SharedWorkerDevToolsManagerTest;
48 FRIEND_TEST_ALL_PREFIXES(SharedWorkerDevToolsManagerTest, BasicTest);
49 FRIEND_TEST_ALL_PREFIXES(SharedWorkerDevToolsManagerTest, AttachTest);
51 using AgentHostMap = std::map<WorkerId, SharedWorkerDevToolsAgentHost*>;
53 SharedWorkerDevToolsManager();
54 ~SharedWorkerDevToolsManager();
56 AgentHostMap::iterator FindExistingWorkerAgentHost(
57 const SharedWorkerInstance& instance);
59 // Resets to its initial state as if newly created.
60 void ResetForTesting();
62 AgentHostMap workers_;
63 DISALLOW_COPY_AND_ASSIGN(SharedWorkerDevToolsManager);
66 } // namespace content
68 #endif // CONTENT_BROWSER_DEVTOOLS_SHARED_WORKER_DEVTOOLS_MANAGER_H_