| 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 #include "content/browser/service_worker/service_worker_version.h" | 5 #include "content/browser/service_worker/service_worker_version.h" |
| 6 | 6 |
| 7 #include "base/command_line.h" | 7 #include "base/command_line.h" |
| 8 #include "base/memory/ref_counted.h" | 8 #include "base/memory/ref_counted.h" |
| 9 #include "base/metrics/histogram_macros.h" | 9 #include "base/metrics/histogram_macros.h" |
| 10 #include "base/stl_util.h" | 10 #include "base/stl_util.h" |
| (...skipping 371 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 382 void ServiceWorkerVersion::RegisterStatusChangeCallback( | 382 void ServiceWorkerVersion::RegisterStatusChangeCallback( |
| 383 const base::Closure& callback) { | 383 const base::Closure& callback) { |
| 384 status_change_callbacks_.push_back(callback); | 384 status_change_callbacks_.push_back(callback); |
| 385 } | 385 } |
| 386 | 386 |
| 387 ServiceWorkerVersionInfo ServiceWorkerVersion::GetInfo() { | 387 ServiceWorkerVersionInfo ServiceWorkerVersion::GetInfo() { |
| 388 DCHECK_CURRENTLY_ON(BrowserThread::IO); | 388 DCHECK_CURRENTLY_ON(BrowserThread::IO); |
| 389 return ServiceWorkerVersionInfo( | 389 return ServiceWorkerVersionInfo( |
| 390 running_status(), status(), script_url(), registration_id(), version_id(), | 390 running_status(), status(), script_url(), registration_id(), version_id(), |
| 391 embedded_worker()->process_id(), embedded_worker()->thread_id(), | 391 embedded_worker()->process_id(), embedded_worker()->thread_id(), |
| 392 embedded_worker()->worker_devtools_agent_route_id()); | 392 embedded_worker()->worker_devtools_agent_route_id(), update_time_); |
| 393 } | 393 } |
| 394 | 394 |
| 395 void ServiceWorkerVersion::StartWorker(const StatusCallback& callback) { | 395 void ServiceWorkerVersion::StartWorker(const StatusCallback& callback) { |
| 396 StartWorker(false, callback); | 396 StartWorker(false, callback); |
| 397 } | 397 } |
| 398 | 398 |
| 399 void ServiceWorkerVersion::StartWorker( | 399 void ServiceWorkerVersion::StartWorker( |
| 400 bool pause_after_download, | 400 bool pause_after_download, |
| 401 const StatusCallback& callback) { | 401 const StatusCallback& callback) { |
| 402 if (!context_) { | 402 if (!context_) { |
| (...skipping 429 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 832 void ServiceWorkerVersion::SetMainScriptHttpResponseInfo( | 832 void ServiceWorkerVersion::SetMainScriptHttpResponseInfo( |
| 833 const net::HttpResponseInfo& http_info) { | 833 const net::HttpResponseInfo& http_info) { |
| 834 main_script_http_info_.reset(new net::HttpResponseInfo(http_info)); | 834 main_script_http_info_.reset(new net::HttpResponseInfo(http_info)); |
| 835 } | 835 } |
| 836 | 836 |
| 837 const net::HttpResponseInfo* | 837 const net::HttpResponseInfo* |
| 838 ServiceWorkerVersion::GetMainScriptHttpResponseInfo() { | 838 ServiceWorkerVersion::GetMainScriptHttpResponseInfo() { |
| 839 return main_script_http_info_.get(); | 839 return main_script_http_info_.get(); |
| 840 } | 840 } |
| 841 | 841 |
| 842 void ServiceWorkerVersion::set_update_time(base::Time update_time) { |
| 843 update_time_ = update_time; |
| 844 FOR_EACH_OBSERVER(Listener, listeners_, OnVersionUpdateTimeSet(this)); |
| 845 } |
| 846 |
| 842 ServiceWorkerVersion::RequestInfo::RequestInfo(int id, RequestType type) | 847 ServiceWorkerVersion::RequestInfo::RequestInfo(int id, RequestType type) |
| 843 : id(id), type(type), time(base::TimeTicks::Now()) { | 848 : id(id), type(type), time(base::TimeTicks::Now()) { |
| 844 } | 849 } |
| 845 | 850 |
| 846 ServiceWorkerVersion::RequestInfo::~RequestInfo() { | 851 ServiceWorkerVersion::RequestInfo::~RequestInfo() { |
| 847 } | 852 } |
| 848 | 853 |
| 849 void ServiceWorkerVersion::OnScriptLoaded() { | 854 void ServiceWorkerVersion::OnScriptLoaded() { |
| 850 DCHECK_EQ(STARTING, running_status()); | 855 DCHECK_EQ(STARTING, running_status()); |
| 851 // Activate ping/pong now that JavaScript execution will start. | 856 // Activate ping/pong now that JavaScript execution will start. |
| (...skipping 909 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1761 while (!requests_.empty()) { | 1766 while (!requests_.empty()) { |
| 1762 RequestInfo info = requests_.front(); | 1767 RequestInfo info = requests_.front(); |
| 1763 info.time = ticks; | 1768 info.time = ticks; |
| 1764 new_requests.push(info); | 1769 new_requests.push(info); |
| 1765 requests_.pop(); | 1770 requests_.pop(); |
| 1766 } | 1771 } |
| 1767 requests_ = new_requests; | 1772 requests_ = new_requests; |
| 1768 } | 1773 } |
| 1769 | 1774 |
| 1770 } // namespace content | 1775 } // namespace content |
| OLD | NEW |