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

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

Issue 894973003: ServiceWorker: Make "ready" fetches registration from browser process(2/3). (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: rebase Created 5 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_registration.h" 5 #include "content/browser/service_worker/service_worker_registration.h"
6 6
7 #include "content/browser/service_worker/service_worker_context_core.h" 7 #include "content/browser/service_worker/service_worker_context_core.h"
8 #include "content/browser/service_worker/service_worker_info.h" 8 #include "content/browser/service_worker/service_worker_info.h"
9 #include "content/browser/service_worker/service_worker_register_job.h" 9 #include "content/browser/service_worker/service_worker_register_job.h"
10 #include "content/browser/service_worker/service_worker_utils.h" 10 #include "content/browser/service_worker/service_worker_utils.h"
(...skipping 285 matching lines...) Expand 10 before | Expand all | Expand 10 after
296 if (status != SERVICE_WORKER_OK) { 296 if (status != SERVICE_WORKER_OK) {
297 // "11. If activateFailed is true, then:..." 297 // "11. If activateFailed is true, then:..."
298 UnsetVersion(activating_version); 298 UnsetVersion(activating_version);
299 activating_version->Doom(); 299 activating_version->Doom();
300 if (!waiting_version()) { 300 if (!waiting_version()) {
301 // Delete the records from the db. 301 // Delete the records from the db.
302 context_->storage()->DeleteRegistration( 302 context_->storage()->DeleteRegistration(
303 id(), pattern().GetOrigin(), 303 id(), pattern().GetOrigin(),
304 base::Bind(&ServiceWorkerRegistration::OnDeleteFinished, this)); 304 base::Bind(&ServiceWorkerRegistration::OnDeleteFinished, this));
305 // But not from memory if there is a version in the pipeline. 305 // But not from memory if there is a version in the pipeline.
306 if (installing_version()) 306 if (installing_version()) {
307 is_deleted_ = false; 307 is_deleted_ = false;
308 else 308 } else {
309 is_uninstalled_ = true; 309 is_uninstalled_ = true;
310 FOR_EACH_OBSERVER(Listener, listeners_, OnRegistrationFailed(this));
311 }
310 } 312 }
311 return; 313 return;
312 } 314 }
313 315
314 // "12. Run the [[UpdateState]] algorithm passing registration.activeWorker 316 // "12. Run the [[UpdateState]] algorithm passing registration.activeWorker
315 // and "activated" as the arguments." 317 // and "activated" as the arguments."
316 activating_version->SetStatus(ServiceWorkerVersion::ACTIVATED); 318 activating_version->SetStatus(ServiceWorkerVersion::ACTIVATED);
317 if (context_) { 319 if (context_) {
318 context_->storage()->UpdateToActiveState( 320 context_->storage()->UpdateToActiveState(
319 this, 321 this,
(...skipping 28 matching lines...) Expand all
348 active_version_->Doom(); 350 active_version_->Doom();
349 active_version_->RemoveListener(this); 351 active_version_->RemoveListener(this);
350 active_version_ = NULL; 352 active_version_ = NULL;
351 mask.add(ChangedVersionAttributesMask::ACTIVE_VERSION); 353 mask.add(ChangedVersionAttributesMask::ACTIVE_VERSION);
352 } 354 }
353 if (mask.changed()) { 355 if (mask.changed()) {
354 ServiceWorkerRegistrationInfo info = GetInfo(); 356 ServiceWorkerRegistrationInfo info = GetInfo();
355 FOR_EACH_OBSERVER(Listener, listeners_, 357 FOR_EACH_OBSERVER(Listener, listeners_,
356 OnVersionAttributesChanged(this, mask, info)); 358 OnVersionAttributesChanged(this, mask, info));
357 } 359 }
360
361 FOR_EACH_OBSERVER(
362 Listener, listeners_, OnRegistrationFinishedUninstalling(this));
358 } 363 }
359 364
360 void ServiceWorkerRegistration::OnRestoreFinished( 365 void ServiceWorkerRegistration::OnRestoreFinished(
361 const StatusCallback& callback, 366 const StatusCallback& callback,
362 scoped_refptr<ServiceWorkerVersion> version, 367 scoped_refptr<ServiceWorkerVersion> version,
363 ServiceWorkerStatusCode status) { 368 ServiceWorkerStatusCode status) {
364 if (!context_) { 369 if (!context_) {
365 callback.Run(SERVICE_WORKER_ERROR_ABORT); 370 callback.Run(SERVICE_WORKER_ERROR_ABORT);
366 return; 371 return;
367 } 372 }
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after
410 if (registration && 415 if (registration &&
411 (registration->is_uninstalling() || registration->is_uninstalled())) 416 (registration->is_uninstalling() || registration->is_uninstalled()))
412 continue; 417 continue;
413 if (matcher.MatchLongest(info.pattern)) 418 if (matcher.MatchLongest(info.pattern))
414 return false; 419 return false;
415 } 420 }
416 return true; 421 return true;
417 } 422 }
418 423
419 } // namespace content 424 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698