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

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

Issue 182253010: Register a Service Worker when an extension is enabled. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Sync to r261176 Created 6 years, 8 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 | Annotate | Revision Log
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 "content/browser/service_worker/service_worker_job_coordinator.h" 9 #include "content/browser/service_worker/service_worker_job_coordinator.h"
10 #include "content/browser/service_worker/service_worker_registration.h" 10 #include "content/browser/service_worker/service_worker_registration.h"
(...skipping 126 matching lines...) Expand 10 before | Expand all | Expand 10 after
137 pending_version_->StartWorker(base::Bind(&ServiceWorkerRegisterJob::Complete, 137 pending_version_->StartWorker(base::Bind(&ServiceWorkerRegisterJob::Complete,
138 weak_factory_.GetWeakPtr())); 138 weak_factory_.GetWeakPtr()));
139 139
140 // TODO(falken): Don't set the active version until just before 140 // TODO(falken): Don't set the active version until just before
141 // the activate event is dispatched. 141 // the activate event is dispatched.
142 pending_version_->SetStatus(ServiceWorkerVersion::ACTIVE); 142 pending_version_->SetStatus(ServiceWorkerVersion::ACTIVE);
143 registration_->set_active_version(pending_version_); 143 registration_->set_active_version(pending_version_);
144 } 144 }
145 145
146 void ServiceWorkerRegisterJob::Complete(ServiceWorkerStatusCode status) { 146 void ServiceWorkerRegisterJob::Complete(ServiceWorkerStatusCode status) {
147 if (status == SERVICE_WORKER_OK)
148 DCHECK(registration_);
149 else
150 registration_ = NULL;
151
147 for (std::vector<RegistrationCallback>::iterator it = callbacks_.begin(); 152 for (std::vector<RegistrationCallback>::iterator it = callbacks_.begin();
148 it != callbacks_.end(); 153 it != callbacks_.end();
149 ++it) { 154 ++it) {
150 it->Run(status, registration_); 155 it->Run(status, registration_);
151 } 156 }
152 coordinator_->FinishJob(pattern_, this); 157 coordinator_->FinishJob(pattern_, this);
153 } 158 }
154 159
155 } // namespace content 160 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698