OLD | NEW |
(Empty) | |
| 1 // Copyright 2015 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_PROTOCOL_SERVICE_WORKER_HANDLER_H_ |
| 6 #define CONTENT_BROWSER_DEVTOOLS_PROTOCOL_SERVICE_WORKER_HANDLER_H_ |
| 7 |
| 8 #include <set> |
| 9 |
| 10 #include "content/browser/devtools/protocol/devtools_protocol_handler.h" |
| 11 #include "content/browser/devtools/worker_devtools_manager.h" |
| 12 #include "content/public/browser/devtools_agent_host.h" |
| 13 #include "content/public/browser/devtools_agent_host_client.h" |
| 14 |
| 15 namespace content { |
| 16 namespace devtools { |
| 17 namespace service_worker { |
| 18 |
| 19 class ServiceWorkerHandler : public DevToolsAgentHostClient, |
| 20 public WorkerDevToolsManager::Observer { |
| 21 public: |
| 22 typedef DevToolsProtocolClient::Response Response; |
| 23 |
| 24 ServiceWorkerHandler(); |
| 25 ~ServiceWorkerHandler() override; |
| 26 |
| 27 void SetClient(scoped_ptr<DevToolsProtocolClient> client); |
| 28 void Detached(); |
| 29 |
| 30 // Protocol 'service worker' domain implementation. |
| 31 Response Enable(); |
| 32 Response Disable(); |
| 33 Response SendMessage(const std::string& worker_id, |
| 34 const std::string& message); |
| 35 Response Attach(const std::string& worker_id); |
| 36 Response Detach(const std::string& worker_id); |
| 37 |
| 38 // WorkerDevToolsManager::Observer implementation. |
| 39 void WorkerCreated(DevToolsAgentHost* host) override; |
| 40 void WorkerDestroyed(DevToolsAgentHost* host) override; |
| 41 |
| 42 private: |
| 43 // DevToolsAgentHostClient overrides. |
| 44 void DispatchProtocolMessage(DevToolsAgentHost* agent_host, |
| 45 const std::string& message) override; |
| 46 void AgentHostClosed(DevToolsAgentHost* agent_host, |
| 47 bool replaced_with_another_client) override; |
| 48 |
| 49 scoped_ptr<DevToolsProtocolClient> client_; |
| 50 using AttachedHosts = std::map<std::string, |
| 51 scoped_refptr<DevToolsAgentHost>>; |
| 52 AttachedHosts attached_hosts_; |
| 53 |
| 54 DISALLOW_COPY_AND_ASSIGN(ServiceWorkerHandler); |
| 55 }; |
| 56 |
| 57 } // namespace service_worker |
| 58 } // namespace devtools |
| 59 } // namespace content |
| 60 |
| 61 #endif // CONTENT_BROWSER_DEVTOOLS_PROTOCOL_SERVICE_WORKER_HANDLER_H_ |
OLD | NEW |