Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(764)

Side by Side Diff: content/browser/service_worker/service_worker_version.cc

Issue 2250623003: Keep ServiceWorkerMetrics::Site in ServiceWorkerVersion (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: rebase Created 4 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « content/browser/service_worker/service_worker_version.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 288 matching lines...) Expand 10 before | Expand all | Expand 10 after
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 fetch_handler_existence_(FetchHandlerExistence::UNKNOWN), 308 fetch_handler_existence_(FetchHandlerExistence::UNKNOWN),
309 site_for_uma_(ServiceWorkerMetrics::SiteFromURL(scope_)),
309 context_(context), 310 context_(context),
310 script_cache_map_(this, context), 311 script_cache_map_(this, context),
311 ping_controller_(new PingController(this)), 312 ping_controller_(new PingController(this)),
312 should_exclude_from_uma_( 313 should_exclude_from_uma_(
313 ServiceWorkerMetrics::ShouldExcludeURLFromHistogram(scope_)), 314 ServiceWorkerMetrics::ShouldExcludeSiteFromHistogram(site_for_uma_)),
314 weak_factory_(this) { 315 weak_factory_(this) {
315 DCHECK_NE(kInvalidServiceWorkerVersionId, version_id); 316 DCHECK_NE(kInvalidServiceWorkerVersionId, version_id);
316 DCHECK(context_); 317 DCHECK(context_);
317 DCHECK(registration); 318 DCHECK(registration);
318 DCHECK(script_url_.is_valid()); 319 DCHECK(script_url_.is_valid());
319 context_->AddLiveVersion(this); 320 context_->AddLiveVersion(this);
320 embedded_worker_ = context_->embedded_worker_registry()->CreateWorker(); 321 embedded_worker_ = context_->embedded_worker_registry()->CreateWorker();
321 embedded_worker_->AddListener(this); 322 embedded_worker_->AddListener(this);
322 } 323 }
323 324
(...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after
404 } 405 }
405 if (!main_script_http_info_) 406 if (!main_script_http_info_)
406 return info; 407 return info;
407 info.script_response_time = main_script_http_info_->response_time; 408 info.script_response_time = main_script_http_info_->response_time;
408 if (main_script_http_info_->headers) 409 if (main_script_http_info_->headers)
409 main_script_http_info_->headers->GetLastModifiedValue( 410 main_script_http_info_->headers->GetLastModifiedValue(
410 &info.script_last_modified); 411 &info.script_last_modified);
411 return info; 412 return info;
412 } 413 }
413 414
415 void ServiceWorkerVersion::set_fetch_handler_existence(
416 FetchHandlerExistence existence) {
417 DCHECK_EQ(fetch_handler_existence_, FetchHandlerExistence::UNKNOWN);
418 DCHECK_NE(existence, FetchHandlerExistence::UNKNOWN);
419 fetch_handler_existence_ = existence;
420 if (site_for_uma_ != ServiceWorkerMetrics::Site::OTHER)
421 return;
422 if (existence == FetchHandlerExistence::EXISTS)
423 site_for_uma_ = ServiceWorkerMetrics::Site::WITH_FETCH_HANDLER;
424 else
425 site_for_uma_ = ServiceWorkerMetrics::Site::WITHOUT_FETCH_HANDLER;
426 }
427
414 void ServiceWorkerVersion::StartWorker(ServiceWorkerMetrics::EventType purpose, 428 void ServiceWorkerVersion::StartWorker(ServiceWorkerMetrics::EventType purpose,
415 const StatusCallback& callback) { 429 const StatusCallback& callback) {
416 TRACE_EVENT_INSTANT2( 430 TRACE_EVENT_INSTANT2(
417 "ServiceWorker", "ServiceWorkerVersion::StartWorker (instant)", 431 "ServiceWorker", "ServiceWorkerVersion::StartWorker (instant)",
418 TRACE_EVENT_SCOPE_THREAD, "Script", script_url_.spec(), "Purpose", 432 TRACE_EVENT_SCOPE_THREAD, "Script", script_url_.spec(), "Purpose",
419 ServiceWorkerMetrics::EventTypeToString(purpose)); 433 ServiceWorkerMetrics::EventTypeToString(purpose));
420 434
421 DCHECK_CURRENTLY_ON(BrowserThread::IO); 435 DCHECK_CURRENTLY_ON(BrowserThread::IO);
422 const bool is_browser_startup_complete = 436 const bool is_browser_startup_complete =
423 GetContentClient()->browser()->IsBrowserStartupComplete(); 437 GetContentClient()->browser()->IsBrowserStartupComplete();
(...skipping 1340 matching lines...) Expand 10 before | Expand all | Expand 10 after
1764 ServiceWorkerMetrics::RecordTimeBetweenEvents(base::TimeTicks::Now() - 1778 ServiceWorkerMetrics::RecordTimeBetweenEvents(base::TimeTicks::Now() -
1765 idle_time_); 1779 idle_time_);
1766 } 1780 }
1767 1781
1768 void ServiceWorkerVersion::FinishStartWorker(ServiceWorkerStatusCode status) { 1782 void ServiceWorkerVersion::FinishStartWorker(ServiceWorkerStatusCode status) {
1769 start_worker_first_purpose_ = base::nullopt; 1783 start_worker_first_purpose_ = base::nullopt;
1770 RunCallbacks(this, &start_callbacks_, status); 1784 RunCallbacks(this, &start_callbacks_, status);
1771 } 1785 }
1772 1786
1773 } // namespace content 1787 } // namespace content
OLDNEW
« no previous file with comments | « content/browser/service_worker/service_worker_version.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698