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_VERSION_H_ | 5 #ifndef CONTENT_BROWSER_SERVICE_WORKER_SERVICE_WORKER_VERSION_H_ |
6 #define CONTENT_BROWSER_SERVICE_WORKER_SERVICE_WORKER_VERSION_H_ | 6 #define CONTENT_BROWSER_SERVICE_WORKER_SERVICE_WORKER_VERSION_H_ |
7 | 7 |
8 #include <map> | 8 #include <map> |
9 #include <string> | 9 #include <string> |
10 #include <vector> | 10 #include <vector> |
(...skipping 230 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
241 | 241 |
242 ServiceWorkerScriptCacheMap* script_cache_map() { return &script_cache_map_; } | 242 ServiceWorkerScriptCacheMap* script_cache_map() { return &script_cache_map_; } |
243 EmbeddedWorkerInstance* embedded_worker() { return embedded_worker_.get(); } | 243 EmbeddedWorkerInstance* embedded_worker() { return embedded_worker_.get(); } |
244 | 244 |
245 // Dooms this version to have REDUNDANT status and its resources deleted. If | 245 // Dooms this version to have REDUNDANT status and its resources deleted. If |
246 // the version is controlling a page, these changes will happen when the | 246 // the version is controlling a page, these changes will happen when the |
247 // version no longer controls any pages. | 247 // version no longer controls any pages. |
248 void Doom(); | 248 void Doom(); |
249 bool is_doomed() const { return is_doomed_; } | 249 bool is_doomed() const { return is_doomed_; } |
250 | 250 |
| 251 void SetDevToolsAttached(bool attached); |
| 252 |
251 private: | 253 private: |
252 friend class base::RefCounted<ServiceWorkerVersion>; | 254 friend class base::RefCounted<ServiceWorkerVersion>; |
253 FRIEND_TEST_ALL_PREFIXES(ServiceWorkerControlleeRequestHandlerTest, | 255 FRIEND_TEST_ALL_PREFIXES(ServiceWorkerControlleeRequestHandlerTest, |
254 ActivateWaitingVersion); | 256 ActivateWaitingVersion); |
255 FRIEND_TEST_ALL_PREFIXES(ServiceWorkerVersionTest, ScheduleStopWorker); | 257 FRIEND_TEST_ALL_PREFIXES(ServiceWorkerVersionTest, ScheduleStopWorker); |
| 258 FRIEND_TEST_ALL_PREFIXES(ServiceWorkerVersionTest, KeepAlive); |
256 FRIEND_TEST_ALL_PREFIXES(ServiceWorkerVersionTest, ListenerAvailability); | 259 FRIEND_TEST_ALL_PREFIXES(ServiceWorkerVersionTest, ListenerAvailability); |
257 typedef ServiceWorkerVersion self; | 260 typedef ServiceWorkerVersion self; |
258 typedef std::map<ServiceWorkerProviderHost*, int> ControlleeMap; | 261 typedef std::map<ServiceWorkerProviderHost*, int> ControlleeMap; |
259 typedef IDMap<ServiceWorkerProviderHost> ControlleeByIDMap; | 262 typedef IDMap<ServiceWorkerProviderHost> ControlleeByIDMap; |
260 | 263 |
261 ~ServiceWorkerVersion() override; | 264 ~ServiceWorkerVersion() override; |
262 | 265 |
263 // EmbeddedWorkerInstance::Listener overrides: | 266 // EmbeddedWorkerInstance::Listener overrides: |
264 void OnStarted() override; | 267 void OnStarted() override; |
265 void OnStopped(EmbeddedWorkerInstance::Status old_status) override; | 268 void OnStopped(EmbeddedWorkerInstance::Status old_status) override; |
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
299 void OnPushEventFinished(int request_id, | 302 void OnPushEventFinished(int request_id, |
300 blink::WebServiceWorkerEventResult result); | 303 blink::WebServiceWorkerEventResult result); |
301 void OnGeofencingEventFinished(int request_id); | 304 void OnGeofencingEventFinished(int request_id); |
302 void OnPostMessageToDocument(int client_id, | 305 void OnPostMessageToDocument(int client_id, |
303 const base::string16& message, | 306 const base::string16& message, |
304 const std::vector<int>& sent_message_port_ids); | 307 const std::vector<int>& sent_message_port_ids); |
305 void OnFocusClient(int request_id, int client_id); | 308 void OnFocusClient(int request_id, int client_id); |
306 | 309 |
307 void OnFocusClientFinished(int request_id, bool result); | 310 void OnFocusClientFinished(int request_id, bool result); |
308 void ScheduleStopWorker(); | 311 void ScheduleStopWorker(); |
| 312 void StopWorkerIfIdle(); |
| 313 bool HasInflightRequests() const; |
| 314 |
309 void DoomInternal(); | 315 void DoomInternal(); |
310 | 316 |
311 const int64 version_id_; | 317 const int64 version_id_; |
312 int64 registration_id_; | 318 int64 registration_id_; |
313 GURL script_url_; | 319 GURL script_url_; |
314 GURL scope_; | 320 GURL scope_; |
315 Status status_; | 321 Status status_; |
316 scoped_ptr<EmbeddedWorkerInstance> embedded_worker_; | 322 scoped_ptr<EmbeddedWorkerInstance> embedded_worker_; |
317 scoped_ptr<ServiceWorkerCacheListener> cache_listener_; | 323 scoped_ptr<ServiceWorkerCacheListener> cache_listener_; |
318 std::vector<StatusCallback> start_callbacks_; | 324 std::vector<StatusCallback> start_callbacks_; |
319 std::vector<StatusCallback> stop_callbacks_; | 325 std::vector<StatusCallback> stop_callbacks_; |
320 std::vector<base::Closure> status_change_callbacks_; | 326 std::vector<base::Closure> status_change_callbacks_; |
321 | 327 |
322 // Message callbacks. | 328 // Message callbacks. (Update HasInflightRequests() too when you update this |
| 329 // list.) |
323 IDMap<StatusCallback, IDMapOwnPointer> activate_callbacks_; | 330 IDMap<StatusCallback, IDMapOwnPointer> activate_callbacks_; |
324 IDMap<StatusCallback, IDMapOwnPointer> install_callbacks_; | 331 IDMap<StatusCallback, IDMapOwnPointer> install_callbacks_; |
325 IDMap<FetchCallback, IDMapOwnPointer> fetch_callbacks_; | 332 IDMap<FetchCallback, IDMapOwnPointer> fetch_callbacks_; |
326 IDMap<StatusCallback, IDMapOwnPointer> sync_callbacks_; | 333 IDMap<StatusCallback, IDMapOwnPointer> sync_callbacks_; |
327 IDMap<StatusCallback, IDMapOwnPointer> notification_click_callbacks_; | 334 IDMap<StatusCallback, IDMapOwnPointer> notification_click_callbacks_; |
328 IDMap<StatusCallback, IDMapOwnPointer> push_callbacks_; | 335 IDMap<StatusCallback, IDMapOwnPointer> push_callbacks_; |
329 IDMap<StatusCallback, IDMapOwnPointer> geofencing_callbacks_; | 336 IDMap<StatusCallback, IDMapOwnPointer> geofencing_callbacks_; |
330 | 337 |
331 ControlleeMap controllee_map_; | 338 ControlleeMap controllee_map_; |
332 ControlleeByIDMap controllee_by_id_; | 339 ControlleeByIDMap controllee_by_id_; |
333 base::WeakPtr<ServiceWorkerContextCore> context_; | 340 base::WeakPtr<ServiceWorkerContextCore> context_; |
334 ObserverList<Listener> listeners_; | 341 ObserverList<Listener> listeners_; |
335 ServiceWorkerScriptCacheMap script_cache_map_; | 342 ServiceWorkerScriptCacheMap script_cache_map_; |
336 base::OneShotTimer<ServiceWorkerVersion> stop_worker_timer_; | 343 base::OneShotTimer<ServiceWorkerVersion> stop_worker_timer_; |
337 base::OneShotTimer<ServiceWorkerVersion> update_timer_; | 344 base::OneShotTimer<ServiceWorkerVersion> update_timer_; |
338 bool is_doomed_; | 345 bool is_doomed_; |
339 | 346 |
340 base::WeakPtrFactory<ServiceWorkerVersion> weak_factory_; | 347 base::WeakPtrFactory<ServiceWorkerVersion> weak_factory_; |
341 | 348 |
342 DISALLOW_COPY_AND_ASSIGN(ServiceWorkerVersion); | 349 DISALLOW_COPY_AND_ASSIGN(ServiceWorkerVersion); |
343 }; | 350 }; |
344 | 351 |
345 } // namespace content | 352 } // namespace content |
346 | 353 |
347 #endif // CONTENT_BROWSER_SERVICE_WORKER_SERVICE_WORKER_VERSION_H_ | 354 #endif // CONTENT_BROWSER_SERVICE_WORKER_SERVICE_WORKER_VERSION_H_ |
OLD | NEW |