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

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

Issue 142973003: Have a central operation status code for ServiceWorker (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 6 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 | 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_registration_status.h" 5 #include "content/browser/service_worker/service_worker_registration_status.h"
6 6
7 #include "base/logging.h" 7 #include "base/logging.h"
8 #include "base/strings/utf_string_conversions.h" 8 #include "base/strings/utf_string_conversions.h"
9 9
10 namespace {
11 const char kInstallFailedErrorMessage[] = "ServiceWorker failed to install";
12 const char kActivateFailedErrorMessage[] = "ServiceWorker failed to activate";
13 }
14
15 namespace content { 10 namespace content {
16 11
17 using blink::WebServiceWorkerError; 12 using blink::WebServiceWorkerError;
18 13
19 void GetServiceWorkerRegistrationStatusResponse( 14 void GetServiceWorkerRegistrationStatusResponse(
20 ServiceWorkerRegistrationStatus status, 15 ServiceWorkerStatusCode status,
21 blink::WebServiceWorkerError::ErrorType* error_type, 16 blink::WebServiceWorkerError::ErrorType* error_type,
22 base::string16* message) { 17 base::string16* message) {
18 *error_type = WebServiceWorkerError::UnknownError;
19 *message = base::ASCIIToUTF16(ServiceWorkerStatusToString(status));
23 switch (status) { 20 switch (status) {
24 case REGISTRATION_OK: 21 case SERVICE_WORKER_OK:
25 NOTREACHED() << "Consumers should check registration status before " 22 NOTREACHED() << "Calling this when status == OK is not allowed";
26 "calling this function.";
27 return; 23 return;
28 24
29 case REGISTRATION_INSTALL_FAILED: 25 case SERVICE_WORKER_ERROR_START_WORKER_FAILED:
26 case SERVICE_WORKER_ERROR_INSTALL_WORKER_FAILED:
30 *error_type = WebServiceWorkerError::InstallError; 27 *error_type = WebServiceWorkerError::InstallError;
31 *message = base::ASCIIToUTF16(kInstallFailedErrorMessage);
32 return; 28 return;
33 29
34 case REGISTRATION_ACTIVATE_FAILED: 30 case SERVICE_WORKER_ERROR_ACTIVATE_WORKER_FAILED:
35 *error_type = WebServiceWorkerError::ActivateError; 31 *error_type = WebServiceWorkerError::ActivateError;
36 *message = base::ASCIIToUTF16(kActivateFailedErrorMessage);
37 return; 32 return;
33
34 case SERVICE_WORKER_ERROR_ABORT:
35 case SERVICE_WORKER_ERROR_FAILED:
36 case SERVICE_WORKER_ERROR_PROCESS_NOT_FOUND:
37 // Unexpected, or should bail out before calling this, or we don't
38 // have a corresponding blink error code yet.
39 break; // Fall through to NOTREACHED().
38 } 40 }
39 NOTREACHED(); 41 NOTREACHED() << "Got unexpected error code: "
42 << status << " " << ServiceWorkerStatusToString(status);
40 } 43 }
44
41 } // namespace content 45 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698