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

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

Powered by Google App Engine
This is Rietveld 408576698