• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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 {
11 const char kInstallFailedErrorMessage[] = "ServiceWorker failed to install";
12 const char kActivateFailedErrorMessage[] = "ServiceWorker failed to activate";
13 }
14 
15 namespace content {
16 
17 using blink::WebServiceWorkerError;
18 
GetServiceWorkerRegistrationStatusResponse(ServiceWorkerRegistrationStatus status,blink::WebServiceWorkerError::ErrorType * error_type,base::string16 * message)19 void GetServiceWorkerRegistrationStatusResponse(
20     ServiceWorkerRegistrationStatus status,
21     blink::WebServiceWorkerError::ErrorType* error_type,
22     base::string16* message) {
23   switch (status) {
24     case REGISTRATION_OK:
25       NOTREACHED() << "Consumers should check registration status before "
26                       "calling this function.";
27       return;
28 
29     case REGISTRATION_INSTALL_FAILED:
30       *error_type = WebServiceWorkerError::InstallError;
31       *message = ASCIIToUTF16(kInstallFailedErrorMessage);
32       return;
33 
34     case REGISTRATION_ACTIVATE_FAILED:
35       *error_type = WebServiceWorkerError::ActivateError;
36       *message = ASCIIToUTF16(kActivateFailedErrorMessage);
37       return;
38   }
39   NOTREACHED();
40 }
41 }  // namespace content
42