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

Unified Diff: content/browser/service_worker/service_worker_version.cc

Issue 369063004: ServiceWorker: SWRegisterJob should manage status of SWVersion (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: fix ServiceWorkerVersionBrowserTest Created 6 years, 5 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 side-by-side diff with in-line comments
Download patch
Index: content/browser/service_worker/service_worker_version.cc
diff --git a/content/browser/service_worker/service_worker_version.cc b/content/browser/service_worker/service_worker_version.cc
index d145dc8f70e40f9b99c29f19369b351b834e010c..e0455624f5625ad0cb547208db7848aca7986d45 100644
--- a/content/browser/service_worker/service_worker_version.cc
+++ b/content/browser/service_worker/service_worker_version.cc
@@ -238,7 +238,7 @@ void ServiceWorkerVersion::SendMessage(
void ServiceWorkerVersion::DispatchInstallEvent(
int active_version_id,
const StatusCallback& callback) {
- DCHECK_EQ(NEW, status()) << status();
+ DCHECK_EQ(INSTALLING, status()) << status();
if (running_status() != RUNNING) {
// Schedule calling this method after starting the worker.
nhiroki 2014/07/07 08:26:41 As I mentioned above, this code path will reach Se
@@ -257,8 +257,7 @@ void ServiceWorkerVersion::DispatchInstallEvent(
void ServiceWorkerVersion::DispatchActivateEvent(
const StatusCallback& callback) {
- DCHECK_EQ(INSTALLED, status()) << status();
- SetStatus(ACTIVATING);
+ DCHECK_EQ(ACTIVATING, status()) << status();
if (running_status() != RUNNING) {
// Schedule calling this method after starting the worker.
@@ -513,7 +512,6 @@ void ServiceWorkerVersion::DispatchInstallEventAfterStartWorker(
const StatusCallback& callback) {
DCHECK_EQ(RUNNING, running_status())
<< "Worker stopped too soon after it was started.";
- SetStatus(INSTALLING);
int request_id = install_callbacks_.Add(new StatusCallback(callback));
ServiceWorkerStatusCode status = embedded_worker_->SendMessage(
@@ -555,18 +553,16 @@ void ServiceWorkerVersion::OnGetClientDocuments(int request_id) {
void ServiceWorkerVersion::OnActivateEventFinished(
int request_id,
blink::WebServiceWorkerEventResult result) {
+ DCHECK_EQ(ACTIVATING, status()) << status();
+
StatusCallback* callback = activate_callbacks_.Lookup(request_id);
if (!callback) {
NOTREACHED() << "Got unexpected message: " << request_id;
return;
}
ServiceWorkerStatusCode status = SERVICE_WORKER_OK;
- if (result == blink::WebServiceWorkerEventResultRejected) {
+ if (result == blink::WebServiceWorkerEventResultRejected)
status = SERVICE_WORKER_ERROR_ACTIVATE_WORKER_FAILED;
- SetStatus(REDUNDANT);
- } else {
- SetStatus(ACTIVE);
- }
scoped_refptr<ServiceWorkerVersion> protect(this);
callback->Run(status);
@@ -576,18 +572,16 @@ void ServiceWorkerVersion::OnActivateEventFinished(
void ServiceWorkerVersion::OnInstallEventFinished(
int request_id,
blink::WebServiceWorkerEventResult result) {
+ DCHECK_EQ(INSTALLING, status()) << status();
+
StatusCallback* callback = install_callbacks_.Lookup(request_id);
if (!callback) {
NOTREACHED() << "Got unexpected message: " << request_id;
return;
}
ServiceWorkerStatusCode status = SERVICE_WORKER_OK;
- if (result == blink::WebServiceWorkerEventResultRejected) {
+ if (result == blink::WebServiceWorkerEventResultRejected)
status = SERVICE_WORKER_ERROR_INSTALL_WORKER_FAILED;
- SetStatus(REDUNDANT);
- } else {
- SetStatus(INSTALLED);
- }
scoped_refptr<ServiceWorkerVersion> protect(this);
callback->Run(status);

Powered by Google App Engine
This is Rietveld 408576698