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