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 <stdint.h> | 8 #include <stdint.h> |
9 | 9 |
10 #include <set> | 10 #include <set> |
11 | 11 |
12 #include "base/macros.h" | 12 #include "base/macros.h" |
13 #include "base/memory/weak_ptr.h" | 13 #include "base/memory/weak_ptr.h" |
14 #include "content/browser/devtools/protocol/service_worker.h" | 14 #include "content/browser/devtools/protocol/devtools_protocol_dispatcher.h" |
15 #include "content/browser/devtools/service_worker_devtools_agent_host.h" | 15 #include "content/browser/devtools/service_worker_devtools_agent_host.h" |
16 #include "content/browser/devtools/service_worker_devtools_manager.h" | 16 #include "content/browser/devtools/service_worker_devtools_manager.h" |
17 #include "content/browser/service_worker/service_worker_context_observer.h" | 17 #include "content/browser/service_worker/service_worker_context_observer.h" |
18 #include "content/browser/service_worker/service_worker_info.h" | 18 #include "content/browser/service_worker/service_worker_info.h" |
| 19 #include "content/public/browser/devtools_agent_host.h" |
| 20 #include "content/public/browser/devtools_agent_host_client.h" |
| 21 |
| 22 // Windows headers will redefine SendMessage. |
| 23 #ifdef SendMessage |
| 24 #undef SendMessage |
| 25 #endif |
19 | 26 |
20 namespace content { | 27 namespace content { |
21 | 28 |
22 class RenderFrameHostImpl; | 29 class RenderFrameHostImpl; |
23 class ServiceWorkerContextWatcher; | 30 class ServiceWorkerContextWatcher; |
24 class ServiceWorkerContextWrapper; | 31 class ServiceWorkerContextWrapper; |
25 | 32 |
26 namespace protocol { | 33 namespace devtools { |
| 34 namespace service_worker { |
27 | 35 |
28 class ServiceWorkerHandler : public ServiceWorker::Backend { | 36 class ServiceWorkerHandler { |
29 public: | 37 public: |
| 38 typedef DevToolsProtocolClient::Response Response; |
| 39 |
30 ServiceWorkerHandler(); | 40 ServiceWorkerHandler(); |
31 ~ServiceWorkerHandler() override; | 41 ~ServiceWorkerHandler(); |
32 | 42 |
33 void Wire(UberDispatcher*); | |
34 void SetRenderFrameHost(RenderFrameHostImpl* render_frame_host); | 43 void SetRenderFrameHost(RenderFrameHostImpl* render_frame_host); |
| 44 void SetClient(std::unique_ptr<Client> client); |
| 45 void Detached(); |
35 | 46 |
36 Response Enable() override; | 47 // Protocol 'service worker' domain implementation. |
37 Response Disable() override; | 48 Response Enable(); |
38 Response Unregister(const std::string& scope_url) override; | 49 Response Disable(); |
39 Response StartWorker(const std::string& scope_url) override; | 50 Response Unregister(const std::string& scope_url); |
40 Response SkipWaiting(const std::string& scope_url) override; | 51 Response StartWorker(const std::string& scope_url); |
41 Response StopWorker(const std::string& version_id) override; | 52 Response SkipWaiting(const std::string& scope_url); |
42 Response UpdateRegistration(const std::string& scope_url) override; | 53 Response StopWorker(const std::string& version_id); |
43 Response InspectWorker(const std::string& version_id) override; | 54 Response UpdateRegistration(const std::string& scope_url); |
44 Response SetForceUpdateOnPageLoad(bool force_update_on_page_load) override; | 55 Response InspectWorker(const std::string& version_id); |
| 56 Response SetForceUpdateOnPageLoad(bool force_update_on_page_load); |
45 Response DeliverPushMessage(const std::string& origin, | 57 Response DeliverPushMessage(const std::string& origin, |
46 const std::string& registration_id, | 58 const std::string& registration_id, |
47 const std::string& data) override; | 59 const std::string& data); |
48 Response DispatchSyncEvent(const std::string& origin, | 60 Response DispatchSyncEvent(const std::string& origin, |
49 const std::string& registration_id, | 61 const std::string& registration_id, |
50 const std::string& tag, | 62 const std::string& tag, |
51 bool last_chance) override; | 63 bool last_chance); |
52 | 64 |
53 private: | 65 private: |
54 void OnWorkerRegistrationUpdated( | 66 void OnWorkerRegistrationUpdated( |
55 const std::vector<ServiceWorkerRegistrationInfo>& registrations); | 67 const std::vector<ServiceWorkerRegistrationInfo>& registrations); |
56 void OnWorkerVersionUpdated( | 68 void OnWorkerVersionUpdated( |
57 const std::vector<ServiceWorkerVersionInfo>& registrations); | 69 const std::vector<ServiceWorkerVersionInfo>& registrations); |
58 void OnErrorReported(int64_t registration_id, | 70 void OnErrorReported(int64_t registration_id, |
59 int64_t version_id, | 71 int64_t version_id, |
60 const ServiceWorkerContextObserver::ErrorInfo& info); | 72 const ServiceWorkerContextObserver::ErrorInfo& info); |
61 | 73 |
62 void OpenNewDevToolsWindow(int process_id, int devtools_agent_route_id); | 74 void OpenNewDevToolsWindow(int process_id, int devtools_agent_route_id); |
63 void ClearForceUpdate(); | 75 void ClearForceUpdate(); |
64 | 76 |
65 scoped_refptr<ServiceWorkerContextWrapper> context_; | 77 scoped_refptr<ServiceWorkerContextWrapper> context_; |
66 std::unique_ptr<ServiceWorker::Frontend> frontend_; | 78 std::unique_ptr<Client> client_; |
67 bool enabled_; | 79 bool enabled_; |
68 scoped_refptr<ServiceWorkerContextWatcher> context_watcher_; | 80 scoped_refptr<ServiceWorkerContextWatcher> context_watcher_; |
69 RenderFrameHostImpl* render_frame_host_; | 81 RenderFrameHostImpl* render_frame_host_; |
70 | 82 |
71 base::WeakPtrFactory<ServiceWorkerHandler> weak_factory_; | 83 base::WeakPtrFactory<ServiceWorkerHandler> weak_factory_; |
72 | 84 |
73 DISALLOW_COPY_AND_ASSIGN(ServiceWorkerHandler); | 85 DISALLOW_COPY_AND_ASSIGN(ServiceWorkerHandler); |
74 }; | 86 }; |
75 | 87 |
76 } // namespace protocol | 88 } // namespace service_worker |
| 89 } // namespace devtools |
77 } // namespace content | 90 } // namespace content |
78 | 91 |
79 #endif // CONTENT_BROWSER_DEVTOOLS_PROTOCOL_SERVICE_WORKER_HANDLER_H_ | 92 #endif // CONTENT_BROWSER_DEVTOOLS_PROTOCOL_SERVICE_WORKER_HANDLER_H_ |
OLD | NEW |