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 ThreadSafeSender; |
| 26 class ServiceWorkerMessageFilter; |
| 27 class WebServiceWorkerImpl; |
| 28 |
| 29 class ServiceWorkerDispatcher : public webkit_glue::WorkerTaskRunner::Observer { |
| 30 public: |
| 31 ServiceWorkerDispatcher(ThreadSafeSender* thread_safe_sender); |
| 32 virtual ~ServiceWorkerDispatcher(); |
| 33 |
| 34 // webkit_glue::WorkerTaskRunner::Observer implementation. |
| 35 virtual void OnWorkerRunLoopStopped() OVERRIDE; |
| 36 |
| 37 void OnMessageReceived(const IPC::Message& msg); |
| 38 bool Send(IPC::Message* msg); |
| 39 |
| 40 void RegisterServiceWorker( |
| 41 const WebKit::WebURL& origin, |
| 42 const string16& pattern, |
| 43 const GURL& script_url, |
| 44 WebKit::WebServiceWorkerProvider::WebServiceWorkerCallbacks* callbacks); |
| 45 void UnregisterServiceWorker( |
| 46 const WebKit::WebURL& origin, |
| 47 const string16& 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 void OnServiceWorkerRegistered(int32 thread_id, |
| 57 int32 request_id, |
| 58 int32 worker_id); |
| 59 void OnServiceWorkerUnregistered(int32 thread_id, |
| 60 int32 request_id, |
| 61 int32 worker_id); |
| 62 |
| 63 IDMap<WebKit::WebServiceWorkerProvider::WebServiceWorkerCallbacks, |
| 64 IDMapOwnPointer> pending_callbacks_; |
| 65 |
| 66 scoped_refptr<ThreadSafeSender> thread_safe_sender_; |
| 67 |
| 68 DISALLOW_COPY_AND_ASSIGN(ServiceWorkerDispatcher); |
| 69 }; |
| 70 |
| 71 } // namespace content |
| 72 |
| 73 #endif // CONTENT_CHILD_SERVICE_WORKER_SERVICE_WORKER_DISPATCHER_H_ |
OLD | NEW |