| 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 <queue> | 9 #include <queue> |
| 10 #include <set> | 10 #include <set> |
| (...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 88 ACTIVATING, // Activate event is dispatched and being handled. | 88 ACTIVATING, // Activate event is dispatched and being handled. |
| 89 ACTIVATED, // Activation is finished and can run as activated. | 89 ACTIVATED, // Activation is finished and can run as activated. |
| 90 REDUNDANT, // The version is no longer running as activated, due to | 90 REDUNDANT, // The version is no longer running as activated, due to |
| 91 // unregistration or replace. | 91 // unregistration or replace. |
| 92 }; | 92 }; |
| 93 | 93 |
| 94 class Listener { | 94 class Listener { |
| 95 public: | 95 public: |
| 96 virtual void OnRunningStateChanged(ServiceWorkerVersion* version) {} | 96 virtual void OnRunningStateChanged(ServiceWorkerVersion* version) {} |
| 97 virtual void OnVersionStateChanged(ServiceWorkerVersion* version) {} | 97 virtual void OnVersionStateChanged(ServiceWorkerVersion* version) {} |
| 98 virtual void OnVersionUpdateTimeSet(ServiceWorkerVersion* version) {} |
| 98 virtual void OnErrorReported(ServiceWorkerVersion* version, | 99 virtual void OnErrorReported(ServiceWorkerVersion* version, |
| 99 const base::string16& error_message, | 100 const base::string16& error_message, |
| 100 int line_number, | 101 int line_number, |
| 101 int column_number, | 102 int column_number, |
| 102 const GURL& source_url) {} | 103 const GURL& source_url) {} |
| 103 virtual void OnReportConsoleMessage(ServiceWorkerVersion* version, | 104 virtual void OnReportConsoleMessage(ServiceWorkerVersion* version, |
| 104 int source_identifier, | 105 int source_identifier, |
| 105 int message_level, | 106 int message_level, |
| 106 const base::string16& message, | 107 const base::string16& message, |
| 107 int line_number, | 108 int line_number, |
| (...skipping 182 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 290 | 291 |
| 291 void SetDevToolsAttached(bool attached); | 292 void SetDevToolsAttached(bool attached); |
| 292 | 293 |
| 293 // Sets the HttpResponseInfo used to load the main script. | 294 // Sets the HttpResponseInfo used to load the main script. |
| 294 // This HttpResponseInfo will be used for all responses sent back from the | 295 // This HttpResponseInfo will be used for all responses sent back from the |
| 295 // service worker, as the effective security of these responses is equivalent | 296 // service worker, as the effective security of these responses is equivalent |
| 296 // to that of the ServiceWorker. | 297 // to that of the ServiceWorker. |
| 297 void SetMainScriptHttpResponseInfo(const net::HttpResponseInfo& http_info); | 298 void SetMainScriptHttpResponseInfo(const net::HttpResponseInfo& http_info); |
| 298 const net::HttpResponseInfo* GetMainScriptHttpResponseInfo(); | 299 const net::HttpResponseInfo* GetMainScriptHttpResponseInfo(); |
| 299 | 300 |
| 301 base::Time update_time() const { return update_time_; } |
| 302 void set_update_time(base::Time update_time); |
| 303 |
| 300 private: | 304 private: |
| 301 friend class base::RefCounted<ServiceWorkerVersion>; | 305 friend class base::RefCounted<ServiceWorkerVersion>; |
| 302 friend class ServiceWorkerURLRequestJobTest; | 306 friend class ServiceWorkerURLRequestJobTest; |
| 303 FRIEND_TEST_ALL_PREFIXES(ServiceWorkerControlleeRequestHandlerTest, | 307 FRIEND_TEST_ALL_PREFIXES(ServiceWorkerControlleeRequestHandlerTest, |
| 304 ActivateWaitingVersion); | 308 ActivateWaitingVersion); |
| 305 FRIEND_TEST_ALL_PREFIXES(ServiceWorkerVersionTest, ScheduleStopWorker); | 309 FRIEND_TEST_ALL_PREFIXES(ServiceWorkerVersionTest, ScheduleStopWorker); |
| 306 FRIEND_TEST_ALL_PREFIXES(ServiceWorkerVersionTest, KeepAlive); | 310 FRIEND_TEST_ALL_PREFIXES(ServiceWorkerVersionTest, KeepAlive); |
| 307 FRIEND_TEST_ALL_PREFIXES(ServiceWorkerVersionTest, ListenerAvailability); | 311 FRIEND_TEST_ALL_PREFIXES(ServiceWorkerVersionTest, ListenerAvailability); |
| 308 FRIEND_TEST_ALL_PREFIXES(ServiceWorkerVersionTest, SetDevToolsAttached); | 312 FRIEND_TEST_ALL_PREFIXES(ServiceWorkerVersionTest, SetDevToolsAttached); |
| 309 FRIEND_TEST_ALL_PREFIXES(ServiceWorkerWaitForeverInFetchTest, RequestTimeout); | 313 FRIEND_TEST_ALL_PREFIXES(ServiceWorkerWaitForeverInFetchTest, RequestTimeout); |
| (...skipping 147 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 457 RequestType request_type); | 461 RequestType request_type); |
| 458 | 462 |
| 459 bool OnRequestTimeout(const RequestInfo& info); | 463 bool OnRequestTimeout(const RequestInfo& info); |
| 460 void SetAllRequestTimes(const base::TimeTicks& ticks); | 464 void SetAllRequestTimes(const base::TimeTicks& ticks); |
| 461 | 465 |
| 462 const int64 version_id_; | 466 const int64 version_id_; |
| 463 int64 registration_id_; | 467 int64 registration_id_; |
| 464 GURL script_url_; | 468 GURL script_url_; |
| 465 GURL scope_; | 469 GURL scope_; |
| 466 Status status_; | 470 Status status_; |
| 471 base::Time update_time_; |
| 467 scoped_ptr<EmbeddedWorkerInstance> embedded_worker_; | 472 scoped_ptr<EmbeddedWorkerInstance> embedded_worker_; |
| 468 std::vector<StatusCallback> start_callbacks_; | 473 std::vector<StatusCallback> start_callbacks_; |
| 469 std::vector<StatusCallback> stop_callbacks_; | 474 std::vector<StatusCallback> stop_callbacks_; |
| 470 std::vector<base::Closure> status_change_callbacks_; | 475 std::vector<base::Closure> status_change_callbacks_; |
| 471 | 476 |
| 472 // Message callbacks. (Update HasInflightRequests() too when you update this | 477 // Message callbacks. (Update HasInflightRequests() too when you update this |
| 473 // list.) | 478 // list.) |
| 474 IDMap<StatusCallback, IDMapOwnPointer> activate_callbacks_; | 479 IDMap<StatusCallback, IDMapOwnPointer> activate_callbacks_; |
| 475 IDMap<StatusCallback, IDMapOwnPointer> install_callbacks_; | 480 IDMap<StatusCallback, IDMapOwnPointer> install_callbacks_; |
| 476 IDMap<FetchCallback, IDMapOwnPointer> fetch_callbacks_; | 481 IDMap<FetchCallback, IDMapOwnPointer> fetch_callbacks_; |
| (...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 515 scoped_ptr<net::HttpResponseInfo> main_script_http_info_; | 520 scoped_ptr<net::HttpResponseInfo> main_script_http_info_; |
| 516 | 521 |
| 517 base::WeakPtrFactory<ServiceWorkerVersion> weak_factory_; | 522 base::WeakPtrFactory<ServiceWorkerVersion> weak_factory_; |
| 518 | 523 |
| 519 DISALLOW_COPY_AND_ASSIGN(ServiceWorkerVersion); | 524 DISALLOW_COPY_AND_ASSIGN(ServiceWorkerVersion); |
| 520 }; | 525 }; |
| 521 | 526 |
| 522 } // namespace content | 527 } // namespace content |
| 523 | 528 |
| 524 #endif // CONTENT_BROWSER_SERVICE_WORKER_SERVICE_WORKER_VERSION_H_ | 529 #endif // CONTENT_BROWSER_SERVICE_WORKER_SERVICE_WORKER_VERSION_H_ |
| OLD | NEW |