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_PROVIDER_HOST_H_ | 5 #ifndef CONTENT_BROWSER_SERVICE_WORKER_SERVICE_WORKER_PROVIDER_HOST_H_ |
6 #define CONTENT_BROWSER_SERVICE_WORKER_SERVICE_WORKER_PROVIDER_HOST_H_ | 6 #define CONTENT_BROWSER_SERVICE_WORKER_SERVICE_WORKER_PROVIDER_HOST_H_ |
7 | 7 |
8 #include <set> | 8 #include <set> |
9 #include <vector> | 9 #include <vector> |
10 | 10 |
(...skipping 16 matching lines...) Expand all Loading... |
27 | 27 |
28 namespace content { | 28 namespace content { |
29 | 29 |
30 class ResourceRequestBody; | 30 class ResourceRequestBody; |
31 class ServiceWorkerContextCore; | 31 class ServiceWorkerContextCore; |
32 class ServiceWorkerDispatcherHost; | 32 class ServiceWorkerDispatcherHost; |
33 class ServiceWorkerRequestHandler; | 33 class ServiceWorkerRequestHandler; |
34 class ServiceWorkerVersion; | 34 class ServiceWorkerVersion; |
35 | 35 |
36 // This class is the browser-process representation of a service worker | 36 // This class is the browser-process representation of a service worker |
37 // provider. There is a provider per document and the lifetime of this | 37 // provider. There is a provider per document or a worker and the lifetime |
38 // object is tied to the lifetime of its document in the renderer process. | 38 // of this object is tied to the lifetime of its document or the worker |
| 39 // in the renderer process. |
39 // This class holds service worker state that is scoped to an individual | 40 // This class holds service worker state that is scoped to an individual |
40 // document. | 41 // document or a worker. |
41 // | 42 // |
42 // Note this class can also host a running service worker, in which | 43 // Note this class can also host a running service worker, in which |
43 // case it will observe resource loads made directly by the service worker. | 44 // case it will observe resource loads made directly by the service worker. |
44 class CONTENT_EXPORT ServiceWorkerProviderHost | 45 class CONTENT_EXPORT ServiceWorkerProviderHost |
45 : public NON_EXPORTED_BASE(ServiceWorkerRegistration::Listener), | 46 : public NON_EXPORTED_BASE(ServiceWorkerRegistration::Listener), |
46 public base::SupportsWeakPtr<ServiceWorkerProviderHost> { | 47 public base::SupportsWeakPtr<ServiceWorkerProviderHost> { |
47 public: | 48 public: |
48 using GetClientInfoCallback = | 49 using GetClientInfoCallback = |
49 base::Callback<void(const ServiceWorkerClientInfo&)>; | 50 base::Callback<void(const ServiceWorkerClientInfo&)>; |
50 | 51 |
51 // If |render_frame_id| is MSG_ROUTING_NONE, this provider host works for the | 52 // If |render_frame_id| is MSG_ROUTING_NONE, this provider host works for the |
52 // worker context, i.e. ServiceWorker or SharedWorker. | 53 // worker context, i.e. ServiceWorker or SharedWorker. |
53 // |provider_type| gives additional information whether the provider is | 54 // |provider_type| gives additional information whether the provider is |
54 // created for controller (ServiceWorker) or controllee (Document or | 55 // created for controller (ServiceWorker) or controllee (Document or |
55 // SharedWorker). | 56 // SharedWorker). |
56 ServiceWorkerProviderHost(int render_process_id, | 57 ServiceWorkerProviderHost(int render_process_id, |
57 int render_frame_id, | 58 int render_frame_id, |
58 int provider_id, | 59 int provider_id, |
59 ServiceWorkerProviderType provider_type, | 60 ServiceWorkerProviderType provider_type, |
60 base::WeakPtr<ServiceWorkerContextCore> context, | 61 base::WeakPtr<ServiceWorkerContextCore> context, |
61 ServiceWorkerDispatcherHost* dispatcher_host); | 62 ServiceWorkerDispatcherHost* dispatcher_host); |
62 virtual ~ServiceWorkerProviderHost(); | 63 virtual ~ServiceWorkerProviderHost(); |
63 | 64 |
| 65 const std::string& client_uuid() const { return client_uuid_; } |
64 int process_id() const { return render_process_id_; } | 66 int process_id() const { return render_process_id_; } |
65 int provider_id() const { return provider_id_; } | 67 int provider_id() const { return provider_id_; } |
66 int frame_id() const { return render_frame_id_; } | 68 int frame_id() const { return render_frame_id_; } |
67 | 69 |
68 bool IsHostToRunningServiceWorker() { | 70 bool IsHostToRunningServiceWorker() { |
69 return running_hosted_version_.get() != NULL; | 71 return running_hosted_version_.get() != NULL; |
70 } | 72 } |
71 | 73 |
72 ServiceWorkerVersion* controlling_version() const { | 74 ServiceWorkerVersion* controlling_version() const { |
73 return controlling_version_.get(); | 75 return controlling_version_.get(); |
(...skipping 141 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
215 | 217 |
216 void SendAssociateRegistrationMessage(); | 218 void SendAssociateRegistrationMessage(); |
217 | 219 |
218 // Increase/decrease this host's process reference for |pattern|. | 220 // Increase/decrease this host's process reference for |pattern|. |
219 void IncreaseProcessReference(const GURL& pattern); | 221 void IncreaseProcessReference(const GURL& pattern); |
220 void DecreaseProcessReference(const GURL& pattern); | 222 void DecreaseProcessReference(const GURL& pattern); |
221 | 223 |
222 bool IsReadyToSendMessages() const; | 224 bool IsReadyToSendMessages() const; |
223 void Send(IPC::Message* message) const; | 225 void Send(IPC::Message* message) const; |
224 | 226 |
| 227 std::string client_uuid_; |
225 int render_process_id_; | 228 int render_process_id_; |
226 int render_frame_id_; | 229 int render_frame_id_; |
227 int render_thread_id_; | 230 int render_thread_id_; |
228 int provider_id_; | 231 int provider_id_; |
229 ServiceWorkerProviderType provider_type_; | 232 ServiceWorkerProviderType provider_type_; |
230 GURL document_url_; | 233 GURL document_url_; |
231 GURL topmost_frame_url_; | 234 GURL topmost_frame_url_; |
232 | 235 |
233 std::vector<GURL> associated_patterns_; | 236 std::vector<GURL> associated_patterns_; |
234 scoped_refptr<ServiceWorkerRegistration> associated_registration_; | 237 scoped_refptr<ServiceWorkerRegistration> associated_registration_; |
235 | 238 |
236 scoped_refptr<ServiceWorkerVersion> controlling_version_; | 239 scoped_refptr<ServiceWorkerVersion> controlling_version_; |
237 scoped_refptr<ServiceWorkerVersion> running_hosted_version_; | 240 scoped_refptr<ServiceWorkerVersion> running_hosted_version_; |
238 base::WeakPtr<ServiceWorkerContextCore> context_; | 241 base::WeakPtr<ServiceWorkerContextCore> context_; |
239 ServiceWorkerDispatcherHost* dispatcher_host_; | 242 ServiceWorkerDispatcherHost* dispatcher_host_; |
240 bool allow_association_; | 243 bool allow_association_; |
241 bool is_claiming_; | 244 bool is_claiming_; |
242 | 245 |
243 std::vector<base::Closure> queued_events_; | 246 std::vector<base::Closure> queued_events_; |
244 | 247 |
245 DISALLOW_COPY_AND_ASSIGN(ServiceWorkerProviderHost); | 248 DISALLOW_COPY_AND_ASSIGN(ServiceWorkerProviderHost); |
246 }; | 249 }; |
247 | 250 |
248 } // namespace content | 251 } // namespace content |
249 | 252 |
250 #endif // CONTENT_BROWSER_SERVICE_WORKER_SERVICE_WORKER_PROVIDER_HOST_H_ | 253 #endif // CONTENT_BROWSER_SERVICE_WORKER_SERVICE_WORKER_PROVIDER_HOST_H_ |
OLD | NEW |