Add long running gmail memory benchmark for background tab.
[chromium-blink-merge.git] / content / browser / service_worker / service_worker_registration_status.cc
blob65f269fd361b882c80a4e62f428d51159f570890
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 <string>
9 #include "base/logging.h"
10 #include "base/strings/utf_string_conversions.h"
12 namespace content {
14 using blink::WebServiceWorkerError;
16 void GetServiceWorkerRegistrationStatusResponse(
17 ServiceWorkerStatusCode status,
18 const std::string& status_message,
19 blink::WebServiceWorkerError::ErrorType* error_type,
20 base::string16* message) {
21 *error_type = WebServiceWorkerError::ErrorTypeUnknown;
22 if (!status_message.empty())
23 *message = base::UTF8ToUTF16(status_message);
24 else
25 *message = base::ASCIIToUTF16(ServiceWorkerStatusToString(status));
26 switch (status) {
27 case SERVICE_WORKER_OK:
28 NOTREACHED() << "Calling this when status == OK is not allowed";
29 return;
31 case SERVICE_WORKER_ERROR_START_WORKER_FAILED:
32 case SERVICE_WORKER_ERROR_INSTALL_WORKER_FAILED:
33 case SERVICE_WORKER_ERROR_PROCESS_NOT_FOUND:
34 case SERVICE_WORKER_ERROR_SCRIPT_EVALUATE_FAILED:
35 case SERVICE_WORKER_ERROR_REDUNDANT:
36 *error_type = WebServiceWorkerError::ErrorTypeInstall;
37 return;
39 case SERVICE_WORKER_ERROR_NOT_FOUND:
40 *error_type = WebServiceWorkerError::ErrorTypeNotFound;
41 return;
43 case SERVICE_WORKER_ERROR_NETWORK:
44 *error_type = WebServiceWorkerError::ErrorTypeNetwork;
45 return;
47 case SERVICE_WORKER_ERROR_SECURITY:
48 *error_type = WebServiceWorkerError::ErrorTypeSecurity;
49 return;
51 case SERVICE_WORKER_ERROR_TIMEOUT:
52 *error_type = WebServiceWorkerError::ErrorTypeTimeout;
53 return;
55 case SERVICE_WORKER_ERROR_ABORT:
56 *error_type = WebServiceWorkerError::ErrorTypeAbort;
57 return;
59 case SERVICE_WORKER_ERROR_ACTIVATE_WORKER_FAILED:
60 case SERVICE_WORKER_ERROR_IPC_FAILED:
61 case SERVICE_WORKER_ERROR_FAILED:
62 case SERVICE_WORKER_ERROR_EXISTS:
63 case SERVICE_WORKER_ERROR_EVENT_WAITUNTIL_REJECTED:
64 case SERVICE_WORKER_ERROR_STATE:
65 case SERVICE_WORKER_ERROR_DISK_CACHE:
66 case SERVICE_WORKER_ERROR_MAX_VALUE:
67 // Unexpected, or should have bailed out before calling this, or we don't
68 // have a corresponding blink error code yet.
69 break; // Fall through to NOTREACHED().
71 NOTREACHED() << "Got unexpected error code: "
72 << status << " " << ServiceWorkerStatusToString(status);
75 } // namespace content