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