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

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

Issue 1795863006: service worker: Attribute purpose to start worker attempts for UMA (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: review comments Created 4 years, 9 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
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 <map> 9 #include <map>
10 #include <string> 10 #include <string>
(...skipping 285 matching lines...) Expand 10 before | Expand all | Expand 10 after
296 296
297 ServiceWorkerVersion::~ServiceWorkerVersion() { 297 ServiceWorkerVersion::~ServiceWorkerVersion() {
298 in_dtor_ = true; 298 in_dtor_ = true;
299 299
300 // The user may have closed the tab waiting for SW to start up. 300 // The user may have closed the tab waiting for SW to start up.
301 if (GetTickDuration(start_time_) > 301 if (GetTickDuration(start_time_) >
302 base::TimeDelta::FromSeconds( 302 base::TimeDelta::FromSeconds(
303 kDestructedStartingWorkerTimeoutThresholdSeconds)) { 303 kDestructedStartingWorkerTimeoutThresholdSeconds)) {
304 DCHECK(timeout_timer_.IsRunning()); 304 DCHECK(timeout_timer_.IsRunning());
305 DCHECK(!embedded_worker_->devtools_attached()); 305 DCHECK(!embedded_worker_->devtools_attached());
306 RecordStartWorkerResult(SERVICE_WORKER_ERROR_TIMEOUT); 306
307 // RecordStartWorkerResult must be in start_callbacks_.
308 DCHECK(!start_callbacks_.empty());
309 RecordStartWorkerResult(ServiceWorkerMetrics::EventType::UNKNOWN,
310 SERVICE_WORKER_ERROR_TIMEOUT);
307 } 311 }
308 312
309 if (context_) 313 if (context_)
310 context_->RemoveLiveVersion(version_id_); 314 context_->RemoveLiveVersion(version_id_);
311 315
312 if (running_status() == STARTING || running_status() == RUNNING) 316 if (running_status() == STARTING || running_status() == RUNNING)
313 embedded_worker_->Stop(); 317 embedded_worker_->Stop();
314 embedded_worker_->RemoveListener(this); 318 embedded_worker_->RemoveListener(this);
315 } 319 }
316 320
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after
354 } 358 }
355 if (!main_script_http_info_) 359 if (!main_script_http_info_)
356 return info; 360 return info;
357 info.script_response_time = main_script_http_info_->response_time; 361 info.script_response_time = main_script_http_info_->response_time;
358 if (main_script_http_info_->headers) 362 if (main_script_http_info_->headers)
359 main_script_http_info_->headers->GetLastModifiedValue( 363 main_script_http_info_->headers->GetLastModifiedValue(
360 &info.script_last_modified); 364 &info.script_last_modified);
361 return info; 365 return info;
362 } 366 }
363 367
364 void ServiceWorkerVersion::StartWorker(const StatusCallback& callback) { 368 void ServiceWorkerVersion::StartWorker(ServiceWorkerMetrics::EventType purpose,
369 const StatusCallback& callback) {
365 DCHECK_CURRENTLY_ON(BrowserThread::IO); 370 DCHECK_CURRENTLY_ON(BrowserThread::IO);
366 if (!context_) { 371 if (!context_) {
367 RecordStartWorkerResult(SERVICE_WORKER_ERROR_ABORT); 372 RecordStartWorkerResult(purpose, SERVICE_WORKER_ERROR_ABORT);
368 RunSoon(base::Bind(callback, SERVICE_WORKER_ERROR_ABORT)); 373 RunSoon(base::Bind(callback, SERVICE_WORKER_ERROR_ABORT));
369 return; 374 return;
370 } 375 }
371 if (is_redundant()) { 376 if (is_redundant()) {
372 RecordStartWorkerResult(SERVICE_WORKER_ERROR_REDUNDANT); 377 RecordStartWorkerResult(purpose, SERVICE_WORKER_ERROR_REDUNDANT);
373 RunSoon(base::Bind(callback, SERVICE_WORKER_ERROR_REDUNDANT)); 378 RunSoon(base::Bind(callback, SERVICE_WORKER_ERROR_REDUNDANT));
374 return; 379 return;
375 } 380 }
376 if (IsDisabled()) { 381 if (IsDisabled()) {
377 RecordStartWorkerResult(SERVICE_WORKER_ERROR_DISABLED_WORKER); 382 RecordStartWorkerResult(purpose, SERVICE_WORKER_ERROR_DISABLED_WORKER);
378 RunSoon(base::Bind(callback, SERVICE_WORKER_ERROR_DISABLED_WORKER)); 383 RunSoon(base::Bind(callback, SERVICE_WORKER_ERROR_DISABLED_WORKER));
379 384
380 // Show a message in DevTools for developers. 385 // Show a message in DevTools for developers.
381 ReportError(SERVICE_WORKER_ERROR_DISABLED_WORKER, 386 ReportError(SERVICE_WORKER_ERROR_DISABLED_WORKER,
382 "The service worker is disabled because its start failure " 387 "The service worker is disabled because its start failure "
383 "count is too high."); 388 "count is too high.");
384 return; 389 return;
385 } 390 }
386 391
387 // Check that the worker is allowed to start on the given scope. Since this 392 // Check that the worker is allowed to start on the given scope. Since this
388 // worker might not be used for a specific frame/process, use -1. 393 // worker might not be used for a specific frame/process, use -1.
389 // resource_context() can return null in unit tests. 394 // resource_context() can return null in unit tests.
390 if (context_->wrapper()->resource_context() && 395 if (context_->wrapper()->resource_context() &&
391 !GetContentClient()->browser()->AllowServiceWorker( 396 !GetContentClient()->browser()->AllowServiceWorker(
392 scope_, scope_, context_->wrapper()->resource_context(), -1, -1)) { 397 scope_, scope_, context_->wrapper()->resource_context(), -1, -1)) {
393 RecordStartWorkerResult(SERVICE_WORKER_ERROR_DISALLOWED); 398 RecordStartWorkerResult(purpose, SERVICE_WORKER_ERROR_DISALLOWED);
394 RunSoon(base::Bind(callback, SERVICE_WORKER_ERROR_DISALLOWED)); 399 RunSoon(base::Bind(callback, SERVICE_WORKER_ERROR_DISALLOWED));
395 return; 400 return;
396 } 401 }
397 402
398 prestart_status_ = status_; 403 prestart_status_ = status_;
399 404
400 // Ensure the live registration during starting worker so that the worker can 405 // Ensure the live registration during starting worker so that the worker can
401 // get associated with it in SWDispatcherHost::OnSetHostedVersionId(). 406 // get associated with it in SWDispatcherHost::OnSetHostedVersionId().
402 context_->storage()->FindRegistrationForId( 407 context_->storage()->FindRegistrationForId(
403 registration_id_, 408 registration_id_, scope_.GetOrigin(),
404 scope_.GetOrigin(),
405 base::Bind(&ServiceWorkerVersion::DidEnsureLiveRegistrationForStartWorker, 409 base::Bind(&ServiceWorkerVersion::DidEnsureLiveRegistrationForStartWorker,
406 weak_factory_.GetWeakPtr(), 410 weak_factory_.GetWeakPtr(), purpose, callback));
407 callback));
408 } 411 }
409 412
410 void ServiceWorkerVersion::StopWorker(const StatusCallback& callback) { 413 void ServiceWorkerVersion::StopWorker(const StatusCallback& callback) {
411 if (running_status() == STOPPED) { 414 if (running_status() == STOPPED) {
412 RunSoon(base::Bind(callback, SERVICE_WORKER_OK)); 415 RunSoon(base::Bind(callback, SERVICE_WORKER_OK));
413 return; 416 return;
414 } 417 }
415 if (stop_callbacks_.empty()) { 418 if (stop_callbacks_.empty()) {
416 ServiceWorkerStatusCode status = embedded_worker_->Stop(); 419 ServiceWorkerStatusCode status = embedded_worker_->Stop();
417 if (status != SERVICE_WORKER_OK) { 420 if (status != SERVICE_WORKER_OK) {
(...skipping 89 matching lines...) Expand 10 before | Expand all | Expand 10 after
507 custom_requests_.Remove(request_id); 510 custom_requests_.Remove(request_id);
508 if (is_redundant()) { 511 if (is_redundant()) {
509 // The stop should be already scheduled, but try to stop immediately, in 512 // The stop should be already scheduled, but try to stop immediately, in
510 // order to release worker resources soon. 513 // order to release worker resources soon.
511 StopWorkerIfIdle(); 514 StopWorkerIfIdle();
512 } 515 }
513 return true; 516 return true;
514 } 517 }
515 518
516 void ServiceWorkerVersion::RunAfterStartWorker( 519 void ServiceWorkerVersion::RunAfterStartWorker(
520 ServiceWorkerMetrics::EventType purpose,
517 const base::Closure& task, 521 const base::Closure& task,
518 const StatusCallback& error_callback) { 522 const StatusCallback& error_callback) {
519 if (running_status() == RUNNING) { 523 if (running_status() == RUNNING) {
520 DCHECK(start_callbacks_.empty()); 524 DCHECK(start_callbacks_.empty());
521 task.Run(); 525 task.Run();
522 return; 526 return;
523 } 527 }
524 StartWorker(base::Bind(&RunTaskAfterStartWorker, weak_factory_.GetWeakPtr(), 528 StartWorker(purpose,
529 base::Bind(&RunTaskAfterStartWorker, weak_factory_.GetWeakPtr(),
525 error_callback, task)); 530 error_callback, task));
526 } 531 }
527 532
528 void ServiceWorkerVersion::DispatchExtendableMessageEvent( 533 void ServiceWorkerVersion::DispatchExtendableMessageEvent(
529 ServiceWorkerProviderHost* sender_provider_host, 534 ServiceWorkerProviderHost* sender_provider_host,
530 const base::string16& message, 535 const base::string16& message,
531 const url::Origin& source_origin, 536 const url::Origin& source_origin,
532 const std::vector<TransferredMessagePort>& sent_message_ports, 537 const std::vector<TransferredMessagePort>& sent_message_ports,
533 const StatusCallback& callback) { 538 const StatusCallback& callback) {
534 for (const TransferredMessagePort& port : sent_message_ports) 539 for (const TransferredMessagePort& port : sent_message_ports)
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after
579 DispatchMessageEventInternal(message, sent_message_ports, callback); 584 DispatchMessageEventInternal(message, sent_message_ports, callback);
580 } 585 }
581 586
582 void ServiceWorkerVersion::DispatchMessageEventInternal( 587 void ServiceWorkerVersion::DispatchMessageEventInternal(
583 const base::string16& message, 588 const base::string16& message,
584 const std::vector<TransferredMessagePort>& sent_message_ports, 589 const std::vector<TransferredMessagePort>& sent_message_ports,
585 const StatusCallback& callback) { 590 const StatusCallback& callback) {
586 OnBeginEvent(); 591 OnBeginEvent();
587 if (running_status() != RUNNING) { 592 if (running_status() != RUNNING) {
588 // Schedule calling this method after starting the worker. 593 // Schedule calling this method after starting the worker.
589 StartWorker(base::Bind( 594 StartWorker(ServiceWorkerMetrics::EventType::MESSAGE,
590 &RunTaskAfterStartWorker, weak_factory_.GetWeakPtr(), 595 base::Bind(&RunTaskAfterStartWorker, weak_factory_.GetWeakPtr(),
591 base::Bind(&RunErrorMessageCallback, sent_message_ports, callback), 596 base::Bind(&RunErrorMessageCallback,
592 base::Bind(&self::DispatchMessageEventInternal, 597 sent_message_ports, callback),
593 weak_factory_.GetWeakPtr(), message, sent_message_ports, 598 base::Bind(&self::DispatchMessageEventInternal,
594 callback))); 599 weak_factory_.GetWeakPtr(), message,
600 sent_message_ports, callback)));
595 return; 601 return;
596 } 602 }
597 603
598 // TODO(kinuko): Cleanup this (and corresponding unit test) when message 604 // TODO(kinuko): Cleanup this (and corresponding unit test) when message
599 // event becomes extendable, round-trip event. (crbug.com/498596) 605 // event becomes extendable, round-trip event. (crbug.com/498596)
600 RestartTick(&idle_time_); 606 RestartTick(&idle_time_);
601 607
602 MessagePortMessageFilter* filter = 608 MessagePortMessageFilter* filter =
603 embedded_worker_->message_port_message_filter(); 609 embedded_worker_->message_port_message_filter();
604 std::vector<int> new_routing_ids; 610 std::vector<int> new_routing_ids;
605 filter->UpdateMessagePortsWithNewRoutes(sent_message_ports, &new_routing_ids); 611 filter->UpdateMessagePortsWithNewRoutes(sent_message_ports, &new_routing_ids);
606 ServiceWorkerStatusCode status = 612 ServiceWorkerStatusCode status =
607 embedded_worker_->SendMessage(ServiceWorkerMsg_MessageToWorker( 613 embedded_worker_->SendMessage(ServiceWorkerMsg_MessageToWorker(
608 message, sent_message_ports, new_routing_ids)); 614 message, sent_message_ports, new_routing_ids));
609 RunSoon(base::Bind(callback, status)); 615 RunSoon(base::Bind(callback, status));
610 } 616 }
611 617
612 void ServiceWorkerVersion::DispatchCrossOriginMessageEvent( 618 void ServiceWorkerVersion::DispatchCrossOriginMessageEvent(
613 const NavigatorConnectClient& client, 619 const NavigatorConnectClient& client,
614 const base::string16& message, 620 const base::string16& message,
615 const std::vector<TransferredMessagePort>& sent_message_ports, 621 const std::vector<TransferredMessagePort>& sent_message_ports,
616 const StatusCallback& callback) { 622 const StatusCallback& callback) {
617 OnBeginEvent(); 623 OnBeginEvent();
618 // Unlike in the case of DispatchMessageEvent, here the caller is assumed to 624 // Unlike in the case of DispatchMessageEvent, here the caller is assumed to
619 // have already put all the sent message ports on hold. So no need to do that 625 // have already put all the sent message ports on hold. So no need to do that
620 // here again. 626 // here again.
621 627
622 if (running_status() != RUNNING) { 628 if (running_status() != RUNNING) {
623 // Schedule calling this method after starting the worker. 629 // Schedule calling this method after starting the worker.
624 StartWorker(base::Bind( 630 StartWorker(ServiceWorkerMetrics::EventType::MESSAGE,
625 &RunTaskAfterStartWorker, weak_factory_.GetWeakPtr(), 631 base::Bind(&RunTaskAfterStartWorker, weak_factory_.GetWeakPtr(),
626 base::Bind(&RunErrorMessageCallback, sent_message_ports, callback), 632 base::Bind(&RunErrorMessageCallback,
627 base::Bind(&self::DispatchCrossOriginMessageEvent, 633 sent_message_ports, callback),
628 weak_factory_.GetWeakPtr(), client, message, 634 base::Bind(&self::DispatchCrossOriginMessageEvent,
629 sent_message_ports, callback))); 635 weak_factory_.GetWeakPtr(), client,
636 message, sent_message_ports, callback)));
630 return; 637 return;
631 } 638 }
632 639
633 MessagePortMessageFilter* filter = 640 MessagePortMessageFilter* filter =
634 embedded_worker_->message_port_message_filter(); 641 embedded_worker_->message_port_message_filter();
635 std::vector<int> new_routing_ids; 642 std::vector<int> new_routing_ids;
636 filter->UpdateMessagePortsWithNewRoutes(sent_message_ports, &new_routing_ids); 643 filter->UpdateMessagePortsWithNewRoutes(sent_message_ports, &new_routing_ids);
637 ServiceWorkerStatusCode status = 644 ServiceWorkerStatusCode status =
638 embedded_worker_->SendMessage(ServiceWorkerMsg_CrossOriginMessageToWorker( 645 embedded_worker_->SendMessage(ServiceWorkerMsg_CrossOriginMessageToWorker(
639 client, message, sent_message_ports, new_routing_ids)); 646 client, message, sent_message_ports, new_routing_ids));
(...skipping 304 matching lines...) Expand 10 before | Expand all | Expand 10 after
944 const url::Origin& source_origin, 951 const url::Origin& source_origin,
945 const std::vector<TransferredMessagePort>& sent_message_ports, 952 const std::vector<TransferredMessagePort>& sent_message_ports,
946 const StatusCallback& callback, 953 const StatusCallback& callback,
947 const SourceInfo& source_info) { 954 const SourceInfo& source_info) {
948 if (!source_info.IsValid()) { 955 if (!source_info.IsValid()) {
949 RunErrorMessageCallback(sent_message_ports, callback, 956 RunErrorMessageCallback(sent_message_ports, callback,
950 SERVICE_WORKER_ERROR_FAILED); 957 SERVICE_WORKER_ERROR_FAILED);
951 return; 958 return;
952 } 959 }
953 RunAfterStartWorker( 960 RunAfterStartWorker(
961 ServiceWorkerMetrics::EventType::MESSAGE,
954 base::Bind( 962 base::Bind(
955 &ServiceWorkerVersion::DispatchExtendableMessageEventAfterStartWorker, 963 &ServiceWorkerVersion::DispatchExtendableMessageEventAfterStartWorker,
956 weak_factory_.GetWeakPtr(), message, source_origin, 964 weak_factory_.GetWeakPtr(), message, source_origin,
957 sent_message_ports, ExtendableMessageEventSource(source_info), 965 sent_message_ports, ExtendableMessageEventSource(source_info),
958 callback), 966 callback),
959 base::Bind(&RunErrorMessageCallback, sent_message_ports, callback)); 967 base::Bind(&RunErrorMessageCallback, sent_message_ports, callback));
960 } 968 }
961 969
962 void ServiceWorkerVersion::DispatchExtendableMessageEventAfterStartWorker( 970 void ServiceWorkerVersion::DispatchExtendableMessageEventAfterStartWorker(
963 const base::string16& message, 971 const base::string16& message,
(...skipping 402 matching lines...) Expand 10 before | Expand all | Expand 10 after
1366 base::Bind(&KillEmbeddedWorkerProcess, embedded_worker_->process_id(), 1374 base::Bind(&KillEmbeddedWorkerProcess, embedded_worker_->process_id(),
1367 RESULT_CODE_KILLED_BAD_MESSAGE)); 1375 RESULT_CODE_KILLED_BAD_MESSAGE));
1368 return; 1376 return;
1369 } 1377 }
1370 } 1378 }
1371 set_foreign_fetch_scopes(sub_scopes); 1379 set_foreign_fetch_scopes(sub_scopes);
1372 set_foreign_fetch_origins(origins); 1380 set_foreign_fetch_origins(origins);
1373 } 1381 }
1374 1382
1375 void ServiceWorkerVersion::DidEnsureLiveRegistrationForStartWorker( 1383 void ServiceWorkerVersion::DidEnsureLiveRegistrationForStartWorker(
1384 ServiceWorkerMetrics::EventType purpose,
1376 const StatusCallback& callback, 1385 const StatusCallback& callback,
1377 ServiceWorkerStatusCode status, 1386 ServiceWorkerStatusCode status,
1378 const scoped_refptr<ServiceWorkerRegistration>& registration) { 1387 const scoped_refptr<ServiceWorkerRegistration>& registration) {
1379 scoped_refptr<ServiceWorkerRegistration> protect = registration; 1388 scoped_refptr<ServiceWorkerRegistration> protect = registration;
1380 if (status == SERVICE_WORKER_ERROR_NOT_FOUND) { 1389 if (status == SERVICE_WORKER_ERROR_NOT_FOUND) {
1381 // When the registration has already been deleted from the storage but its 1390 // When the registration has already been deleted from the storage but its
1382 // active worker is still controlling clients, the event should be 1391 // active worker is still controlling clients, the event should be
1383 // dispatched on the worker. However, the storage cannot find the 1392 // dispatched on the worker. However, the storage cannot find the
1384 // registration. To handle the case, check the live registrations here. 1393 // registration. To handle the case, check the live registrations here.
1385 protect = context_->GetLiveRegistration(registration_id_); 1394 protect = context_->GetLiveRegistration(registration_id_);
1386 if (protect) { 1395 if (protect) {
1387 DCHECK(protect->is_deleted()); 1396 DCHECK(protect->is_deleted());
1388 status = SERVICE_WORKER_OK; 1397 status = SERVICE_WORKER_OK;
1389 } 1398 }
1390 } 1399 }
1391 if (status != SERVICE_WORKER_OK) { 1400 if (status != SERVICE_WORKER_OK) {
1392 RecordStartWorkerResult(status); 1401 RecordStartWorkerResult(purpose, status);
1393 RunSoon(base::Bind(callback, SERVICE_WORKER_ERROR_START_WORKER_FAILED)); 1402 RunSoon(base::Bind(callback, SERVICE_WORKER_ERROR_START_WORKER_FAILED));
1394 return; 1403 return;
1395 } 1404 }
1396 if (is_redundant()) { 1405 if (is_redundant()) {
1397 RecordStartWorkerResult(SERVICE_WORKER_ERROR_REDUNDANT); 1406 RecordStartWorkerResult(purpose, SERVICE_WORKER_ERROR_REDUNDANT);
1398 RunSoon(base::Bind(callback, SERVICE_WORKER_ERROR_REDUNDANT)); 1407 RunSoon(base::Bind(callback, SERVICE_WORKER_ERROR_REDUNDANT));
1399 return; 1408 return;
1400 } 1409 }
1401 1410
1402 MarkIfStale(); 1411 MarkIfStale();
1403 1412
1404 switch (running_status()) { 1413 switch (running_status()) {
1405 case RUNNING: 1414 case RUNNING:
1406 RunSoon(base::Bind(callback, SERVICE_WORKER_OK)); 1415 RunSoon(base::Bind(callback, SERVICE_WORKER_OK));
1407 return; 1416 return;
1408 case STARTING: 1417 case STARTING:
1409 DCHECK(!start_callbacks_.empty()); 1418 DCHECK(!start_callbacks_.empty());
1410 break; 1419 break;
1411 case STOPPING: 1420 case STOPPING:
1412 case STOPPED: 1421 case STOPPED:
1413 if (start_callbacks_.empty()) { 1422 if (start_callbacks_.empty()) {
1414 start_callbacks_.push_back( 1423 start_callbacks_.push_back(
1415 base::Bind(&ServiceWorkerVersion::RecordStartWorkerResult, 1424 base::Bind(&ServiceWorkerVersion::RecordStartWorkerResult,
1416 weak_factory_.GetWeakPtr())); 1425 weak_factory_.GetWeakPtr(), purpose));
1417 } 1426 }
1418 break; 1427 break;
1419 } 1428 }
1420 1429
1421 // Keep the live registration while starting the worker. 1430 // Keep the live registration while starting the worker.
1422 start_callbacks_.push_back( 1431 start_callbacks_.push_back(
1423 base::Bind(&RunStartWorkerCallback, callback, protect)); 1432 base::Bind(&RunStartWorkerCallback, callback, protect));
1424 1433
1425 if (running_status() == STOPPED) 1434 if (running_status() == STOPPED)
1426 StartWorkerInternal(); 1435 StartWorkerInternal();
(...skipping 171 matching lines...) Expand 10 before | Expand all | Expand 10 after
1598 } 1607 }
1599 1608
1600 embedded_worker_->StopIfIdle(); 1609 embedded_worker_->StopIfIdle();
1601 } 1610 }
1602 1611
1603 bool ServiceWorkerVersion::HasInflightRequests() const { 1612 bool ServiceWorkerVersion::HasInflightRequests() const {
1604 return !custom_requests_.IsEmpty() || !streaming_url_request_jobs_.empty(); 1613 return !custom_requests_.IsEmpty() || !streaming_url_request_jobs_.empty();
1605 } 1614 }
1606 1615
1607 void ServiceWorkerVersion::RecordStartWorkerResult( 1616 void ServiceWorkerVersion::RecordStartWorkerResult(
1617 ServiceWorkerMetrics::EventType purpose,
1608 ServiceWorkerStatusCode status) { 1618 ServiceWorkerStatusCode status) {
1609 base::TimeTicks start_time = start_time_; 1619 base::TimeTicks start_time = start_time_;
1610 ClearTick(&start_time_); 1620 ClearTick(&start_time_);
1611 1621
1612 if (context_) 1622 if (context_)
1613 context_->UpdateVersionFailureCount(version_id_, status); 1623 context_->UpdateVersionFailureCount(version_id_, status);
1614 1624
1615 ServiceWorkerMetrics::RecordStartWorkerStatus(status, 1625 ServiceWorkerMetrics::RecordStartWorkerStatus(status, purpose,
1616 IsInstalled(prestart_status_)); 1626 IsInstalled(prestart_status_));
1617 1627
1618 if (status == SERVICE_WORKER_OK && !start_time.is_null() && 1628 if (status == SERVICE_WORKER_OK && !start_time.is_null() &&
1619 !skip_recording_startup_time_) { 1629 !skip_recording_startup_time_) {
1620 ServiceWorkerMetrics::RecordStartWorkerTime(GetTickDuration(start_time), 1630 ServiceWorkerMetrics::RecordStartWorkerTime(GetTickDuration(start_time),
1621 IsInstalled(prestart_status_)); 1631 IsInstalled(prestart_status_));
1622 } 1632 }
1623 1633
1624 if (status != SERVICE_WORKER_ERROR_TIMEOUT) 1634 if (status != SERVICE_WORKER_ERROR_TIMEOUT)
1625 return; 1635 return;
(...skipping 164 matching lines...) Expand 10 before | Expand all | Expand 10 after
1790 void ServiceWorkerVersion::OnBeginEvent() { 1800 void ServiceWorkerVersion::OnBeginEvent() {
1791 if (should_exclude_from_uma_ || running_status() != RUNNING || 1801 if (should_exclude_from_uma_ || running_status() != RUNNING ||
1792 idle_time_.is_null()) { 1802 idle_time_.is_null()) {
1793 return; 1803 return;
1794 } 1804 }
1795 ServiceWorkerMetrics::RecordTimeBetweenEvents(base::TimeTicks::Now() - 1805 ServiceWorkerMetrics::RecordTimeBetweenEvents(base::TimeTicks::Now() -
1796 idle_time_); 1806 idle_time_);
1797 } 1807 }
1798 1808
1799 } // namespace content 1809 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698