| 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 "base/memory/weak_ptr.h" | 10 #include "base/memory/weak_ptr.h" |
| 11 #include "content/browser/devtools/protocol/devtools_protocol_handler.h" | 11 #include "content/browser/devtools/protocol/devtools_protocol_handler.h" |
| 12 #include "content/browser/devtools/service_worker_devtools_manager.h" | 12 #include "content/browser/devtools/service_worker_devtools_manager.h" |
| 13 #include "content/browser/service_worker/service_worker_info.h" | 13 #include "content/browser/service_worker/service_worker_info.h" |
| 14 #include "content/public/browser/devtools_agent_host.h" | 14 #include "content/public/browser/devtools_agent_host.h" |
| 15 #include "content/public/browser/devtools_agent_host_client.h" | 15 #include "content/public/browser/devtools_agent_host_client.h" |
| 16 | 16 |
| 17 // Windows headers will redefine SendMessage. | 17 // Windows headers will redefine SendMessage. |
| 18 #ifdef SendMessage | 18 #ifdef SendMessage |
| 19 #undef SendMessage | 19 #undef SendMessage |
| 20 #endif | 20 #endif |
| 21 | 21 |
| 22 namespace content { | 22 namespace content { |
| 23 | 23 |
| 24 class RenderFrameHost; | 24 class RenderFrameHost; |
| 25 class ServiceWorkerContextWatcher; |
| 25 class ServiceWorkerContextWrapper; | 26 class ServiceWorkerContextWrapper; |
| 26 class ServiceWorkerDevToolsAgentHost; | 27 class ServiceWorkerDevToolsAgentHost; |
| 27 | 28 |
| 28 namespace devtools { | 29 namespace devtools { |
| 29 namespace service_worker { | 30 namespace service_worker { |
| 30 | 31 |
| 31 class ServiceWorkerHandler : public DevToolsAgentHostClient, | 32 class ServiceWorkerHandler : public DevToolsAgentHostClient, |
| 32 public ServiceWorkerDevToolsManager::Observer { | 33 public ServiceWorkerDevToolsManager::Observer { |
| 33 public: | 34 public: |
| 34 typedef DevToolsProtocolClient::Response Response; | 35 typedef DevToolsProtocolClient::Response Response; |
| (...skipping 12 matching lines...) Expand all Loading... |
| 47 Response SendMessage(const std::string& worker_id, | 48 Response SendMessage(const std::string& worker_id, |
| 48 const std::string& message); | 49 const std::string& message); |
| 49 Response Stop(const std::string& worker_id); | 50 Response Stop(const std::string& worker_id); |
| 50 | 51 |
| 51 // WorkerDevToolsManager::Observer implementation. | 52 // WorkerDevToolsManager::Observer implementation. |
| 52 void WorkerCreated(ServiceWorkerDevToolsAgentHost* host) override; | 53 void WorkerCreated(ServiceWorkerDevToolsAgentHost* host) override; |
| 53 void WorkerReadyForInspection(ServiceWorkerDevToolsAgentHost* host) override; | 54 void WorkerReadyForInspection(ServiceWorkerDevToolsAgentHost* host) override; |
| 54 void WorkerDestroyed(ServiceWorkerDevToolsAgentHost* host) override; | 55 void WorkerDestroyed(ServiceWorkerDevToolsAgentHost* host) override; |
| 55 | 56 |
| 56 private: | 57 private: |
| 57 class ContextObserver; | |
| 58 | |
| 59 // DevToolsAgentHostClient overrides. | 58 // DevToolsAgentHostClient overrides. |
| 60 void DispatchProtocolMessage(DevToolsAgentHost* agent_host, | 59 void DispatchProtocolMessage(DevToolsAgentHost* agent_host, |
| 61 const std::string& message) override; | 60 const std::string& message) override; |
| 62 void AgentHostClosed(DevToolsAgentHost* agent_host, | 61 void AgentHostClosed(DevToolsAgentHost* agent_host, |
| 63 bool replaced_with_another_client) override; | 62 bool replaced_with_another_client) override; |
| 64 | 63 |
| 65 void ReportWorkerCreated(DevToolsAgentHost* host, bool new_worker); | 64 void ReportWorkerCreated(DevToolsAgentHost* host, bool new_worker); |
| 66 | 65 |
| 67 bool MatchesInspectedPage(ServiceWorkerDevToolsAgentHost* host); | 66 bool MatchesInspectedPage(ServiceWorkerDevToolsAgentHost* host); |
| 68 | 67 |
| 69 void OnWorkerRegistrationUpdated( | 68 void OnWorkerRegistrationUpdated( |
| 70 const std::vector<ServiceWorkerRegistrationInfo>& registrations); | 69 const std::vector<ServiceWorkerRegistrationInfo>& registrations); |
| 71 void OnWorkerVersionUpdated( | 70 void OnWorkerVersionUpdated( |
| 72 const std::vector<ServiceWorkerVersionInfo>& registrations); | 71 const std::vector<ServiceWorkerVersionInfo>& registrations); |
| 73 void OnWorkerRegistrationDeleted(int64 registration_id); | |
| 74 | 72 |
| 75 scoped_refptr<ServiceWorkerContextWrapper> context_; | 73 scoped_refptr<ServiceWorkerContextWrapper> context_; |
| 76 scoped_ptr<Client> client_; | 74 scoped_ptr<Client> client_; |
| 77 using AttachedHosts = std::map< | 75 using AttachedHosts = std::map< |
| 78 std::string, scoped_refptr<ServiceWorkerDevToolsAgentHost>>; | 76 std::string, scoped_refptr<ServiceWorkerDevToolsAgentHost>>; |
| 79 AttachedHosts attached_hosts_; | 77 AttachedHosts attached_hosts_; |
| 80 bool enabled_; | 78 bool enabled_; |
| 81 GURL url_; | 79 GURL url_; |
| 82 scoped_refptr<ContextObserver> context_observer_; | 80 scoped_refptr<ServiceWorkerContextWatcher> context_watcher_; |
| 83 | 81 |
| 84 base::WeakPtrFactory<ServiceWorkerHandler> weak_factory_; | 82 base::WeakPtrFactory<ServiceWorkerHandler> weak_factory_; |
| 85 | 83 |
| 86 DISALLOW_COPY_AND_ASSIGN(ServiceWorkerHandler); | 84 DISALLOW_COPY_AND_ASSIGN(ServiceWorkerHandler); |
| 87 }; | 85 }; |
| 88 | 86 |
| 89 } // namespace service_worker | 87 } // namespace service_worker |
| 90 } // namespace devtools | 88 } // namespace devtools |
| 91 } // namespace content | 89 } // namespace content |
| 92 | 90 |
| 93 #endif // CONTENT_BROWSER_DEVTOOLS_PROTOCOL_SERVICE_WORKER_HANDLER_H_ | 91 #endif // CONTENT_BROWSER_DEVTOOLS_PROTOCOL_SERVICE_WORKER_HANDLER_H_ |
| OLD | NEW |