| OLD | NEW |
| 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 content { | 10 namespace content { |
| 11 | 11 |
| 12 using blink::WebServiceWorkerError; | 12 using blink::WebServiceWorkerError; |
| 13 | 13 |
| 14 void GetServiceWorkerRegistrationStatusResponse( | 14 void GetServiceWorkerRegistrationStatusResponse( |
| 15 ServiceWorkerStatusCode status, | 15 ServiceWorkerStatusCode status, |
| 16 blink::WebServiceWorkerError::ErrorType* error_type, | 16 blink::WebServiceWorkerError::ErrorType* error_type, |
| 17 base::string16* message) { | 17 base::string16* message) { |
| 18 *error_type = WebServiceWorkerError::UnknownError; | 18 *error_type = WebServiceWorkerError::ErrorTypeUnknown; |
| 19 *message = base::ASCIIToUTF16(ServiceWorkerStatusToString(status)); | 19 *message = base::ASCIIToUTF16(ServiceWorkerStatusToString(status)); |
| 20 switch (status) { | 20 switch (status) { |
| 21 case SERVICE_WORKER_OK: | 21 case SERVICE_WORKER_OK: |
| 22 NOTREACHED() << "Calling this when status == OK is not allowed"; | 22 NOTREACHED() << "Calling this when status == OK is not allowed"; |
| 23 return; | 23 return; |
| 24 | 24 |
| 25 case SERVICE_WORKER_ERROR_START_WORKER_FAILED: | 25 case SERVICE_WORKER_ERROR_START_WORKER_FAILED: |
| 26 case SERVICE_WORKER_ERROR_INSTALL_WORKER_FAILED: | 26 case SERVICE_WORKER_ERROR_INSTALL_WORKER_FAILED: |
| 27 *error_type = WebServiceWorkerError::InstallError; | 27 *error_type = WebServiceWorkerError::ErrorTypeInstall; |
| 28 return; | 28 return; |
| 29 | 29 |
| 30 case SERVICE_WORKER_ERROR_ACTIVATE_WORKER_FAILED: | 30 case SERVICE_WORKER_ERROR_ACTIVATE_WORKER_FAILED: |
| 31 *error_type = WebServiceWorkerError::ActivateError; | 31 *error_type = WebServiceWorkerError::ErrorTypeActivate; |
| 32 return; | 32 return; |
| 33 | 33 |
| 34 case SERVICE_WORKER_ERROR_NOT_FOUND: | 34 case SERVICE_WORKER_ERROR_NOT_FOUND: |
| 35 *error_type = WebServiceWorkerError::NotFoundError; | 35 *error_type = WebServiceWorkerError::ErrorTypeNotFound; |
| 36 return; | 36 return; |
| 37 | 37 |
| 38 case SERVICE_WORKER_ERROR_ABORT: | 38 case SERVICE_WORKER_ERROR_ABORT: |
| 39 case SERVICE_WORKER_ERROR_IPC_FAILED: | 39 case SERVICE_WORKER_ERROR_IPC_FAILED: |
| 40 case SERVICE_WORKER_ERROR_FAILED: | 40 case SERVICE_WORKER_ERROR_FAILED: |
| 41 case SERVICE_WORKER_ERROR_PROCESS_NOT_FOUND: | 41 case SERVICE_WORKER_ERROR_PROCESS_NOT_FOUND: |
| 42 case SERVICE_WORKER_ERROR_EXISTS: | 42 case SERVICE_WORKER_ERROR_EXISTS: |
| 43 case SERVICE_WORKER_ERROR_DB_CORRUPTED: | 43 case SERVICE_WORKER_ERROR_DB_CORRUPTED: |
| 44 // Unexpected, or should have bailed out before calling this, or we don't | 44 // Unexpected, or should have bailed out before calling this, or we don't |
| 45 // have a corresponding blink error code yet. | 45 // have a corresponding blink error code yet. |
| 46 break; // Fall through to NOTREACHED(). | 46 break; // Fall through to NOTREACHED(). |
| 47 } | 47 } |
| 48 NOTREACHED() << "Got unexpected error code: " | 48 NOTREACHED() << "Got unexpected error code: " |
| 49 << status << " " << ServiceWorkerStatusToString(status); | 49 << status << " " << ServiceWorkerStatusToString(status); |
| 50 } | 50 } |
| 51 | 51 |
| 52 } // namespace content | 52 } // namespace content |
| OLD | NEW |