Chromium Code Reviews| 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 <stddef.h> | 7 #include <stddef.h> |
| 8 | 8 |
| 9 #include <limits> | 9 #include <limits> |
| 10 #include <map> | 10 #include <map> |
| (...skipping 287 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 298 | 298 |
| 299 ServiceWorkerVersion::ServiceWorkerVersion( | 299 ServiceWorkerVersion::ServiceWorkerVersion( |
| 300 ServiceWorkerRegistration* registration, | 300 ServiceWorkerRegistration* registration, |
| 301 const GURL& script_url, | 301 const GURL& script_url, |
| 302 int64_t version_id, | 302 int64_t version_id, |
| 303 base::WeakPtr<ServiceWorkerContextCore> context) | 303 base::WeakPtr<ServiceWorkerContextCore> context) |
| 304 : version_id_(version_id), | 304 : version_id_(version_id), |
| 305 registration_id_(registration->id()), | 305 registration_id_(registration->id()), |
| 306 script_url_(script_url), | 306 script_url_(script_url), |
| 307 scope_(registration->pattern()), | 307 scope_(registration->pattern()), |
| 308 site_for_uma_(ServiceWorkerMetrics::SiteFromURL(scope_, base::nullopt)), | |
| 308 context_(context), | 309 context_(context), |
| 309 script_cache_map_(this, context), | 310 script_cache_map_(this, context), |
| 310 ping_controller_(new PingController(this)), | 311 ping_controller_(new PingController(this)), |
| 311 should_exclude_from_uma_( | 312 should_exclude_from_uma_( |
| 312 ServiceWorkerMetrics::ShouldExcludeURLFromHistogram(scope_)), | 313 ServiceWorkerMetrics::ShouldExcludeSiteFromHistogram(site_for_uma_)), |
| 313 weak_factory_(this) { | 314 weak_factory_(this) { |
| 314 DCHECK_NE(kInvalidServiceWorkerVersionId, version_id); | 315 DCHECK_NE(kInvalidServiceWorkerVersionId, version_id); |
| 315 DCHECK(context_); | 316 DCHECK(context_); |
| 316 DCHECK(registration); | 317 DCHECK(registration); |
| 317 DCHECK(script_url_.is_valid()); | 318 DCHECK(script_url_.is_valid()); |
| 318 context_->AddLiveVersion(this); | 319 context_->AddLiveVersion(this); |
| 319 embedded_worker_ = context_->embedded_worker_registry()->CreateWorker(); | 320 embedded_worker_ = context_->embedded_worker_registry()->CreateWorker(); |
| 320 embedded_worker_->AddListener(this); | 321 embedded_worker_->AddListener(this); |
| 321 } | 322 } |
| 322 | 323 |
| (...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 402 } | 403 } |
| 403 if (!main_script_http_info_) | 404 if (!main_script_http_info_) |
| 404 return info; | 405 return info; |
| 405 info.script_response_time = main_script_http_info_->response_time; | 406 info.script_response_time = main_script_http_info_->response_time; |
| 406 if (main_script_http_info_->headers) | 407 if (main_script_http_info_->headers) |
| 407 main_script_http_info_->headers->GetLastModifiedValue( | 408 main_script_http_info_->headers->GetLastModifiedValue( |
| 408 &info.script_last_modified); | 409 &info.script_last_modified); |
| 409 return info; | 410 return info; |
| 410 } | 411 } |
| 411 | 412 |
| 413 void ServiceWorkerVersion::set_has_fetch_handler(bool has_fetch_handler) { | |
| 414 DCHECK(!has_fetch_handler_); | |
| 415 has_fetch_handler_ = has_fetch_handler; | |
| 416 if (site_for_uma_ != ServiceWorkerMetrics::Site::OTHER) | |
|
shimazu
2016/08/18 06:53:24
How about using SiteFromURL for keeping consistenc
horo
2016/08/21 08:39:58
I removed FetchHandlerExistence from the arguments
shimazu
2016/08/22 02:48:02
Sure.
| |
| 417 return; | |
| 418 if (has_fetch_handler) | |
| 419 site_for_uma_ = ServiceWorkerMetrics::Site::WITH_FETCH_HANDLER; | |
| 420 else | |
| 421 site_for_uma_ = ServiceWorkerMetrics::Site::WITHOUT_FETCH_HANDLER; | |
| 422 } | |
| 423 | |
| 412 void ServiceWorkerVersion::StartWorker(ServiceWorkerMetrics::EventType purpose, | 424 void ServiceWorkerVersion::StartWorker(ServiceWorkerMetrics::EventType purpose, |
| 413 const StatusCallback& callback) { | 425 const StatusCallback& callback) { |
| 414 TRACE_EVENT_INSTANT2( | 426 TRACE_EVENT_INSTANT2( |
| 415 "ServiceWorker", "ServiceWorkerVersion::StartWorker (instant)", | 427 "ServiceWorker", "ServiceWorkerVersion::StartWorker (instant)", |
| 416 TRACE_EVENT_SCOPE_THREAD, "Script", script_url_.spec(), "Purpose", | 428 TRACE_EVENT_SCOPE_THREAD, "Script", script_url_.spec(), "Purpose", |
| 417 ServiceWorkerMetrics::EventTypeToString(purpose)); | 429 ServiceWorkerMetrics::EventTypeToString(purpose)); |
| 418 | 430 |
| 419 DCHECK_CURRENTLY_ON(BrowserThread::IO); | 431 DCHECK_CURRENTLY_ON(BrowserThread::IO); |
| 420 const bool is_browser_startup_complete = | 432 const bool is_browser_startup_complete = |
| 421 GetContentClient()->browser()->IsBrowserStartupComplete(); | 433 GetContentClient()->browser()->IsBrowserStartupComplete(); |
| (...skipping 1340 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1762 ServiceWorkerMetrics::RecordTimeBetweenEvents(base::TimeTicks::Now() - | 1774 ServiceWorkerMetrics::RecordTimeBetweenEvents(base::TimeTicks::Now() - |
| 1763 idle_time_); | 1775 idle_time_); |
| 1764 } | 1776 } |
| 1765 | 1777 |
| 1766 void ServiceWorkerVersion::FinishStartWorker(ServiceWorkerStatusCode status) { | 1778 void ServiceWorkerVersion::FinishStartWorker(ServiceWorkerStatusCode status) { |
| 1767 start_worker_first_purpose_ = base::nullopt; | 1779 start_worker_first_purpose_ = base::nullopt; |
| 1768 RunCallbacks(this, &start_callbacks_, status); | 1780 RunCallbacks(this, &start_callbacks_, status); |
| 1769 } | 1781 } |
| 1770 | 1782 |
| 1771 } // namespace content | 1783 } // namespace content |
| OLD | NEW |