Use multiline attribute to check for IA2_STATE_MULTILINE.
[chromium-blink-merge.git] / content / browser / service_worker / service_worker_registration_status.cc
blob45b947d645e53eb6ed1887aca9e08541a8e22575
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 const std::string& status_message,
17 blink::WebServiceWorkerError::ErrorType* error_type,
18 base::string16* message) {
19 *error_type = WebServiceWorkerError::ErrorTypeUnknown;
20 if (!status_message.empty())
21 *message = base::UTF8ToUTF16(status_message);
22 else
23 *message = base::ASCIIToUTF16(ServiceWorkerStatusToString(status));
24 switch (status) {
25 case SERVICE_WORKER_OK:
26 NOTREACHED() << "Calling this when status == OK is not allowed";
27 return;
29 case SERVICE_WORKER_ERROR_START_WORKER_FAILED:
30 case SERVICE_WORKER_ERROR_INSTALL_WORKER_FAILED:
31 *error_type = WebServiceWorkerError::ErrorTypeInstall;
32 return;
34 case SERVICE_WORKER_ERROR_ACTIVATE_WORKER_FAILED:
35 *error_type = WebServiceWorkerError::ErrorTypeActivate;
36 return;
38 case SERVICE_WORKER_ERROR_NOT_FOUND:
39 *error_type = WebServiceWorkerError::ErrorTypeNotFound;
40 return;
42 case SERVICE_WORKER_ERROR_NETWORK:
43 *error_type = WebServiceWorkerError::ErrorTypeNetwork;
44 return;
46 case SERVICE_WORKER_ERROR_SECURITY:
47 *error_type = WebServiceWorkerError::ErrorTypeSecurity;
48 return;
50 case SERVICE_WORKER_ERROR_TIMEOUT:
51 *error_type = WebServiceWorkerError::ErrorTypeTimeout;
52 return;
54 case SERVICE_WORKER_ERROR_ABORT:
55 *error_type = WebServiceWorkerError::ErrorTypeAbort;
56 return;
58 case SERVICE_WORKER_ERROR_IPC_FAILED:
59 case SERVICE_WORKER_ERROR_FAILED:
60 case SERVICE_WORKER_ERROR_PROCESS_NOT_FOUND:
61 case SERVICE_WORKER_ERROR_EXISTS:
62 case SERVICE_WORKER_ERROR_EVENT_WAITUNTIL_REJECTED:
63 case SERVICE_WORKER_ERROR_STATE:
64 case SERVICE_WORKER_ERROR_MAX_VALUE:
65 // Unexpected, or should have bailed out before calling this, or we don't
66 // have a corresponding blink error code yet.
67 break; // Fall through to NOTREACHED().
69 NOTREACHED() << "Got unexpected error code: "
70 << status << " " << ServiceWorkerStatusToString(status);
73 } // namespace content