| 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_WORKER_DEVTOOLS_AGENT_HOST_H_ | 5 #ifndef CONTENT_BROWSER_DEVTOOLS_WORKER_DEVTOOLS_AGENT_HOST_H_ |
| 6 #define CONTENT_BROWSER_DEVTOOLS_WORKER_DEVTOOLS_AGENT_HOST_H_ | 6 #define CONTENT_BROWSER_DEVTOOLS_WORKER_DEVTOOLS_AGENT_HOST_H_ |
| 7 | 7 |
| 8 #include "content/browser/devtools/ipc_devtools_agent_host.h" | 8 #include "content/browser/devtools/devtools_agent_host_impl.h" |
| 9 #include "ipc/ipc_listener.h" | 9 #include "ipc/ipc_listener.h" |
| 10 | 10 |
| 11 namespace content { | 11 namespace content { |
| 12 | 12 |
| 13 class BrowserContext; | 13 class BrowserContext; |
| 14 class SharedWorkerInstance; | 14 class SharedWorkerInstance; |
| 15 | 15 |
| 16 class WorkerDevToolsAgentHost : public IPCDevToolsAgentHost, | 16 class WorkerDevToolsAgentHost : public DevToolsAgentHostImpl, |
| 17 public IPC::Listener { | 17 public IPC::Listener { |
| 18 public: | 18 public: |
| 19 typedef std::pair<int, int> WorkerId; | 19 typedef std::pair<int, int> WorkerId; |
| 20 | 20 |
| 21 // DevToolsAgentHost override. | 21 // DevToolsAgentHost override. |
| 22 BrowserContext* GetBrowserContext() override; | 22 BrowserContext* GetBrowserContext() override; |
| 23 | 23 |
| 24 // IPCDevToolsAgentHost implementation. | 24 // DevToolsAgentHostImpl overrides. |
| 25 void SendMessageToAgent(IPC::Message* message) override; | |
| 26 void Attach() override; | 25 void Attach() override; |
| 27 void OnClientAttached(bool reattached) override; | 26 void Detach() override; |
| 28 void OnClientDetached() override; | 27 bool DispatchProtocolMessage(const std::string& message) override; |
| 29 | 28 |
| 30 // IPC::Listener implementation. | 29 // IPC::Listener implementation. |
| 31 bool OnMessageReceived(const IPC::Message& msg) override; | 30 bool OnMessageReceived(const IPC::Message& msg) override; |
| 32 | 31 |
| 33 void PauseForDebugOnStart(); | 32 void PauseForDebugOnStart(); |
| 34 bool IsPausedForDebugOnStart(); | 33 bool IsPausedForDebugOnStart(); |
| 35 | 34 |
| 36 void WorkerReadyForInspection(); | 35 void WorkerReadyForInspection(); |
| 37 void WorkerRestarted(WorkerId worker_id); | 36 void WorkerRestarted(WorkerId worker_id); |
| 38 void WorkerDestroyed(); | 37 void WorkerDestroyed(); |
| 39 bool IsTerminated(); | 38 bool IsTerminated(); |
| 40 | 39 |
| 41 protected: | 40 protected: |
| 42 WorkerDevToolsAgentHost(WorkerId worker_id); | 41 WorkerDevToolsAgentHost(WorkerId worker_id); |
| 43 ~WorkerDevToolsAgentHost() override; | 42 ~WorkerDevToolsAgentHost() override; |
| 44 | 43 |
| 45 enum WorkerState { | 44 enum WorkerState { |
| 46 WORKER_UNINSPECTED, | 45 WORKER_UNINSPECTED, |
| 47 WORKER_INSPECTED, | 46 WORKER_INSPECTED, |
| 48 WORKER_TERMINATED, | 47 WORKER_TERMINATED, |
| 49 WORKER_PAUSED_FOR_DEBUG_ON_START, | 48 WORKER_PAUSED_FOR_DEBUG_ON_START, |
| 50 WORKER_PAUSED_FOR_REATTACH, | 49 WORKER_PAUSED_FOR_REATTACH, |
| 51 }; | 50 }; |
| 52 | 51 |
| 52 virtual void OnAttachedStateChanged(bool attached); |
| 53 const WorkerId& worker_id() const { return worker_id_; } |
| 54 |
| 55 private: |
| 56 friend class SharedWorkerDevToolsManagerTest; |
| 57 |
| 53 void AttachToWorker(); | 58 void AttachToWorker(); |
| 54 void DetachFromWorker(); | 59 void DetachFromWorker(); |
| 55 void WorkerCreated(); | 60 void WorkerCreated(); |
| 56 void OnDispatchOnInspectorFrontend(const DevToolsMessageChunk& message); | 61 void OnDispatchOnInspectorFrontend(const DevToolsMessageChunk& message); |
| 57 | 62 |
| 58 const WorkerId& worker_id() const { return worker_id_; } | |
| 59 | |
| 60 private: | |
| 61 friend class SharedWorkerDevToolsManagerTest; | |
| 62 | |
| 63 WorkerState state_; | 63 WorkerState state_; |
| 64 WorkerId worker_id_; | 64 WorkerId worker_id_; |
| 65 DISALLOW_COPY_AND_ASSIGN(WorkerDevToolsAgentHost); | 65 DISALLOW_COPY_AND_ASSIGN(WorkerDevToolsAgentHost); |
| 66 }; | 66 }; |
| 67 | 67 |
| 68 } // namespace content | 68 } // namespace content |
| 69 | 69 |
| 70 #endif // CONTENT_BROWSER_DEVTOOLS_WORKER_DEVTOOLS_AGENT_HOST_H_ | 70 #endif // CONTENT_BROWSER_DEVTOOLS_WORKER_DEVTOOLS_AGENT_HOST_H_ |
| OLD | NEW |