| 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 419 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 822 void ServiceWorkerVersion::SetMainScriptHttpResponseInfo( | 822 void ServiceWorkerVersion::SetMainScriptHttpResponseInfo( |
| 823 const net::HttpResponseInfo& http_info) { | 823 const net::HttpResponseInfo& http_info) { |
| 824 main_script_http_info_.reset(new net::HttpResponseInfo(http_info)); | 824 main_script_http_info_.reset(new net::HttpResponseInfo(http_info)); |
| 825 } | 825 } |
| 826 | 826 |
| 827 const net::HttpResponseInfo* | 827 const net::HttpResponseInfo* |
| 828 ServiceWorkerVersion::GetMainScriptHttpResponseInfo() { | 828 ServiceWorkerVersion::GetMainScriptHttpResponseInfo() { |
| 829 return main_script_http_info_.get(); | 829 return main_script_http_info_.get(); |
| 830 } | 830 } |
| 831 | 831 |
| 832 void ServiceWorkerVersion::set_update_time(base::Time update_time) { |
| 833 update_time_ = update_time; |
| 834 FOR_EACH_OBSERVER(Listener, listeners_, OnVersionUpdateTimeSet(this)); |
| 835 } |
| 836 |
| 832 ServiceWorkerVersion::RequestInfo::RequestInfo(int id, RequestType type) | 837 ServiceWorkerVersion::RequestInfo::RequestInfo(int id, RequestType type) |
| 833 : id(id), type(type), time(base::TimeTicks::Now()) { | 838 : id(id), type(type), time(base::TimeTicks::Now()) { |
| 834 } | 839 } |
| 835 | 840 |
| 836 ServiceWorkerVersion::RequestInfo::~RequestInfo() { | 841 ServiceWorkerVersion::RequestInfo::~RequestInfo() { |
| 837 } | 842 } |
| 838 | 843 |
| 839 void ServiceWorkerVersion::OnScriptLoaded() { | 844 void ServiceWorkerVersion::OnScriptLoaded() { |
| 840 DCHECK_EQ(STARTING, running_status()); | 845 DCHECK_EQ(STARTING, running_status()); |
| 841 // Activate ping/pong now that JavaScript execution will start. | 846 // Activate ping/pong now that JavaScript execution will start. |
| (...skipping 908 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1750 while (!requests_.empty()) { | 1755 while (!requests_.empty()) { |
| 1751 RequestInfo info = requests_.front(); | 1756 RequestInfo info = requests_.front(); |
| 1752 info.time = ticks; | 1757 info.time = ticks; |
| 1753 new_requests.push(info); | 1758 new_requests.push(info); |
| 1754 requests_.pop(); | 1759 requests_.pop(); |
| 1755 } | 1760 } |
| 1756 requests_ = new_requests; | 1761 requests_ = new_requests; |
| 1757 } | 1762 } |
| 1758 | 1763 |
| 1759 } // namespace content | 1764 } // namespace content |
| OLD | NEW |