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/worker_devtools_manager.h" | 12 #include "content/browser/devtools/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 | |
| 19 #undef SendMessage | |
| 20 #endif | |
| 21 | |
| 15 namespace content { | 22 namespace content { |
| 23 | |
| 24 class RenderViewHostImpl; | |
| 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 WorkerDevToolsManager::Observer { | 30 public WorkerDevToolsManager::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 SetRenderViewHost(RenderViewHostImpl* render_view_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 Response GetRegistrations(DevToolsCommandId command_id, | 48 Response GetRegistrations(DevToolsCommandId command_id, |
| 38 const std::string& origin); | 49 const std::string& origin); |
| 39 | 50 |
| 40 // WorkerDevToolsManager::Observer implementation. | 51 // WorkerDevToolsManager::Observer implementation. |
| 41 void WorkerCreated(DevToolsAgentHost* host) override; | 52 void WorkerCreated(DevToolsAgentHost* host) override; |
| 42 void WorkerDestroyed(DevToolsAgentHost* host) override; | 53 void WorkerDestroyed(DevToolsAgentHost* host) override; |
| 43 | 54 |
| 44 private: | 55 private: |
| 45 // DevToolsAgentHostClient overrides. | 56 // DevToolsAgentHostClient overrides. |
| 46 void DispatchProtocolMessage(DevToolsAgentHost* agent_host, | 57 void DispatchProtocolMessage(DevToolsAgentHost* agent_host, |
| 47 const std::string& message) override; | 58 const std::string& message) override; |
| 48 void AgentHostClosed(DevToolsAgentHost* agent_host, | 59 void AgentHostClosed(DevToolsAgentHost* agent_host, |
| 49 bool replaced_with_another_client) override; | 60 bool replaced_with_another_client) override; |
| 61 void OnGetRegistrations( | |
| 62 DevToolsCommandId command_id, | |
| 63 const std::vector<ServiceWorkerRegistrationInfo>& registrations); | |
| 50 | 64 |
| 65 RenderViewHostImpl* render_view_host_; | |
|
pfeldman
2015/03/06 10:44:37
We probably want to move off rvh to the main rfh e
horo
2015/03/09 12:33:32
Done.
| |
| 51 scoped_ptr<Client> client_; | 66 scoped_ptr<Client> client_; |
| 52 using AttachedHosts = std::map<std::string, | 67 using AttachedHosts = std::map<std::string, |
| 53 scoped_refptr<DevToolsAgentHost>>; | 68 scoped_refptr<DevToolsAgentHost>>; |
| 54 AttachedHosts attached_hosts_; | 69 AttachedHosts attached_hosts_; |
| 55 | 70 |
| 71 base::WeakPtrFactory<ServiceWorkerHandler> weak_factory_; | |
| 72 | |
| 56 DISALLOW_COPY_AND_ASSIGN(ServiceWorkerHandler); | 73 DISALLOW_COPY_AND_ASSIGN(ServiceWorkerHandler); |
| 57 }; | 74 }; |
| 58 | 75 |
| 59 } // namespace service_worker | 76 } // namespace service_worker |
| 60 } // namespace devtools | 77 } // namespace devtools |
| 61 } // namespace content | 78 } // namespace content |
| 62 | 79 |
| 63 #endif // CONTENT_BROWSER_DEVTOOLS_PROTOCOL_SERVICE_WORKER_HANDLER_H_ | 80 #endif // CONTENT_BROWSER_DEVTOOLS_PROTOCOL_SERVICE_WORKER_HANDLER_H_ |
| OLD | NEW |