OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 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 | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #ifndef CONTENT_BROWSER_DEVTOOLS_EMBEDDED_WORKER_DEVTOOLS_AGENT_HOST_H_ | 5 #ifndef CONTENT_BROWSER_DEVTOOLS_WORKER_DEVTOOLS_AGENT_HOST_H_ |
6 #define CONTENT_BROWSER_DEVTOOLS_EMBEDDED_WORKER_DEVTOOLS_AGENT_HOST_H_ | 6 #define CONTENT_BROWSER_DEVTOOLS_WORKER_DEVTOOLS_AGENT_HOST_H_ |
7 | 7 |
8 #include "content/browser/devtools/embedded_worker_devtools_manager.h" | |
9 #include "content/browser/devtools/ipc_devtools_agent_host.h" | 8 #include "content/browser/devtools/ipc_devtools_agent_host.h" |
| 9 #include "content/browser/devtools/worker_devtools_manager.h" |
10 #include "ipc/ipc_listener.h" | 10 #include "ipc/ipc_listener.h" |
11 | 11 |
12 namespace content { | 12 namespace content { |
13 | 13 |
14 class BrowserContext; | 14 class BrowserContext; |
15 class SharedWorkerInstance; | 15 class SharedWorkerInstance; |
16 | 16 |
17 class EmbeddedWorkerDevToolsAgentHost : public IPCDevToolsAgentHost, | 17 class WorkerDevToolsAgentHost : public IPCDevToolsAgentHost, |
18 public IPC::Listener { | 18 public IPC::Listener { |
19 public: | 19 public: |
20 typedef EmbeddedWorkerDevToolsManager::WorkerId WorkerId; | 20 typedef WorkerDevToolsManager::WorkerId WorkerId; |
21 typedef EmbeddedWorkerDevToolsManager::ServiceWorkerIdentifier | |
22 ServiceWorkerIdentifier; | |
23 | 21 |
24 // DevToolsAgentHost override. | 22 // DevToolsAgentHost override. |
25 bool IsWorker() const override; | 23 bool IsWorker() const override; |
26 BrowserContext* GetBrowserContext() override; | 24 BrowserContext* GetBrowserContext() override; |
27 | 25 |
28 // IPCDevToolsAgentHost implementation. | 26 // IPCDevToolsAgentHost implementation. |
29 void SendMessageToAgent(IPC::Message* message) override; | 27 void SendMessageToAgent(IPC::Message* message) override; |
30 void Attach() override; | 28 void Attach() override; |
31 void OnClientAttached() override; | 29 void OnClientAttached() override; |
32 void OnClientDetached() override; | 30 void OnClientDetached() override; |
33 | 31 |
34 // IPC::Listener implementation. | 32 // IPC::Listener implementation. |
35 bool OnMessageReceived(const IPC::Message& msg) override; | 33 bool OnMessageReceived(const IPC::Message& msg) override; |
36 | 34 |
37 void WorkerReadyForInspection(); | 35 void WorkerReadyForInspection(); |
38 void WorkerRestarted(WorkerId worker_id); | 36 void WorkerRestarted(WorkerId worker_id); |
39 void WorkerDestroyed(); | 37 void WorkerDestroyed(); |
40 bool IsTerminated(); | 38 bool IsTerminated(); |
41 | 39 |
42 // TODO(kinuko): Remove these virtual methods after we split devtools manager. | |
43 virtual bool Matches(const SharedWorkerInstance& other); | |
44 virtual bool Matches(const ServiceWorkerIdentifier& other); | |
45 | |
46 protected: | 40 protected: |
47 friend class EmbeddedWorkerDevToolsManagerTest; | 41 WorkerDevToolsAgentHost(WorkerId worker_id); |
48 | 42 ~WorkerDevToolsAgentHost() override; |
49 EmbeddedWorkerDevToolsAgentHost(WorkerId worker_id); | |
50 ~EmbeddedWorkerDevToolsAgentHost() override; | |
51 | 43 |
52 enum WorkerState { | 44 enum WorkerState { |
53 WORKER_UNINSPECTED, | 45 WORKER_UNINSPECTED, |
54 WORKER_INSPECTED, | 46 WORKER_INSPECTED, |
55 WORKER_TERMINATED, | 47 WORKER_TERMINATED, |
56 WORKER_PAUSED_FOR_DEBUG_ON_START, | 48 WORKER_PAUSED_FOR_DEBUG_ON_START, |
57 WORKER_PAUSED_FOR_REATTACH, | 49 WORKER_PAUSED_FOR_REATTACH, |
58 }; | 50 }; |
59 | 51 |
60 void AttachToWorker(); | 52 void AttachToWorker(); |
61 void DetachFromWorker(); | 53 void DetachFromWorker(); |
62 void WorkerCreated(); | 54 void WorkerCreated(); |
63 void OnDispatchOnInspectorFrontend(const std::string& message, | 55 void OnDispatchOnInspectorFrontend(const std::string& message, |
64 uint32 total_size); | 56 uint32 total_size); |
65 void OnSaveAgentRuntimeState(const std::string& state); | 57 void OnSaveAgentRuntimeState(const std::string& state); |
66 | 58 |
67 void set_state(WorkerState state) { state_ = state; } | 59 void set_state(WorkerState state) { state_ = state; } |
68 const WorkerId& worker_id() const { return worker_id_; } | 60 const WorkerId& worker_id() const { return worker_id_; } |
69 | 61 |
70 private: | 62 private: |
| 63 friend class SharedWorkerDevToolsManagerTest; |
| 64 |
71 WorkerState state_; | 65 WorkerState state_; |
72 WorkerId worker_id_; | 66 WorkerId worker_id_; |
73 std::string saved_agent_state_; | 67 std::string saved_agent_state_; |
74 DISALLOW_COPY_AND_ASSIGN(EmbeddedWorkerDevToolsAgentHost); | 68 DISALLOW_COPY_AND_ASSIGN(WorkerDevToolsAgentHost); |
75 }; | 69 }; |
76 | 70 |
77 } // namespace content | 71 } // namespace content |
78 | 72 |
79 #endif // CONTENT_BROWSER_DEVTOOLS_EMBEDDED_WORKER_DEVTOOLS_AGENT_HOST_H_ | 73 #endif // CONTENT_BROWSER_DEVTOOLS_WORKER_DEVTOOLS_AGENT_HOST_H_ |
OLD | NEW |