OLD | NEW |
1 // Copyright 2013 The Chromium Authors. All rights reserved. | 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 | 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_CHILD_SERVICE_WORKER_SERVICE_WORKER_DISPATCHER_H_ | 5 #ifndef CONTENT_CHILD_SERVICE_WORKER_SERVICE_WORKER_DISPATCHER_H_ |
6 #define CONTENT_CHILD_SERVICE_WORKER_SERVICE_WORKER_DISPATCHER_H_ | 6 #define CONTENT_CHILD_SERVICE_WORKER_SERVICE_WORKER_DISPATCHER_H_ |
7 | 7 |
8 #include <map> | 8 #include <map> |
9 | 9 |
10 #include "base/id_map.h" | 10 #include "base/id_map.h" |
(...skipping 24 matching lines...) Expand all Loading... |
35 class ServiceWorkerDispatcher : public WorkerTaskRunner::Observer { | 35 class ServiceWorkerDispatcher : public WorkerTaskRunner::Observer { |
36 public: | 36 public: |
37 explicit ServiceWorkerDispatcher(ThreadSafeSender* thread_safe_sender); | 37 explicit ServiceWorkerDispatcher(ThreadSafeSender* thread_safe_sender); |
38 virtual ~ServiceWorkerDispatcher(); | 38 virtual ~ServiceWorkerDispatcher(); |
39 | 39 |
40 void OnMessageReceived(const IPC::Message& msg); | 40 void OnMessageReceived(const IPC::Message& msg); |
41 bool Send(IPC::Message* msg); | 41 bool Send(IPC::Message* msg); |
42 | 42 |
43 // Corresponds to navigator.serviceWorker.register() | 43 // Corresponds to navigator.serviceWorker.register() |
44 void RegisterServiceWorker( | 44 void RegisterServiceWorker( |
| 45 int provider_id, |
45 const GURL& pattern, | 46 const GURL& pattern, |
46 const GURL& script_url, | 47 const GURL& script_url, |
47 blink::WebServiceWorkerProvider::WebServiceWorkerCallbacks* callbacks); | 48 blink::WebServiceWorkerProvider::WebServiceWorkerCallbacks* callbacks); |
48 // Corresponds to navigator.serviceWorker.unregister() | 49 // Corresponds to navigator.serviceWorker.unregister() |
49 void UnregisterServiceWorker( | 50 void UnregisterServiceWorker( |
| 51 int provider_id, |
50 const GURL& pattern, | 52 const GURL& pattern, |
51 blink::WebServiceWorkerProvider::WebServiceWorkerCallbacks* callbacks); | 53 blink::WebServiceWorkerProvider::WebServiceWorkerCallbacks* callbacks); |
52 | 54 |
53 // Called when navigator.serviceWorker is instantiated or detached | 55 // Called when navigator.serviceWorker is instantiated or detached |
54 // for a document whose provider can be identified by |provider_id|. | 56 // for a document whose provider can be identified by |provider_id|. |
55 void AddScriptClient(int provider_id, | 57 void AddScriptClient(int provider_id, |
56 blink::WebServiceWorkerProviderClient* client); | 58 blink::WebServiceWorkerProviderClient* client); |
57 void RemoveScriptClient(int provider_id); | 59 void RemoveScriptClient(int provider_id); |
58 | 60 |
59 // |thread_safe_sender| needs to be passed in because if the call leads to | 61 // |thread_safe_sender| needs to be passed in because if the call leads to |
60 // construction it will be needed. | 62 // construction it will be needed. |
61 static ServiceWorkerDispatcher* ThreadSpecificInstance( | 63 static ServiceWorkerDispatcher* ThreadSpecificInstance( |
62 ThreadSafeSender* thread_safe_sender); | 64 ThreadSafeSender* thread_safe_sender); |
63 | 65 |
64 private: | 66 private: |
65 typedef std::map<int, blink::WebServiceWorkerProviderClient*> ScriptClientMap; | 67 typedef std::map<int, blink::WebServiceWorkerProviderClient*> ScriptClientMap; |
66 | 68 |
67 // WorkerTaskRunner::Observer implementation. | 69 // WorkerTaskRunner::Observer implementation. |
68 virtual void OnWorkerRunLoopStopped() OVERRIDE; | 70 virtual void OnWorkerRunLoopStopped() OVERRIDE; |
69 | 71 |
70 // The asynchronous success response to RegisterServiceWorker. | 72 // The asynchronous success response to RegisterServiceWorker. |
71 void OnRegistered(int32 thread_id, | 73 void OnRegistered(int thread_id, |
72 int32 request_id, | 74 int request_id, |
73 int handle_id); | 75 int handle_id); |
74 // The asynchronous success response to UregisterServiceWorker. | 76 // The asynchronous success response to UregisterServiceWorker. |
75 void OnUnregistered(int32 thread_id, | 77 void OnUnregistered(int thread_id, |
76 int32 request_id); | 78 int request_id); |
77 void OnRegistrationError(int32 thread_id, | 79 void OnRegistrationError(int thread_id, |
78 int32 request_id, | 80 int request_id, |
79 blink::WebServiceWorkerError::ErrorType error_type, | 81 blink::WebServiceWorkerError::ErrorType error_type, |
80 const base::string16& message); | 82 const base::string16& message); |
81 | 83 |
82 IDMap<blink::WebServiceWorkerProvider::WebServiceWorkerCallbacks, | 84 IDMap<blink::WebServiceWorkerProvider::WebServiceWorkerCallbacks, |
83 IDMapOwnPointer> pending_callbacks_; | 85 IDMapOwnPointer> pending_callbacks_; |
84 ScriptClientMap script_clients_; | 86 ScriptClientMap script_clients_; |
85 | 87 |
86 scoped_refptr<ThreadSafeSender> thread_safe_sender_; | 88 scoped_refptr<ThreadSafeSender> thread_safe_sender_; |
87 | 89 |
88 DISALLOW_COPY_AND_ASSIGN(ServiceWorkerDispatcher); | 90 DISALLOW_COPY_AND_ASSIGN(ServiceWorkerDispatcher); |
89 }; | 91 }; |
90 | 92 |
91 } // namespace content | 93 } // namespace content |
92 | 94 |
93 #endif // CONTENT_CHILD_SERVICE_WORKER_SERVICE_WORKER_DISPATCHER_H_ | 95 #endif // CONTENT_CHILD_SERVICE_WORKER_SERVICE_WORKER_DISPATCHER_H_ |
OLD | NEW |