Upstream version 6.35.121.0
[platform/framework/web/crosswalk.git] / src / content / browser / service_worker / service_worker_registration_status.cc
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.
4
5 #include "content/browser/service_worker/service_worker_registration_status.h"
6
7 #include "base/logging.h"
8 #include "base/strings/utf_string_conversions.h"
9
10 namespace content {
11
12 using blink::WebServiceWorkerError;
13
14 void GetServiceWorkerRegistrationStatusResponse(
15     ServiceWorkerStatusCode status,
16     blink::WebServiceWorkerError::ErrorType* error_type,
17     base::string16* message) {
18   *error_type = WebServiceWorkerError::UnknownError;
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;
24
25     case SERVICE_WORKER_ERROR_START_WORKER_FAILED:
26     case SERVICE_WORKER_ERROR_INSTALL_WORKER_FAILED:
27       *error_type = WebServiceWorkerError::InstallError;
28       return;
29
30     case SERVICE_WORKER_ERROR_ACTIVATE_WORKER_FAILED:
31       *error_type = WebServiceWorkerError::ActivateError;
32       return;
33
34     case SERVICE_WORKER_ERROR_ABORT:
35     case SERVICE_WORKER_ERROR_IPC_FAILED:
36     case SERVICE_WORKER_ERROR_FAILED:
37     case SERVICE_WORKER_ERROR_PROCESS_NOT_FOUND:
38     case SERVICE_WORKER_ERROR_NOT_FOUND:
39     case SERVICE_WORKER_ERROR_EXISTS:
40       // Unexpected, or should have bailed out before calling this, or we don't
41       // have a corresponding blink error code yet.
42       break;  // Fall through to NOTREACHED().
43   }
44   NOTREACHED() << "Got unexpected error code: "
45                << status << " " << ServiceWorkerStatusToString(status);
46 }
47
48 }  // namespace content