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_EMBEDDED_WORKER_DEVTOOLS_AGENT_HOST_H_ |
6 #define CONTENT_BROWSER_DEVTOOLS_EMBEDDED_WORKER_DEVTOOLS_AGENT_HOST_H_ | 6 #define CONTENT_BROWSER_DEVTOOLS_EMBEDDED_WORKER_DEVTOOLS_AGENT_HOST_H_ |
7 | 7 |
8 #include "content/browser/devtools/embedded_worker_devtools_manager.h" | 8 #include "content/browser/devtools/embedded_worker_devtools_manager.h" |
9 #include "content/browser/devtools/ipc_devtools_agent_host.h" | 9 #include "content/browser/devtools/ipc_devtools_agent_host.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 EmbeddedWorkerDevToolsAgentHost : public IPCDevToolsAgentHost, |
18 public IPC::Listener { | 18 public IPC::Listener { |
19 public: | 19 public: |
20 typedef EmbeddedWorkerDevToolsManager::WorkerId WorkerId; | 20 typedef EmbeddedWorkerDevToolsManager::WorkerId WorkerId; |
21 typedef EmbeddedWorkerDevToolsManager::ServiceWorkerIdentifier | 21 typedef EmbeddedWorkerDevToolsManager::ServiceWorkerIdentifier |
22 ServiceWorkerIdentifier; | 22 ServiceWorkerIdentifier; |
23 | 23 |
24 EmbeddedWorkerDevToolsAgentHost(WorkerId worker_id, | |
25 const SharedWorkerInstance& shared_worker); | |
26 | |
27 EmbeddedWorkerDevToolsAgentHost(WorkerId worker_id, | |
28 const ServiceWorkerIdentifier& service_worker, | |
29 bool debug_service_worker_on_start); | |
30 | |
31 // DevToolsAgentHost override. | 24 // DevToolsAgentHost override. |
32 bool IsWorker() const override; | 25 bool IsWorker() const override; |
33 Type GetType() override; | |
34 std::string GetTitle() override; | |
35 GURL GetURL() override; | |
36 bool Activate() override; | |
37 bool Close() override; | |
38 BrowserContext* GetBrowserContext() override; | 26 BrowserContext* GetBrowserContext() override; |
39 | 27 |
40 // IPCDevToolsAgentHost implementation. | 28 // IPCDevToolsAgentHost implementation. |
41 void SendMessageToAgent(IPC::Message* message) override; | 29 void SendMessageToAgent(IPC::Message* message) override; |
42 void Attach() override; | 30 void Attach() override; |
43 void OnClientAttached() override; | 31 void OnClientAttached() override; |
44 void OnClientDetached() override; | 32 void OnClientDetached() override; |
45 | 33 |
46 // IPC::Listener implementation. | 34 // IPC::Listener implementation. |
47 bool OnMessageReceived(const IPC::Message& msg) override; | 35 bool OnMessageReceived(const IPC::Message& msg) override; |
48 | 36 |
49 void WorkerReadyForInspection(); | 37 void WorkerReadyForInspection(); |
50 void WorkerRestarted(WorkerId worker_id); | 38 void WorkerRestarted(WorkerId worker_id); |
51 void WorkerDestroyed(); | 39 void WorkerDestroyed(); |
52 bool Matches(const SharedWorkerInstance& other); | |
53 bool Matches(const ServiceWorkerIdentifier& other); | |
54 bool IsTerminated(); | 40 bool IsTerminated(); |
55 | 41 |
56 private: | 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: |
57 friend class EmbeddedWorkerDevToolsManagerTest; | 47 friend class EmbeddedWorkerDevToolsManagerTest; |
58 | 48 |
| 49 EmbeddedWorkerDevToolsAgentHost(WorkerId worker_id); |
59 ~EmbeddedWorkerDevToolsAgentHost() override; | 50 ~EmbeddedWorkerDevToolsAgentHost() override; |
60 | 51 |
61 enum WorkerState { | 52 enum WorkerState { |
62 WORKER_UNINSPECTED, | 53 WORKER_UNINSPECTED, |
63 WORKER_INSPECTED, | 54 WORKER_INSPECTED, |
64 WORKER_TERMINATED, | 55 WORKER_TERMINATED, |
65 WORKER_PAUSED_FOR_DEBUG_ON_START, | 56 WORKER_PAUSED_FOR_DEBUG_ON_START, |
66 WORKER_PAUSED_FOR_REATTACH, | 57 WORKER_PAUSED_FOR_REATTACH, |
67 }; | 58 }; |
68 | 59 |
69 void AttachToWorker(); | 60 void AttachToWorker(); |
70 void DetachFromWorker(); | 61 void DetachFromWorker(); |
71 void WorkerCreated(); | 62 void WorkerCreated(); |
72 void OnDispatchOnInspectorFrontend(const std::string& message, | 63 void OnDispatchOnInspectorFrontend(const std::string& message, |
73 uint32 total_size); | 64 uint32 total_size); |
74 void OnSaveAgentRuntimeState(const std::string& state); | 65 void OnSaveAgentRuntimeState(const std::string& state); |
75 | 66 |
76 scoped_ptr<SharedWorkerInstance> shared_worker_; | 67 void set_state(WorkerState state) { state_ = state; } |
77 scoped_ptr<ServiceWorkerIdentifier> service_worker_; | 68 const WorkerId& worker_id() const { return worker_id_; } |
| 69 |
| 70 private: |
78 WorkerState state_; | 71 WorkerState state_; |
79 WorkerId worker_id_; | 72 WorkerId worker_id_; |
80 std::string saved_agent_state_; | 73 std::string saved_agent_state_; |
81 DISALLOW_COPY_AND_ASSIGN(EmbeddedWorkerDevToolsAgentHost); | 74 DISALLOW_COPY_AND_ASSIGN(EmbeddedWorkerDevToolsAgentHost); |
82 }; | 75 }; |
83 | 76 |
84 } // namespace content | 77 } // namespace content |
85 | 78 |
86 #endif // CONTENT_BROWSER_DEVTOOLS_EMBEDDED_WORKER_DEVTOOLS_AGENT_HOST_H_ | 79 #endif // CONTENT_BROWSER_DEVTOOLS_EMBEDDED_WORKER_DEVTOOLS_AGENT_HOST_H_ |
OLD | NEW |