OLD | NEW |
(Empty) | |
| 1 // Copyright 2013 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. |
| 4 |
| 5 #ifndef CONTENT_CHILD_SERVICE_WORKER_SERVICE_WORKER_DISPATCHER_H_ |
| 6 #define CONTENT_CHILD_SERVICE_WORKER_SERVICE_WORKER_DISPATCHER_H_ |
| 7 |
| 8 #include "base/id_map.h" |
| 9 #include "base/memory/ref_counted.h" |
| 10 #include "base/strings/string16.h" |
| 11 #include "third_party/WebKit/public/platform/WebServiceWorkerProvider.h" |
| 12 #include "webkit/child/worker_task_runner.h" |
| 13 |
| 14 class GURL; |
| 15 |
| 16 namespace WebKit { |
| 17 class WebURL; |
| 18 } |
| 19 |
| 20 namespace IPC { |
| 21 class Message; |
| 22 } |
| 23 |
| 24 namespace content { |
| 25 class ServiceWorkerMessageFilter; |
| 26 class ThreadSafeSender; |
| 27 class WebServiceWorkerImpl; |
| 28 |
| 29 // This class manages communication with the browser process about |
| 30 // registration of the service worker, exposed to renderer and worker |
| 31 // scripts through methods like navigator.registerServiceWorker(). |
| 32 class ServiceWorkerDispatcher : public webkit_glue::WorkerTaskRunner::Observer { |
| 33 public: |
| 34 explicit ServiceWorkerDispatcher(ThreadSafeSender* thread_safe_sender); |
| 35 virtual ~ServiceWorkerDispatcher(); |
| 36 |
| 37 void OnMessageReceived(const IPC::Message& msg); |
| 38 bool Send(IPC::Message* msg); |
| 39 |
| 40 // Corresponds to navigator.registerServiceWorker() |
| 41 void RegisterServiceWorker( |
| 42 const GURL& pattern, |
| 43 const GURL& script_url, |
| 44 WebKit::WebServiceWorkerProvider::WebServiceWorkerCallbacks* callbacks); |
| 45 // Corresponds to navigator.unregisterServiceWorker() |
| 46 void UnregisterServiceWorker( |
| 47 const GURL& pattern, |
| 48 WebKit::WebServiceWorkerProvider::WebServiceWorkerCallbacks* callbacks); |
| 49 |
| 50 // |thread_safe_sender| needs to be passed in because if the call leads to |
| 51 // construction it will be needed. |
| 52 static ServiceWorkerDispatcher* ThreadSpecificInstance( |
| 53 ThreadSafeSender* thread_safe_sender); |
| 54 |
| 55 private: |
| 56 // webkit_glue::WorkerTaskRunner::Observer implementation. |
| 57 virtual void OnWorkerRunLoopStopped() OVERRIDE; |
| 58 |
| 59 // The asynchronous success response to RegisterServiceWorker. |
| 60 void OnServiceWorkerRegistered(int32 thread_id, |
| 61 int32 request_id, |
| 62 int64 service_worker_id); |
| 63 // The asynchronous success response to UregisterServiceWorker. |
| 64 void OnServiceWorkerUnregistered(int32 thread_id, int32 request_id); |
| 65 |
| 66 IDMap<WebKit::WebServiceWorkerProvider::WebServiceWorkerCallbacks, |
| 67 IDMapOwnPointer> pending_callbacks_; |
| 68 |
| 69 scoped_refptr<ThreadSafeSender> thread_safe_sender_; |
| 70 |
| 71 DISALLOW_COPY_AND_ASSIGN(ServiceWorkerDispatcher); |
| 72 }; |
| 73 |
| 74 } // namespace content |
| 75 |
| 76 #endif // CONTENT_CHILD_SERVICE_WORKER_SERVICE_WORKER_DISPATCHER_H_ |
OLD | NEW |