| 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_BROWSER_SERVICE_WORKER_SERVICE_WORKER_DISPATCHER_HOST_H_ | 5 #ifndef CONTENT_BROWSER_SERVICE_WORKER_SERVICE_WORKER_DISPATCHER_HOST_H_ |
| 6 #define CONTENT_BROWSER_SERVICE_WORKER_SERVICE_WORKER_DISPATCHER_HOST_H_ | 6 #define CONTENT_BROWSER_SERVICE_WORKER_SERVICE_WORKER_DISPATCHER_HOST_H_ |
| 7 | 7 |
| 8 #include <vector> | 8 #include <vector> |
| 9 | 9 |
| 10 #include "base/id_map.h" | 10 #include "base/id_map.h" |
| (...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 47 bool OnMessageReceived(const IPC::Message& message) override; | 47 bool OnMessageReceived(const IPC::Message& message) override; |
| 48 | 48 |
| 49 // IPC::Sender implementation | 49 // IPC::Sender implementation |
| 50 | 50 |
| 51 // Send() queues the message until the underlying sender is ready. This | 51 // Send() queues the message until the underlying sender is ready. This |
| 52 // class assumes that Send() can only fail after that when the renderer | 52 // class assumes that Send() can only fail after that when the renderer |
| 53 // process has terminated, at which point the whole instance will eventually | 53 // process has terminated, at which point the whole instance will eventually |
| 54 // be destroyed. | 54 // be destroyed. |
| 55 bool Send(IPC::Message* message) override; | 55 bool Send(IPC::Message* message) override; |
| 56 | 56 |
| 57 void RegisterServiceWorkerHandle(scoped_ptr<ServiceWorkerHandle> handle); |
| 58 void RegisterServiceWorkerRegistrationHandle( |
| 59 scoped_ptr<ServiceWorkerRegistrationHandle> handle); |
| 60 |
| 57 // Returns the existing registration handle whose reference count is | 61 // Returns the existing registration handle whose reference count is |
| 58 // incremented or newly created one if it doesn't exist. | 62 // incremented or newly created one if it doesn't exist. |
| 59 ServiceWorkerRegistrationHandle* GetOrCreateRegistrationHandle( | 63 ServiceWorkerRegistrationHandle* GetOrCreateRegistrationHandle( |
| 60 int provider_id, | 64 base::WeakPtr<ServiceWorkerProviderHost> provider_host, |
| 61 ServiceWorkerRegistration* registration); | 65 ServiceWorkerRegistration* registration); |
| 62 | 66 |
| 63 // Creates a ServiceWorkerHandle to retain |version| and returns a | |
| 64 // ServiceWorkerInfo with a newly created handle ID. The handle is held in | |
| 65 // the dispatcher host until its ref-count becomes zero via | |
| 66 // OnDecrementServiceWorkerRefCount. | |
| 67 ServiceWorkerObjectInfo CreateAndRegisterServiceWorkerHandle( | |
| 68 ServiceWorkerVersion* version); | |
| 69 | |
| 70 MessagePortMessageFilter* message_port_message_filter() { | 67 MessagePortMessageFilter* message_port_message_filter() { |
| 71 return message_port_message_filter_; | 68 return message_port_message_filter_; |
| 72 } | 69 } |
| 73 | 70 |
| 74 protected: | 71 protected: |
| 75 ~ServiceWorkerDispatcherHost() override; | 72 ~ServiceWorkerDispatcherHost() override; |
| 76 | 73 |
| 77 private: | 74 private: |
| 78 friend class BrowserThread; | 75 friend class BrowserThread; |
| 79 friend class base::DeleteHelper<ServiceWorkerDispatcherHost>; | 76 friend class base::DeleteHelper<ServiceWorkerDispatcherHost>; |
| (...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 117 void OnIncrementServiceWorkerRefCount(int handle_id); | 114 void OnIncrementServiceWorkerRefCount(int handle_id); |
| 118 void OnDecrementServiceWorkerRefCount(int handle_id); | 115 void OnDecrementServiceWorkerRefCount(int handle_id); |
| 119 void OnIncrementRegistrationRefCount(int registration_handle_id); | 116 void OnIncrementRegistrationRefCount(int registration_handle_id); |
| 120 void OnDecrementRegistrationRefCount(int registration_handle_id); | 117 void OnDecrementRegistrationRefCount(int registration_handle_id); |
| 121 void OnPostMessageToWorker(int handle_id, | 118 void OnPostMessageToWorker(int handle_id, |
| 122 const base::string16& message, | 119 const base::string16& message, |
| 123 const std::vector<int>& sent_message_port_ids); | 120 const std::vector<int>& sent_message_port_ids); |
| 124 void OnServiceWorkerObjectDestroyed(int handle_id); | 121 void OnServiceWorkerObjectDestroyed(int handle_id); |
| 125 void OnTerminateWorker(int handle_id); | 122 void OnTerminateWorker(int handle_id); |
| 126 | 123 |
| 127 void RegisterServiceWorkerHandle(scoped_ptr<ServiceWorkerHandle> handle); | |
| 128 void RegisterServiceWorkerRegistrationHandle( | |
| 129 scoped_ptr<ServiceWorkerRegistrationHandle> handle); | |
| 130 | |
| 131 ServiceWorkerRegistrationHandle* FindRegistrationHandle( | 124 ServiceWorkerRegistrationHandle* FindRegistrationHandle( |
| 132 int provider_id, | 125 int provider_id, |
| 133 int64 registration_id); | 126 int64 registration_id); |
| 134 | 127 |
| 135 void GetRegistrationObjectInfoAndVersionAttributes( | 128 void GetRegistrationObjectInfoAndVersionAttributes( |
| 136 int provider_id, | 129 base::WeakPtr<ServiceWorkerProviderHost> provider_host, |
| 137 ServiceWorkerRegistration* registration, | 130 ServiceWorkerRegistration* registration, |
| 138 ServiceWorkerRegistrationObjectInfo* info, | 131 ServiceWorkerRegistrationObjectInfo* info, |
| 139 ServiceWorkerVersionAttributes* attrs); | 132 ServiceWorkerVersionAttributes* attrs); |
| 140 | 133 |
| 141 // Callbacks from ServiceWorkerContextCore | 134 // Callbacks from ServiceWorkerContextCore |
| 142 void RegistrationComplete(int thread_id, | 135 void RegistrationComplete(int thread_id, |
| 143 int provider_id, | 136 int provider_id, |
| 144 int request_id, | 137 int request_id, |
| 145 ServiceWorkerStatusCode status, | 138 ServiceWorkerStatusCode status, |
| 146 const std::string& status_message, | 139 const std::string& status_message, |
| (...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 182 | 175 |
| 183 bool channel_ready_; // True after BrowserMessageFilter::sender_ != NULL. | 176 bool channel_ready_; // True after BrowserMessageFilter::sender_ != NULL. |
| 184 ScopedVector<IPC::Message> pending_messages_; | 177 ScopedVector<IPC::Message> pending_messages_; |
| 185 | 178 |
| 186 DISALLOW_COPY_AND_ASSIGN(ServiceWorkerDispatcherHost); | 179 DISALLOW_COPY_AND_ASSIGN(ServiceWorkerDispatcherHost); |
| 187 }; | 180 }; |
| 188 | 181 |
| 189 } // namespace content | 182 } // namespace content |
| 190 | 183 |
| 191 #endif // CONTENT_BROWSER_SERVICE_WORKER_SERVICE_WORKER_DISPATCHER_HOST_H_ | 184 #endif // CONTENT_BROWSER_SERVICE_WORKER_SERVICE_WORKER_DISPATCHER_HOST_H_ |
| OLD | NEW |