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 #include <vector> | 9 #include <vector> |
10 | 10 |
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
63 // (This is attached only to the document thread's ServiceWorkerDispatcher) | 63 // (This is attached only to the document thread's ServiceWorkerDispatcher) |
64 void AddProviderContext(ServiceWorkerProviderContext* provider_context); | 64 void AddProviderContext(ServiceWorkerProviderContext* provider_context); |
65 void RemoveProviderContext(ServiceWorkerProviderContext* provider_context); | 65 void RemoveProviderContext(ServiceWorkerProviderContext* provider_context); |
66 | 66 |
67 // Called when navigator.serviceWorker is instantiated or detached | 67 // Called when navigator.serviceWorker is instantiated or detached |
68 // for a document whose provider can be identified by |provider_id|. | 68 // for a document whose provider can be identified by |provider_id|. |
69 void AddScriptClient(int provider_id, | 69 void AddScriptClient(int provider_id, |
70 blink::WebServiceWorkerProviderClient* client); | 70 blink::WebServiceWorkerProviderClient* client); |
71 void RemoveScriptClient(int provider_id); | 71 void RemoveScriptClient(int provider_id); |
72 | 72 |
| 73 // If an existing WebServiceWorkerImpl exists for the Service |
| 74 // Worker, it is returned; otherwise a WebServiceWorkerImpl is |
| 75 // created and its ownership is transferred to the caller. If |
| 76 // |adopt_handle| is true, a ServiceWorkerHandleReference will be |
| 77 // adopted for the specified Service Worker. |
| 78 // |
| 79 // TODO(dominicc): The lifetime of WebServiceWorkerImpl is too tricky; this |
| 80 // method can return an existing WebServiceWorkerImpl, in which case |
| 81 // it is owned by a WebCore::ServiceWorker and the lifetime is not |
| 82 // being transferred to the owner; or it can create a |
| 83 // WebServiceWorkerImpl, in which case ownership is transferred to |
| 84 // the caller who must bounce it to a method that will associate it |
| 85 // with a WebCore::ServiceWorker. |
| 86 WebServiceWorkerImpl* GetServiceWorker(const ServiceWorkerObjectInfo&, |
| 87 bool adopt_handle); |
| 88 |
73 // |thread_safe_sender| needs to be passed in because if the call leads to | 89 // |thread_safe_sender| needs to be passed in because if the call leads to |
74 // construction it will be needed. | 90 // construction it will be needed. |
75 static ServiceWorkerDispatcher* GetOrCreateThreadSpecificInstance( | 91 static ServiceWorkerDispatcher* GetOrCreateThreadSpecificInstance( |
76 ThreadSafeSender* thread_safe_sender); | 92 ThreadSafeSender* thread_safe_sender); |
77 | 93 |
78 // Unlike GetOrCreateThreadSpecificInstance() this doesn't create a new | 94 // Unlike GetOrCreateThreadSpecificInstance() this doesn't create a new |
79 // instance if thread-local instance doesn't exist. | 95 // instance if thread-local instance doesn't exist. |
80 static ServiceWorkerDispatcher* GetThreadSpecificInstance(); | 96 static ServiceWorkerDispatcher* GetThreadSpecificInstance(); |
81 | 97 |
82 private: | 98 private: |
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
127 WorkerToProviderMap worker_to_provider_; | 143 WorkerToProviderMap worker_to_provider_; |
128 | 144 |
129 scoped_refptr<ThreadSafeSender> thread_safe_sender_; | 145 scoped_refptr<ThreadSafeSender> thread_safe_sender_; |
130 | 146 |
131 DISALLOW_COPY_AND_ASSIGN(ServiceWorkerDispatcher); | 147 DISALLOW_COPY_AND_ASSIGN(ServiceWorkerDispatcher); |
132 }; | 148 }; |
133 | 149 |
134 } // namespace content | 150 } // namespace content |
135 | 151 |
136 #endif // CONTENT_CHILD_SERVICE_WORKER_SERVICE_WORKER_DISPATCHER_H_ | 152 #endif // CONTENT_CHILD_SERVICE_WORKER_SERVICE_WORKER_DISPATCHER_H_ |
OLD | NEW |