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, | 24 EmbeddedWorkerDevToolsAgentHost(WorkerId worker_id, |
horo
2014/12/18 05:55:56
remove this
kinuko
2014/12/18 06:24:54
Done.
| |
25 const SharedWorkerInstance& shared_worker); | 25 const SharedWorkerInstance& shared_worker); |
26 | 26 |
27 EmbeddedWorkerDevToolsAgentHost(WorkerId worker_id, | |
28 const ServiceWorkerIdentifier& service_worker, | |
29 bool debug_service_worker_on_start); | |
30 | |
31 // DevToolsAgentHost override. | 27 // DevToolsAgentHost override. |
32 bool IsWorker() const override; | 28 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; | 29 BrowserContext* GetBrowserContext() override; |
39 | 30 |
40 // IPCDevToolsAgentHost implementation. | 31 // IPCDevToolsAgentHost implementation. |
41 void SendMessageToAgent(IPC::Message* message) override; | 32 void SendMessageToAgent(IPC::Message* message) override; |
42 void Attach() override; | 33 void Attach() override; |
43 void OnClientAttached() override; | 34 void OnClientAttached() override; |
44 void OnClientDetached() override; | 35 void OnClientDetached() override; |
45 | 36 |
46 // IPC::Listener implementation. | 37 // IPC::Listener implementation. |
47 bool OnMessageReceived(const IPC::Message& msg) override; | 38 bool OnMessageReceived(const IPC::Message& msg) override; |
48 | 39 |
49 void WorkerReadyForInspection(); | 40 void WorkerReadyForInspection(); |
50 void WorkerRestarted(WorkerId worker_id); | 41 void WorkerRestarted(WorkerId worker_id); |
51 void WorkerDestroyed(); | 42 void WorkerDestroyed(); |
52 bool Matches(const SharedWorkerInstance& other); | |
53 bool Matches(const ServiceWorkerIdentifier& other); | |
54 bool IsTerminated(); | 43 bool IsTerminated(); |
55 | 44 |
56 private: | 45 // TODO(kinuko): Remove these virtual methods after we split devtools manager. |
46 virtual bool Matches(const SharedWorkerInstance& other); | |
47 virtual bool Matches(const ServiceWorkerIdentifier& other); | |
48 | |
49 protected: | |
57 friend class EmbeddedWorkerDevToolsManagerTest; | 50 friend class EmbeddedWorkerDevToolsManagerTest; |
58 | 51 |
52 EmbeddedWorkerDevToolsAgentHost(WorkerId worker_id); | |
59 ~EmbeddedWorkerDevToolsAgentHost() override; | 53 ~EmbeddedWorkerDevToolsAgentHost() override; |
60 | 54 |
61 enum WorkerState { | 55 enum WorkerState { |
62 WORKER_UNINSPECTED, | 56 WORKER_UNINSPECTED, |
63 WORKER_INSPECTED, | 57 WORKER_INSPECTED, |
64 WORKER_TERMINATED, | 58 WORKER_TERMINATED, |
65 WORKER_PAUSED_FOR_DEBUG_ON_START, | 59 WORKER_PAUSED_FOR_DEBUG_ON_START, |
66 WORKER_PAUSED_FOR_REATTACH, | 60 WORKER_PAUSED_FOR_REATTACH, |
67 }; | 61 }; |
68 | 62 |
69 void AttachToWorker(); | 63 void AttachToWorker(); |
70 void DetachFromWorker(); | 64 void DetachFromWorker(); |
71 void WorkerCreated(); | 65 void WorkerCreated(); |
72 void OnDispatchOnInspectorFrontend(const std::string& message, | 66 void OnDispatchOnInspectorFrontend(const std::string& message, |
73 uint32 total_size); | 67 uint32 total_size); |
74 void OnSaveAgentRuntimeState(const std::string& state); | 68 void OnSaveAgentRuntimeState(const std::string& state); |
75 | 69 |
76 scoped_ptr<SharedWorkerInstance> shared_worker_; | 70 void set_state(WorkerState state) { state_ = state; } |
77 scoped_ptr<ServiceWorkerIdentifier> service_worker_; | 71 const WorkerId& worker_id() const { return worker_id_; } |
72 | |
73 private: | |
78 WorkerState state_; | 74 WorkerState state_; |
79 WorkerId worker_id_; | 75 WorkerId worker_id_; |
80 std::string saved_agent_state_; | 76 std::string saved_agent_state_; |
81 DISALLOW_COPY_AND_ASSIGN(EmbeddedWorkerDevToolsAgentHost); | 77 DISALLOW_COPY_AND_ASSIGN(EmbeddedWorkerDevToolsAgentHost); |
82 }; | 78 }; |
83 | 79 |
84 } // namespace content | 80 } // namespace content |
85 | 81 |
86 #endif // CONTENT_BROWSER_DEVTOOLS_EMBEDDED_WORKER_DEVTOOLS_AGENT_HOST_H_ | 82 #endif // CONTENT_BROWSER_DEVTOOLS_EMBEDDED_WORKER_DEVTOOLS_AGENT_HOST_H_ |
OLD | NEW |