| OLD | NEW |
| (Empty) |
| 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. | |
| 4 | |
| 5 #ifndef CONTENT_BROWSER_DEVTOOLS_EMBEDDED_WORKER_DEVTOOLS_AGENT_HOST_H_ | |
| 6 #define CONTENT_BROWSER_DEVTOOLS_EMBEDDED_WORKER_DEVTOOLS_AGENT_HOST_H_ | |
| 7 | |
| 8 #include "content/browser/devtools/embedded_worker_devtools_manager.h" | |
| 9 #include "content/browser/devtools/ipc_devtools_agent_host.h" | |
| 10 #include "ipc/ipc_listener.h" | |
| 11 | |
| 12 namespace content { | |
| 13 | |
| 14 class BrowserContext; | |
| 15 class SharedWorkerInstance; | |
| 16 | |
| 17 class EmbeddedWorkerDevToolsAgentHost : public IPCDevToolsAgentHost, | |
| 18 public IPC::Listener { | |
| 19 public: | |
| 20 typedef EmbeddedWorkerDevToolsManager::WorkerId WorkerId; | |
| 21 typedef EmbeddedWorkerDevToolsManager::ServiceWorkerIdentifier | |
| 22 ServiceWorkerIdentifier; | |
| 23 | |
| 24 // DevToolsAgentHost override. | |
| 25 bool IsWorker() const override; | |
| 26 BrowserContext* GetBrowserContext() override; | |
| 27 | |
| 28 // IPCDevToolsAgentHost implementation. | |
| 29 void SendMessageToAgent(IPC::Message* message) override; | |
| 30 void Attach() override; | |
| 31 void OnClientAttached() override; | |
| 32 void OnClientDetached() override; | |
| 33 | |
| 34 // IPC::Listener implementation. | |
| 35 bool OnMessageReceived(const IPC::Message& msg) override; | |
| 36 | |
| 37 void WorkerReadyForInspection(); | |
| 38 void WorkerRestarted(WorkerId worker_id); | |
| 39 void WorkerDestroyed(); | |
| 40 bool IsTerminated(); | |
| 41 | |
| 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: | |
| 47 friend class EmbeddedWorkerDevToolsManagerTest; | |
| 48 | |
| 49 EmbeddedWorkerDevToolsAgentHost(WorkerId worker_id); | |
| 50 ~EmbeddedWorkerDevToolsAgentHost() override; | |
| 51 | |
| 52 enum WorkerState { | |
| 53 WORKER_UNINSPECTED, | |
| 54 WORKER_INSPECTED, | |
| 55 WORKER_TERMINATED, | |
| 56 WORKER_PAUSED_FOR_DEBUG_ON_START, | |
| 57 WORKER_PAUSED_FOR_REATTACH, | |
| 58 }; | |
| 59 | |
| 60 void AttachToWorker(); | |
| 61 void DetachFromWorker(); | |
| 62 void WorkerCreated(); | |
| 63 void OnDispatchOnInspectorFrontend(const std::string& message, | |
| 64 uint32 total_size); | |
| 65 void OnSaveAgentRuntimeState(const std::string& state); | |
| 66 | |
| 67 void set_state(WorkerState state) { state_ = state; } | |
| 68 const WorkerId& worker_id() const { return worker_id_; } | |
| 69 | |
| 70 private: | |
| 71 WorkerState state_; | |
| 72 WorkerId worker_id_; | |
| 73 std::string saved_agent_state_; | |
| 74 DISALLOW_COPY_AND_ASSIGN(EmbeddedWorkerDevToolsAgentHost); | |
| 75 }; | |
| 76 | |
| 77 } // namespace content | |
| 78 | |
| 79 #endif // CONTENT_BROWSER_DEVTOOLS_EMBEDDED_WORKER_DEVTOOLS_AGENT_HOST_H_ | |
| OLD | NEW |