Chromium Code Reviews| 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 "content/browser/devtools/protocol/devtools_protocol_handler.h" | 11 #include "content/browser/devtools/protocol/devtools_protocol_handler.h" |
| 11 #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" | |
| 12 #include "content/public/browser/devtools_agent_host.h" | 14 #include "content/public/browser/devtools_agent_host.h" |
| 13 #include "content/public/browser/devtools_agent_host_client.h" | 15 #include "content/public/browser/devtools_agent_host_client.h" |
| 14 | 16 |
| 17 // Windows headers will redefine SendMessage. | |
| 18 #ifdef SendMessage | |
|
pfeldman
2015/03/09 19:16:49
We can rename it instead. Where does it articulate
horo
2015/03/10 01:34:07
In windows environment, winuser.h has this line "#
| |
| 19 #undef SendMessage | |
| 20 #endif | |
| 21 | |
| 15 namespace content { | 22 namespace content { |
| 23 | |
| 24 class RenderFrameHost; | |
| 25 | |
| 16 namespace devtools { | 26 namespace devtools { |
| 17 namespace service_worker { | 27 namespace service_worker { |
| 18 | 28 |
| 19 class ServiceWorkerHandler : public DevToolsAgentHostClient, | 29 class ServiceWorkerHandler : public DevToolsAgentHostClient, |
| 20 public ServiceWorkerDevToolsManager::Observer { | 30 public ServiceWorkerDevToolsManager::Observer { |
| 21 public: | 31 public: |
| 22 typedef DevToolsProtocolClient::Response Response; | 32 typedef DevToolsProtocolClient::Response Response; |
| 23 | 33 |
| 24 ServiceWorkerHandler(); | 34 ServiceWorkerHandler(); |
| 25 ~ServiceWorkerHandler() override; | 35 ~ServiceWorkerHandler() override; |
| 26 | 36 |
| 37 void SetRenderFrameHost(RenderFrameHost* render_frame_host); | |
| 27 void SetClient(scoped_ptr<Client> client); | 38 void SetClient(scoped_ptr<Client> client); |
| 28 void Detached(); | 39 void Detached(); |
| 29 | 40 |
| 30 // Protocol 'service worker' domain implementation. | 41 // Protocol 'service worker' domain implementation. |
| 31 Response Enable(); | 42 Response Enable(); |
| 32 Response Disable(); | 43 Response Disable(); |
| 33 Response SendMessage(const std::string& worker_id, | 44 Response SendMessage(const std::string& worker_id, |
| 34 const std::string& message); | 45 const std::string& message); |
| 35 Response Attach(const std::string& worker_id); | 46 Response Attach(const std::string& worker_id); |
| 36 Response Detach(const std::string& worker_id); | 47 Response Detach(const std::string& worker_id); |
| 37 | 48 |
| 38 // WorkerDevToolsManager::Observer implementation. | 49 // WorkerDevToolsManager::Observer implementation. |
| 39 void WorkerCreated(DevToolsAgentHost* host) override; | 50 void WorkerCreated(DevToolsAgentHost* host) override; |
| 40 void WorkerDestroyed(DevToolsAgentHost* host) override; | 51 void WorkerDestroyed(DevToolsAgentHost* host) override; |
| 41 | 52 |
| 42 private: | 53 private: |
| 54 class ContextObserver; | |
| 55 | |
| 43 // DevToolsAgentHostClient overrides. | 56 // DevToolsAgentHostClient overrides. |
| 44 void DispatchProtocolMessage(DevToolsAgentHost* agent_host, | 57 void DispatchProtocolMessage(DevToolsAgentHost* agent_host, |
| 45 const std::string& message) override; | 58 const std::string& message) override; |
| 46 void AgentHostClosed(DevToolsAgentHost* agent_host, | 59 void AgentHostClosed(DevToolsAgentHost* agent_host, |
| 47 bool replaced_with_another_client) override; | 60 bool replaced_with_another_client) override; |
| 48 | 61 |
| 62 void OnWorkerRegistrationUpdated( | |
| 63 const std::vector<ServiceWorkerRegistrationInfo>& registrations); | |
| 64 void OnWorkerVersionUpdated( | |
| 65 const std::vector<ServiceWorkerVersionInfo>& registrations); | |
| 66 void OnWorkerRegistrationDeleted(int64 registration_id); | |
| 67 | |
| 68 RenderFrameHost* render_frame_host_; | |
| 49 scoped_ptr<Client> client_; | 69 scoped_ptr<Client> client_; |
| 50 using AttachedHosts = std::map<std::string, | 70 using AttachedHosts = std::map<std::string, |
| 51 scoped_refptr<DevToolsAgentHost>>; | 71 scoped_refptr<DevToolsAgentHost>>; |
| 52 AttachedHosts attached_hosts_; | 72 AttachedHosts attached_hosts_; |
| 73 scoped_refptr<ContextObserver> context_observer_; | |
| 74 | |
| 75 base::WeakPtrFactory<ServiceWorkerHandler> weak_factory_; | |
| 53 | 76 |
| 54 DISALLOW_COPY_AND_ASSIGN(ServiceWorkerHandler); | 77 DISALLOW_COPY_AND_ASSIGN(ServiceWorkerHandler); |
| 55 }; | 78 }; |
| 56 | 79 |
| 57 } // namespace service_worker | 80 } // namespace service_worker |
| 58 } // namespace devtools | 81 } // namespace devtools |
| 59 } // namespace content | 82 } // namespace content |
| 60 | 83 |
| 61 #endif // CONTENT_BROWSER_DEVTOOLS_PROTOCOL_SERVICE_WORKER_HANDLER_H_ | 84 #endif // CONTENT_BROWSER_DEVTOOLS_PROTOCOL_SERVICE_WORKER_HANDLER_H_ |
| OLD | NEW |