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

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

Issue 188283003: Add ServiceWorkerVersion::status() (which is to be persisted unlike running status) (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: build fix after rebase Created 6 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 | 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 "base/message_loop/message_loop.h" 9 #include "base/message_loop/message_loop.h"
10 #include "content/browser/service_worker/service_worker_job_coordinator.h" 10 #include "content/browser/service_worker/service_worker_job_coordinator.h"
(...skipping 93 matching lines...) Expand 10 before | Expand all | Expand 10 after
104 ServiceWorkerStatusCode status) { 104 ServiceWorkerStatusCode status) {
105 DCHECK(registration_); 105 DCHECK(registration_);
106 if (registration_->active_version()) { 106 if (registration_->active_version()) {
107 // We have an active version, so we can complete immediately, even 107 // We have an active version, so we can complete immediately, even
108 // if the service worker isn't running. 108 // if the service worker isn't running.
109 callback.Run(SERVICE_WORKER_OK); 109 callback.Run(SERVICE_WORKER_OK);
110 return; 110 return;
111 } 111 }
112 112
113 pending_version_ = new ServiceWorkerVersion( 113 pending_version_ = new ServiceWorkerVersion(
114 registration_, worker_registry_, registration_->next_version_id()); 114 registration_, worker_registry_,
115 storage_->NewVersionId());
115 for (std::vector<int>::const_iterator it = pending_process_ids_.begin(); 116 for (std::vector<int>::const_iterator it = pending_process_ids_.begin();
116 it != pending_process_ids_.end(); 117 it != pending_process_ids_.end();
117 ++it) 118 ++it)
118 pending_version_->AddProcessToWorker(*it); 119 pending_version_->AddProcessToWorker(*it);
119 120
120 // The callback to watch "installation" actually fires as soon as 121 // The callback to watch "installation" actually fires as soon as
121 // the worker is up and running, just before the install event is 122 // the worker is up and running, just before the install event is
122 // dispatched. The job will continue to run even though the main 123 // dispatched. The job will continue to run even though the main
123 // callback has executed. 124 // callback has executed.
124 pending_version_->StartWorker(callback); 125 pending_version_->StartWorker(callback);
125 126
126 // TODO(alecflett): Don't set the active version until just before 127 // TODO(alecflett): Don't set the active version until just before
127 // the activate event is dispatched. 128 // the activate event is dispatched.
129 pending_version_->set_status(ServiceWorkerVersion::ACTIVE);
128 registration_->set_active_version(pending_version_); 130 registration_->set_active_version(pending_version_);
129 } 131 }
130 132
131 void ServiceWorkerRegisterJob::RegisterPatternAndContinue( 133 void ServiceWorkerRegisterJob::RegisterPatternAndContinue(
132 const StatusCallback& callback, 134 const StatusCallback& callback,
133 ServiceWorkerStatusCode previous_status) { 135 ServiceWorkerStatusCode previous_status) {
134 if (previous_status == SERVICE_WORKER_ERROR_EXISTS) { 136 if (previous_status == SERVICE_WORKER_ERROR_EXISTS) {
135 // Registration already exists, call to the next step. 137 // Registration already exists, call to the next step.
136 RunSoon(base::Bind(callback, SERVICE_WORKER_OK)); 138 RunSoon(base::Bind(callback, SERVICE_WORKER_OK));
137 return; 139 return;
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after
183 void ServiceWorkerRegisterJob::Complete(ServiceWorkerStatusCode status) { 185 void ServiceWorkerRegisterJob::Complete(ServiceWorkerStatusCode status) {
184 for (std::vector<RegistrationCallback>::iterator it = callbacks_.begin(); 186 for (std::vector<RegistrationCallback>::iterator it = callbacks_.begin();
185 it != callbacks_.end(); 187 it != callbacks_.end();
186 ++it) { 188 ++it) {
187 it->Run(status, registration_); 189 it->Run(status, registration_);
188 } 190 }
189 coordinator_->FinishJob(pattern_, this); 191 coordinator_->FinishJob(pattern_, this);
190 } 192 }
191 193
192 } // namespace content 194 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698