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 <set> | 9 #include <set> |
10 #include <string> | 10 #include <string> |
(...skipping 293 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
304 private: | 304 private: |
305 class GetClientDocumentsCallback; | 305 class GetClientDocumentsCallback; |
306 | 306 |
307 friend class base::RefCounted<ServiceWorkerVersion>; | 307 friend class base::RefCounted<ServiceWorkerVersion>; |
308 friend class ServiceWorkerURLRequestJobTest; | 308 friend class ServiceWorkerURLRequestJobTest; |
309 FRIEND_TEST_ALL_PREFIXES(ServiceWorkerControlleeRequestHandlerTest, | 309 FRIEND_TEST_ALL_PREFIXES(ServiceWorkerControlleeRequestHandlerTest, |
310 ActivateWaitingVersion); | 310 ActivateWaitingVersion); |
311 FRIEND_TEST_ALL_PREFIXES(ServiceWorkerVersionTest, ScheduleStopWorker); | 311 FRIEND_TEST_ALL_PREFIXES(ServiceWorkerVersionTest, ScheduleStopWorker); |
312 FRIEND_TEST_ALL_PREFIXES(ServiceWorkerVersionTest, KeepAlive); | 312 FRIEND_TEST_ALL_PREFIXES(ServiceWorkerVersionTest, KeepAlive); |
313 FRIEND_TEST_ALL_PREFIXES(ServiceWorkerVersionTest, ListenerAvailability); | 313 FRIEND_TEST_ALL_PREFIXES(ServiceWorkerVersionTest, ListenerAvailability); |
| 314 FRIEND_TEST_ALL_PREFIXES(ServiceWorkerStartTimeoutTest, |
| 315 ScriptEvaluationTimeout); |
| 316 FRIEND_TEST_ALL_PREFIXES(ServiceWorkerEventTimeoutTest, EventTimeout); |
| 317 |
314 typedef ServiceWorkerVersion self; | 318 typedef ServiceWorkerVersion self; |
315 typedef std::map<ServiceWorkerProviderHost*, int> ControlleeMap; | 319 typedef std::map<ServiceWorkerProviderHost*, int> ControlleeMap; |
316 typedef IDMap<ServiceWorkerProviderHost> ControlleeByIDMap; | 320 typedef IDMap<ServiceWorkerProviderHost> ControlleeByIDMap; |
317 | 321 |
318 ~ServiceWorkerVersion() override; | 322 ~ServiceWorkerVersion() override; |
319 | 323 |
320 // EmbeddedWorkerInstance::Listener overrides: | 324 // EmbeddedWorkerInstance::Listener overrides: |
| 325 void OnScriptLoaded() override; |
321 void OnStarted() override; | 326 void OnStarted() override; |
322 void OnStopped(EmbeddedWorkerInstance::Status old_status) override; | 327 void OnStopped(EmbeddedWorkerInstance::Status old_status) override; |
323 void OnReportException(const base::string16& error_message, | 328 void OnReportException(const base::string16& error_message, |
324 int line_number, | 329 int line_number, |
325 int column_number, | 330 int column_number, |
326 const GURL& source_url) override; | 331 const GURL& source_url) override; |
327 void OnReportConsoleMessage(int source_identifier, | 332 void OnReportConsoleMessage(int source_identifier, |
328 int message_level, | 333 int message_level, |
329 const base::string16& message, | 334 const base::string16& message, |
330 int line_number, | 335 int line_number, |
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
365 void OnOpenWindowFinished(int request_id, | 370 void OnOpenWindowFinished(int request_id, |
366 int client_id, | 371 int client_id, |
367 const ServiceWorkerClientInfo& client_info); | 372 const ServiceWorkerClientInfo& client_info); |
368 | 373 |
369 void OnPostMessageToDocument(int client_id, | 374 void OnPostMessageToDocument(int client_id, |
370 const base::string16& message, | 375 const base::string16& message, |
371 const std::vector<int>& sent_message_port_ids); | 376 const std::vector<int>& sent_message_port_ids); |
372 void OnFocusClient(int request_id, int client_id); | 377 void OnFocusClient(int request_id, int client_id); |
373 void OnSkipWaiting(int request_id); | 378 void OnSkipWaiting(int request_id); |
374 void OnClaimClients(int request_id); | 379 void OnClaimClients(int request_id); |
| 380 void OnPongFromWorker(); |
375 | 381 |
376 void OnFocusClientFinished(int request_id, | 382 void OnFocusClientFinished(int request_id, |
377 int client_id, | 383 int client_id, |
378 const ServiceWorkerClientInfo& client); | 384 const ServiceWorkerClientInfo& client); |
379 | 385 |
380 void DidSkipWaiting(int request_id); | 386 void DidSkipWaiting(int request_id); |
381 void DidClaimClients(int request_id, ServiceWorkerStatusCode status); | 387 void DidClaimClients(int request_id, ServiceWorkerStatusCode status); |
382 void DidGetClientInfo(int client_id, | 388 void DidGetClientInfo(int client_id, |
383 scoped_refptr<GetClientDocumentsCallback> callback, | 389 scoped_refptr<GetClientDocumentsCallback> callback, |
384 const ServiceWorkerClientInfo& info); | 390 const ServiceWorkerClientInfo& info); |
385 | 391 |
| 392 void PingWorker(); |
| 393 void SchedulePingWorker(); |
| 394 void OnPingTimeout(); |
| 395 |
386 void ScheduleStopWorker(); | 396 void ScheduleStopWorker(); |
387 void StopWorkerIfIdle(); | 397 void StopWorkerIfIdle(); |
388 bool HasInflightRequests() const; | 398 bool HasInflightRequests() const; |
389 | 399 |
390 void DoomInternal(); | 400 void DoomInternal(); |
391 | 401 |
392 template <typename IDMAP> | 402 template <typename IDMAP> |
393 void RemoveCallbackAndStopIfDoomed(IDMAP* callbacks, int request_id); | 403 void RemoveCallbackAndStopIfDoomed(IDMAP* callbacks, int request_id); |
394 | 404 |
395 const int64 version_id_; | 405 const int64 version_id_; |
(...skipping 22 matching lines...) Expand all Loading... |
418 std::set<const ServiceWorkerURLRequestJob*> streaming_url_request_jobs_; | 428 std::set<const ServiceWorkerURLRequestJob*> streaming_url_request_jobs_; |
419 | 429 |
420 ControlleeMap controllee_map_; | 430 ControlleeMap controllee_map_; |
421 ControlleeByIDMap controllee_by_id_; | 431 ControlleeByIDMap controllee_by_id_; |
422 // Will be null while shutting down. | 432 // Will be null while shutting down. |
423 base::WeakPtr<ServiceWorkerContextCore> context_; | 433 base::WeakPtr<ServiceWorkerContextCore> context_; |
424 ObserverList<Listener> listeners_; | 434 ObserverList<Listener> listeners_; |
425 ServiceWorkerScriptCacheMap script_cache_map_; | 435 ServiceWorkerScriptCacheMap script_cache_map_; |
426 base::OneShotTimer<ServiceWorkerVersion> stop_worker_timer_; | 436 base::OneShotTimer<ServiceWorkerVersion> stop_worker_timer_; |
427 base::OneShotTimer<ServiceWorkerVersion> update_timer_; | 437 base::OneShotTimer<ServiceWorkerVersion> update_timer_; |
| 438 base::OneShotTimer<ServiceWorkerVersion> ping_worker_timer_; |
| 439 bool ping_timed_out_; |
428 bool is_doomed_; | 440 bool is_doomed_; |
429 std::vector<int> pending_skip_waiting_requests_; | 441 std::vector<int> pending_skip_waiting_requests_; |
430 bool skip_waiting_; | 442 bool skip_waiting_; |
431 scoped_ptr<net::HttpResponseInfo> main_script_http_info_; | 443 scoped_ptr<net::HttpResponseInfo> main_script_http_info_; |
432 | 444 |
433 base::WeakPtrFactory<ServiceWorkerVersion> weak_factory_; | 445 base::WeakPtrFactory<ServiceWorkerVersion> weak_factory_; |
434 | 446 |
435 DISALLOW_COPY_AND_ASSIGN(ServiceWorkerVersion); | 447 DISALLOW_COPY_AND_ASSIGN(ServiceWorkerVersion); |
436 }; | 448 }; |
437 | 449 |
438 } // namespace content | 450 } // namespace content |
439 | 451 |
440 #endif // CONTENT_BROWSER_SERVICE_WORKER_SERVICE_WORKER_VERSION_H_ | 452 #endif // CONTENT_BROWSER_SERVICE_WORKER_SERVICE_WORKER_VERSION_H_ |
OLD | NEW |