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

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

Issue 1100763002: Inject CanAddURLToHistory into TopSitesImpl (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@prefs
Patch Set: Fix error introduced during rebase Created 5 years, 7 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_register_job.h" 5 #include "content/browser/service_worker/service_worker_register_job.h"
6 6
7 #include <vector> 7 #include <vector>
8 8
9 #include "base/message_loop/message_loop.h" 9 #include "base/message_loop/message_loop.h"
10 #include "content/browser/service_worker/service_worker_context_core.h" 10 #include "content/browser/service_worker/service_worker_context_core.h"
11 #include "content/browser/service_worker/service_worker_job_coordinator.h" 11 #include "content/browser/service_worker/service_worker_job_coordinator.h"
12 #include "content/browser/service_worker/service_worker_metrics.h"
12 #include "content/browser/service_worker/service_worker_registration.h" 13 #include "content/browser/service_worker/service_worker_registration.h"
13 #include "content/browser/service_worker/service_worker_storage.h" 14 #include "content/browser/service_worker/service_worker_storage.h"
14 #include "content/browser/service_worker/service_worker_utils.h" 15 #include "content/browser/service_worker/service_worker_utils.h"
15 #include "content/common/service_worker/service_worker_types.h" 16 #include "content/common/service_worker/service_worker_types.h"
16 #include "net/base/net_errors.h" 17 #include "net/base/net_errors.h"
17 18
18 namespace content { 19 namespace content {
19 20
20 namespace { 21 namespace {
21 22
(...skipping 356 matching lines...) Expand 10 before | Expand all | Expand 10 after
378 379
379 // A subsequent registration job may terminate our installing worker. It can 380 // A subsequent registration job may terminate our installing worker. It can
380 // only do so after we've started the worker and dispatched the install 381 // only do so after we've started the worker and dispatched the install
381 // event, as those are atomic substeps in the [[Install]] algorithm. 382 // event, as those are atomic substeps in the [[Install]] algorithm.
382 if (doom_installing_worker_) 383 if (doom_installing_worker_)
383 Complete(SERVICE_WORKER_ERROR_INSTALL_WORKER_FAILED); 384 Complete(SERVICE_WORKER_ERROR_INSTALL_WORKER_FAILED);
384 } 385 }
385 386
386 void ServiceWorkerRegisterJob::OnInstallFinished( 387 void ServiceWorkerRegisterJob::OnInstallFinished(
387 ServiceWorkerStatusCode status) { 388 ServiceWorkerStatusCode status) {
389 ServiceWorkerMetrics::RecordInstallEventStatus(status);
390
388 if (status != SERVICE_WORKER_OK) { 391 if (status != SERVICE_WORKER_OK) {
389 // "8. If installFailed is true, then:..." 392 // "8. If installFailed is true, then:..."
390 Complete(status); 393 Complete(status);
391 return; 394 return;
392 } 395 }
393 396
394 SetPhase(STORE); 397 SetPhase(STORE);
395 registration()->set_last_update_check(base::Time::Now()); 398 registration()->set_last_update_check(base::Time::Now());
396 context_->storage()->StoreRegistration( 399 context_->storage()->StoreRegistration(
397 registration(), 400 registration(),
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after
443 446
444 void ServiceWorkerRegisterJob::CompleteInternal( 447 void ServiceWorkerRegisterJob::CompleteInternal(
445 ServiceWorkerStatusCode status, 448 ServiceWorkerStatusCode status,
446 const std::string& status_message) { 449 const std::string& status_message) {
447 SetPhase(COMPLETE); 450 SetPhase(COMPLETE);
448 if (status != SERVICE_WORKER_OK) { 451 if (status != SERVICE_WORKER_OK) {
449 if (registration()) { 452 if (registration()) {
450 if (should_uninstall_on_failure_) 453 if (should_uninstall_on_failure_)
451 registration()->ClearWhenReady(); 454 registration()->ClearWhenReady();
452 if (new_version()) { 455 if (new_version()) {
453 if (status != SERVICE_WORKER_ERROR_EXISTS) 456 if (status == SERVICE_WORKER_ERROR_EXISTS)
457 new_version()->SetStartWorkerStatusCode(SERVICE_WORKER_ERROR_EXISTS);
458 else
454 new_version()->ReportError(status, status_message); 459 new_version()->ReportError(status, status_message);
455 registration()->UnsetVersion(new_version()); 460 registration()->UnsetVersion(new_version());
456 new_version()->Doom(); 461 new_version()->Doom();
457 } 462 }
458 if (!registration()->waiting_version() && 463 if (!registration()->waiting_version() &&
459 !registration()->active_version()) { 464 !registration()->active_version()) {
460 registration()->NotifyRegistrationFailed(); 465 registration()->NotifyRegistrationFailed();
461 context_->storage()->DeleteRegistration( 466 context_->storage()->DeleteRegistration(
462 registration()->id(), 467 registration()->id(),
463 registration()->pattern().GetOrigin(), 468 registration()->pattern().GetOrigin(),
(...skipping 89 matching lines...) Expand 10 before | Expand all | Expand 10 after
553 if (host->IsHostToRunningServiceWorker()) 558 if (host->IsHostToRunningServiceWorker())
554 continue; 559 continue;
555 if (!ServiceWorkerUtils::ScopeMatches(registration->pattern(), 560 if (!ServiceWorkerUtils::ScopeMatches(registration->pattern(),
556 host->document_url())) 561 host->document_url()))
557 continue; 562 continue;
558 host->AddMatchingRegistration(registration); 563 host->AddMatchingRegistration(registration);
559 } 564 }
560 } 565 }
561 566
562 } // namespace content 567 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698