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

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

Issue 567903002: ServiceWorker: Change worker script fetch error code(2/3). (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: rebase & fix typo Created 6 years, 3 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_register_job.cc
diff --git a/content/browser/service_worker/service_worker_register_job.cc b/content/browser/service_worker/service_worker_register_job.cc
index 44c6f60e22f9cd71fffc30593599b88f8ff8da43..b728eca653e94cdff0386b4b1e5bec12505c5166 100644
--- a/content/browser/service_worker/service_worker_register_job.cc
+++ b/content/browser/service_worker/service_worker_register_job.cc
@@ -12,6 +12,7 @@
#include "content/browser/service_worker/service_worker_registration.h"
#include "content/browser/service_worker/service_worker_storage.h"
#include "content/browser/service_worker/service_worker_utils.h"
+#include "net/base/net_errors.h"
namespace content {
@@ -333,14 +334,33 @@ void ServiceWorkerRegisterJob::UpdateAndContinue() {
void ServiceWorkerRegisterJob::OnStartWorkerFinished(
ServiceWorkerStatusCode status) {
- // "If serviceWorker fails to start up..." then reject the promise with an
- // error and abort.
- if (status != SERVICE_WORKER_OK) {
- Complete(status);
+ if (status == SERVICE_WORKER_OK) {
+ InstallAndContinue();
return;
}
- InstallAndContinue();
+ // "If serviceWorker fails to start up..." then reject the promise with an
+ // error and abort. When there is a main script network error, the status will
+ // be updated to a more specific one.
+ const net::URLRequestStatus& main_script_status =
+ new_version()->script_cache_map()->main_script_status();
+ if (main_script_status.status() != net::URLRequestStatus::SUCCESS) {
+ switch (main_script_status.error()) {
+ case net::ERR_INSECURE_RESPONSE:
+ case net::ERR_UNSAFE_REDIRECT:
+ status = SERVICE_WORKER_ERROR_SECURITY;
+ break;
+ case net::ERR_ABORTED:
+ status = SERVICE_WORKER_ERROR_ABORT;
+ break;
+ case net::ERR_FAILED:
+ status = SERVICE_WORKER_ERROR_NETWORK;
+ break;
+ default:
+ NOTREACHED();
horo 2014/09/24 12:55:32 Why don't we handle other error types?
+ }
+ }
+ Complete(status);
}
// This function corresponds to the spec's [[Install]] algorithm.

Powered by Google App Engine
This is Rietveld 408576698