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

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: add unitests, change names Created 5 years, 10 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 292 matching lines...) Expand 10 before | Expand all | Expand 10 after
303 UnsetVersion(activating_version); 303 UnsetVersion(activating_version);
304 activating_version->Doom(); 304 activating_version->Doom();
305 if (!waiting_version()) { 305 if (!waiting_version()) {
306 // Delete the records from the db. 306 // Delete the records from the db.
307 context_->storage()->DeleteRegistration( 307 context_->storage()->DeleteRegistration(
308 id(), pattern().GetOrigin(), 308 id(), pattern().GetOrigin(),
309 base::Bind(&ServiceWorkerRegistration::OnDeleteFinished, this)); 309 base::Bind(&ServiceWorkerRegistration::OnDeleteFinished, this));
310 // But not from memory if there is a version in the pipeline. 310 // But not from memory if there is a version in the pipeline.
311 if (installing_version()) 311 if (installing_version())
312 is_deleted_ = false; 312 is_deleted_ = false;
313 else
314 FOR_EACH_OBSERVER(Listener, listeners_, OnRegistrationFailed(this));
313 } 315 }
314 return; 316 return;
315 } 317 }
316 318
317 // "12. Run the [[UpdateState]] algorithm passing registration.activeWorker 319 // "12. Run the [[UpdateState]] algorithm passing registration.activeWorker
318 // and "activated" as the arguments." 320 // and "activated" as the arguments."
319 activating_version->SetStatus(ServiceWorkerVersion::ACTIVATED); 321 activating_version->SetStatus(ServiceWorkerVersion::ACTIVATED);
320 if (context_) { 322 if (context_) {
321 context_->storage()->UpdateToActiveState( 323 context_->storage()->UpdateToActiveState(
322 this, 324 this,
(...skipping 28 matching lines...) Expand all
351 active_version_->Doom(); 353 active_version_->Doom();
352 active_version_->RemoveListener(this); 354 active_version_->RemoveListener(this);
353 active_version_ = NULL; 355 active_version_ = NULL;
354 mask.add(ChangedVersionAttributesMask::ACTIVE_VERSION); 356 mask.add(ChangedVersionAttributesMask::ACTIVE_VERSION);
355 } 357 }
356 if (mask.changed()) { 358 if (mask.changed()) {
357 ServiceWorkerRegistrationInfo info = GetInfo(); 359 ServiceWorkerRegistrationInfo info = GetInfo();
358 FOR_EACH_OBSERVER(Listener, listeners_, 360 FOR_EACH_OBSERVER(Listener, listeners_,
359 OnVersionAttributesChanged(this, mask, info)); 361 OnVersionAttributesChanged(this, mask, info));
360 } 362 }
363
364 FOR_EACH_OBSERVER(
365 Listener, listeners_, OnRegistrationFinishedUninstalling(this));
361 } 366 }
362 367
363 void ServiceWorkerRegistration::OnRestoreFinished( 368 void ServiceWorkerRegistration::OnRestoreFinished(
364 const StatusCallback& callback, 369 const StatusCallback& callback,
365 scoped_refptr<ServiceWorkerVersion> version, 370 scoped_refptr<ServiceWorkerVersion> version,
366 ServiceWorkerStatusCode status) { 371 ServiceWorkerStatusCode status) {
367 if (!context_) { 372 if (!context_) {
368 callback.Run(SERVICE_WORKER_ERROR_ABORT); 373 callback.Run(SERVICE_WORKER_ERROR_ABORT);
369 return; 374 return;
370 } 375 }
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after
411 if (registration && 416 if (registration &&
412 (registration->is_uninstalling() || registration->is_uninstalled())) 417 (registration->is_uninstalling() || registration->is_uninstalled()))
413 continue; 418 continue;
414 if (matcher.MatchLongest(info.pattern)) 419 if (matcher.MatchLongest(info.pattern))
415 return false; 420 return false;
416 } 421 }
417 return true; 422 return true;
418 } 423 }
419 424
420 } // namespace content 425 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698