Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(214)

Side by Side Diff: content/browser/service_worker/service_worker_registration_status.cc

Issue 845313004: Service Worker: Improve error messages from register(). (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: git-cl format Created 5 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 // Copyright 2013 The Chromium Authors. All rights reserved. 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 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "content/browser/service_worker/service_worker_registration_status.h" 5 #include "content/browser/service_worker/service_worker_registration_status.h"
6 6
7 #include "base/logging.h" 7 #include "base/logging.h"
8 #include "base/strings/utf_string_conversions.h" 8 #include "base/strings/utf_string_conversions.h"
9 9
10 namespace content { 10 namespace content {
11 11
12 using blink::WebServiceWorkerError; 12 using blink::WebServiceWorkerError;
13 13
14 void GetServiceWorkerRegistrationStatusResponse( 14 void GetServiceWorkerRegistrationStatusResponse(
15 ServiceWorkerStatusCode status, 15 ServiceWorkerStatusCode status,
16 const std::string& status_message,
16 blink::WebServiceWorkerError::ErrorType* error_type, 17 blink::WebServiceWorkerError::ErrorType* error_type,
17 base::string16* message) { 18 base::string16* message) {
18 *error_type = WebServiceWorkerError::ErrorTypeUnknown; 19 *error_type = WebServiceWorkerError::ErrorTypeUnknown;
19 *message = base::ASCIIToUTF16(ServiceWorkerStatusToString(status)); 20 if (!status_message.empty())
21 *message = base::UTF8ToUTF16(status_message);
22 else
23 *message = base::ASCIIToUTF16(ServiceWorkerStatusToString(status));
20 switch (status) { 24 switch (status) {
21 case SERVICE_WORKER_OK: 25 case SERVICE_WORKER_OK:
22 NOTREACHED() << "Calling this when status == OK is not allowed"; 26 NOTREACHED() << "Calling this when status == OK is not allowed";
23 return; 27 return;
24 28
25 case SERVICE_WORKER_ERROR_START_WORKER_FAILED: 29 case SERVICE_WORKER_ERROR_START_WORKER_FAILED:
26 case SERVICE_WORKER_ERROR_INSTALL_WORKER_FAILED: 30 case SERVICE_WORKER_ERROR_INSTALL_WORKER_FAILED:
27 *error_type = WebServiceWorkerError::ErrorTypeInstall; 31 *error_type = WebServiceWorkerError::ErrorTypeInstall;
28 return; 32 return;
29 33
(...skipping 21 matching lines...) Expand all
51 case SERVICE_WORKER_ERROR_EVENT_WAITUNTIL_REJECTED: 55 case SERVICE_WORKER_ERROR_EVENT_WAITUNTIL_REJECTED:
52 // Unexpected, or should have bailed out before calling this, or we don't 56 // Unexpected, or should have bailed out before calling this, or we don't
53 // have a corresponding blink error code yet. 57 // have a corresponding blink error code yet.
54 break; // Fall through to NOTREACHED(). 58 break; // Fall through to NOTREACHED().
55 } 59 }
56 NOTREACHED() << "Got unexpected error code: " 60 NOTREACHED() << "Got unexpected error code: "
57 << status << " " << ServiceWorkerStatusToString(status); 61 << status << " " << ServiceWorkerStatusToString(status);
58 } 62 }
59 63
60 } // namespace content 64 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698