Blink roll 25b6bd3a7a131ffe68d809546ad1a20707915cdc:3a503f41ae42e5b79cfcd2ff10e65afde...
[chromium-blink-merge.git] / content / browser / service_worker / service_worker_registration_status.cc
blobe67b833826d33b986b79411e22b2f726de61740f
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
3 // found in the LICENSE file.
5 #include "content/browser/service_worker/service_worker_registration_status.h"
7 #include "base/logging.h"
8 #include "base/strings/utf_string_conversions.h"
10 namespace content {
12 using blink::WebServiceWorkerError;
14 void GetServiceWorkerRegistrationStatusResponse(
15 ServiceWorkerStatusCode status,
16 blink::WebServiceWorkerError::ErrorType* error_type,
17 base::string16* message) {
18 *error_type = WebServiceWorkerError::ErrorTypeUnknown;
19 *message = base::ASCIIToUTF16(ServiceWorkerStatusToString(status));
20 switch (status) {
21 case SERVICE_WORKER_OK:
22 NOTREACHED() << "Calling this when status == OK is not allowed";
23 return;
25 case SERVICE_WORKER_ERROR_START_WORKER_FAILED:
26 case SERVICE_WORKER_ERROR_INSTALL_WORKER_FAILED:
27 *error_type = WebServiceWorkerError::ErrorTypeInstall;
28 return;
30 case SERVICE_WORKER_ERROR_ACTIVATE_WORKER_FAILED:
31 *error_type = WebServiceWorkerError::ErrorTypeActivate;
32 return;
34 case SERVICE_WORKER_ERROR_NOT_FOUND:
35 *error_type = WebServiceWorkerError::ErrorTypeNotFound;
36 return;
38 case SERVICE_WORKER_ERROR_NETWORK:
39 *error_type = WebServiceWorkerError::ErrorTypeNetwork;
40 return;
42 case SERVICE_WORKER_ERROR_SECURITY:
43 *error_type = WebServiceWorkerError::ErrorTypeSecurity;
44 return;
46 case SERVICE_WORKER_ERROR_ABORT:
47 case SERVICE_WORKER_ERROR_IPC_FAILED:
48 case SERVICE_WORKER_ERROR_FAILED:
49 case SERVICE_WORKER_ERROR_PROCESS_NOT_FOUND:
50 case SERVICE_WORKER_ERROR_EXISTS:
51 // Unexpected, or should have bailed out before calling this, or we don't
52 // have a corresponding blink error code yet.
53 break; // Fall through to NOTREACHED().
55 NOTREACHED() << "Got unexpected error code: "
56 << status << " " << ServiceWorkerStatusToString(status);
59 } // namespace content