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 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
44 // 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. |
45 class CONTENT_EXPORT ServiceWorkerProviderHost | 45 class CONTENT_EXPORT ServiceWorkerProviderHost |
46 : public NON_EXPORTED_BASE(ServiceWorkerRegistration::Listener), | 46 : public NON_EXPORTED_BASE(ServiceWorkerRegistration::Listener), |
47 public base::SupportsWeakPtr<ServiceWorkerProviderHost> { | 47 public base::SupportsWeakPtr<ServiceWorkerProviderHost> { |
48 public: | 48 public: |
49 using GetClientInfoCallback = | 49 using GetClientInfoCallback = |
50 base::Callback<void(const ServiceWorkerClientInfo&)>; | 50 base::Callback<void(const ServiceWorkerClientInfo&)>; |
51 using GetRegistrationForReadyCallback = | 51 using GetRegistrationForReadyCallback = |
52 base::Callback<void(ServiceWorkerRegistration* reigstration)>; | 52 base::Callback<void(ServiceWorkerRegistration* reigstration)>; |
53 | 53 |
54 // If |render_frame_id| is MSG_ROUTING_NONE, this provider host works for the | 54 // When this provider host is for a Service Worker context, |route_id| is |
55 // worker context, i.e. ServiceWorker or SharedWorker. | 55 // MSG_ROUTING_NONE. When this provider host is for a Document, |
| 56 // |route_id| is the frame ID of the Document. When this provider host is for |
| 57 // a Shared Worker, |route_id| is the Shared Worker route ID. |
56 // |provider_type| gives additional information whether the provider is | 58 // |provider_type| gives additional information whether the provider is |
57 // created for controller (ServiceWorker) or controllee (Document or | 59 // created for controller (ServiceWorker) or controllee (Document or |
58 // SharedWorker). | 60 // SharedWorker). |
59 ServiceWorkerProviderHost(int render_process_id, | 61 ServiceWorkerProviderHost(int render_process_id, |
60 int render_frame_id, | 62 int route_id, |
61 int provider_id, | 63 int provider_id, |
62 ServiceWorkerProviderType provider_type, | 64 ServiceWorkerProviderType provider_type, |
63 base::WeakPtr<ServiceWorkerContextCore> context, | 65 base::WeakPtr<ServiceWorkerContextCore> context, |
64 ServiceWorkerDispatcherHost* dispatcher_host); | 66 ServiceWorkerDispatcherHost* dispatcher_host); |
65 virtual ~ServiceWorkerProviderHost(); | 67 virtual ~ServiceWorkerProviderHost(); |
66 | 68 |
67 const std::string& client_uuid() const { return client_uuid_; } | 69 const std::string& client_uuid() const { return client_uuid_; } |
68 int process_id() const { return render_process_id_; } | 70 int process_id() const { return render_process_id_; } |
69 int provider_id() const { return provider_id_; } | 71 int provider_id() const { return provider_id_; } |
70 int frame_id() const { return render_frame_id_; } | 72 int frame_id() const; |
| 73 int route_id() const { return route_id_; } |
71 | 74 |
72 bool IsHostToRunningServiceWorker() { | 75 bool IsHostToRunningServiceWorker() { |
73 return running_hosted_version_.get() != NULL; | 76 return running_hosted_version_.get() != NULL; |
74 } | 77 } |
75 | 78 |
76 ServiceWorkerVersion* controlling_version() const { | 79 ServiceWorkerVersion* controlling_version() const { |
77 return controlling_version_.get(); | 80 return controlling_version_.get(); |
78 } | 81 } |
79 ServiceWorkerVersion* active_version() const { | 82 ServiceWorkerVersion* active_version() const { |
80 return associated_registration_.get() ? | 83 return associated_registration_.get() ? |
(...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
152 // Returns true if the context referred to by this host (i.e. |context_|) is | 155 // Returns true if the context referred to by this host (i.e. |context_|) is |
153 // still alive. | 156 // still alive. |
154 bool IsContextAlive(); | 157 bool IsContextAlive(); |
155 | 158 |
156 // Dispatches message event to the document. | 159 // Dispatches message event to the document. |
157 void PostMessage( | 160 void PostMessage( |
158 const base::string16& message, | 161 const base::string16& message, |
159 const std::vector<TransferredMessagePort>& sent_message_ports); | 162 const std::vector<TransferredMessagePort>& sent_message_ports); |
160 | 163 |
161 // Activates the WebContents associated with | 164 // Activates the WebContents associated with |
162 // { render_process_id_, render_frame_id_ }. | 165 // { render_process_id_, route_id_ }. |
163 // Runs the |callback| with the updated ServiceWorkerClientInfo in parameter. | 166 // Runs the |callback| with the updated ServiceWorkerClientInfo in parameter. |
164 void Focus(const GetClientInfoCallback& callback); | 167 void Focus(const GetClientInfoCallback& callback); |
165 | 168 |
166 // Asks the renderer to send back the document information. | 169 // Asks the renderer to send back the document information. |
167 void GetWindowClientInfo(const GetClientInfoCallback& callback) const; | 170 void GetWindowClientInfo(const GetClientInfoCallback& callback) const; |
168 | 171 |
169 // Same as above but has to be called from the UI thread. | 172 // Same as above but has to be called from the UI thread. |
170 // It is taking the process and frame ids in parameter because |this| is meant | 173 // It is taking the process and frame ids in parameter because |this| is meant |
171 // to live on the IO thread. | 174 // to live on the IO thread. |
172 static ServiceWorkerClientInfo GetWindowClientInfoOnUI(int render_process_id, | 175 static ServiceWorkerClientInfo GetWindowClientInfoOnUI(int render_process_id, |
173 int render_frame_id); | 176 int route_id); |
174 | 177 |
175 // Adds reference of this host's process to the |pattern|, the reference will | 178 // Adds reference of this host's process to the |pattern|, the reference will |
176 // be removed in destructor. | 179 // be removed in destructor. |
177 void AddScopedProcessReferenceToPattern(const GURL& pattern); | 180 void AddScopedProcessReferenceToPattern(const GURL& pattern); |
178 | 181 |
179 // |registration| claims the document to be controlled. | 182 // |registration| claims the document to be controlled. |
180 void ClaimedByRegistration(ServiceWorkerRegistration* registration); | 183 void ClaimedByRegistration(ServiceWorkerRegistration* registration); |
181 | 184 |
182 // Called by dispatcher host to get the registration for the "ready" property. | 185 // Called by dispatcher host to get the registration for the "ready" property. |
183 // Returns false if there's a completed or ongoing request for the document. | 186 // Returns false if there's a completed or ongoing request for the document. |
(...skipping 91 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
275 void IncreaseProcessReference(const GURL& pattern); | 278 void IncreaseProcessReference(const GURL& pattern); |
276 void DecreaseProcessReference(const GURL& pattern); | 279 void DecreaseProcessReference(const GURL& pattern); |
277 | 280 |
278 void ReturnRegistrationForReadyIfNeeded(); | 281 void ReturnRegistrationForReadyIfNeeded(); |
279 | 282 |
280 bool IsReadyToSendMessages() const; | 283 bool IsReadyToSendMessages() const; |
281 void Send(IPC::Message* message) const; | 284 void Send(IPC::Message* message) const; |
282 | 285 |
283 std::string client_uuid_; | 286 std::string client_uuid_; |
284 int render_process_id_; | 287 int render_process_id_; |
285 int render_frame_id_; | 288 int route_id_; |
286 int render_thread_id_; | 289 int render_thread_id_; |
287 int provider_id_; | 290 int provider_id_; |
288 ServiceWorkerProviderType provider_type_; | 291 ServiceWorkerProviderType provider_type_; |
289 GURL document_url_; | 292 GURL document_url_; |
290 GURL topmost_frame_url_; | 293 GURL topmost_frame_url_; |
291 | 294 |
292 std::vector<GURL> associated_patterns_; | 295 std::vector<GURL> associated_patterns_; |
293 scoped_refptr<ServiceWorkerRegistration> associated_registration_; | 296 scoped_refptr<ServiceWorkerRegistration> associated_registration_; |
294 | 297 |
295 // Keyed by registration scope URL length. | 298 // Keyed by registration scope URL length. |
(...skipping 11 matching lines...) Expand all Loading... |
307 bool allow_association_; | 310 bool allow_association_; |
308 | 311 |
309 std::vector<base::Closure> queued_events_; | 312 std::vector<base::Closure> queued_events_; |
310 | 313 |
311 DISALLOW_COPY_AND_ASSIGN(ServiceWorkerProviderHost); | 314 DISALLOW_COPY_AND_ASSIGN(ServiceWorkerProviderHost); |
312 }; | 315 }; |
313 | 316 |
314 } // namespace content | 317 } // namespace content |
315 | 318 |
316 #endif // CONTENT_BROWSER_SERVICE_WORKER_SERVICE_WORKER_PROVIDER_HOST_H_ | 319 #endif // CONTENT_BROWSER_SERVICE_WORKER_SERVICE_WORKER_PROVIDER_HOST_H_ |
OLD | NEW |