Re-subimission of https://codereview.chromium.org/1041213003/
[chromium-blink-merge.git] / content / public / common / push_messaging_status.cc
blob9b4a42138e6acadee9eba552ca704292818010d2
1 // Copyright 2014 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/public/common/push_messaging_status.h"
7 #include "base/logging.h"
9 namespace content {
11 const char* PushRegistrationStatusToString(PushRegistrationStatus status) {
12 switch (status) {
13 case PUSH_REGISTRATION_STATUS_SUCCESS_FROM_PUSH_SERVICE:
14 return "Registration successful - from push service";
16 case PUSH_REGISTRATION_STATUS_NO_SERVICE_WORKER:
17 return "Registration failed - no Service Worker";
19 case PUSH_REGISTRATION_STATUS_SERVICE_NOT_AVAILABLE:
20 return "Registration failed - push service not available";
22 case PUSH_REGISTRATION_STATUS_LIMIT_REACHED:
23 return "Registration failed - registration limit has been reached";
25 case PUSH_REGISTRATION_STATUS_PERMISSION_DENIED:
26 return "Registration failed - permission denied";
28 case PUSH_REGISTRATION_STATUS_SERVICE_ERROR:
29 return "Registration failed - push service error";
31 case PUSH_REGISTRATION_STATUS_NO_SENDER_ID:
32 return "Registration failed - no sender id provided";
34 case PUSH_REGISTRATION_STATUS_STORAGE_ERROR:
35 return "Registration failed - storage error";
37 case PUSH_REGISTRATION_STATUS_SUCCESS_FROM_CACHE:
38 return "Registration successful - from cache";
40 case PUSH_REGISTRATION_STATUS_NETWORK_ERROR:
41 return "Registration failed - could not connect to push server";
43 case PUSH_REGISTRATION_STATUS_INCOGNITO_PERMISSION_DENIED:
44 // We split this out for UMA, but it must be indistinguishable to JS.
45 return PushRegistrationStatusToString(
46 PUSH_REGISTRATION_STATUS_PERMISSION_DENIED);
48 NOTREACHED();
49 return "";
52 const char* PushUnregistrationStatusToString(PushUnregistrationStatus status) {
53 switch (status) {
54 case PUSH_UNREGISTRATION_STATUS_SUCCESS_UNREGISTERED:
55 return "Unregistration successful - from push service";
57 case PUSH_UNREGISTRATION_STATUS_SUCCESS_WAS_NOT_REGISTERED:
58 return "Unregistration successful - was not registered";
60 case PUSH_UNREGISTRATION_STATUS_PENDING_NETWORK_ERROR:
61 return "Unregistration pending - a network error occurred, but it will "
62 "be retried until it succeeds";
64 case PUSH_UNREGISTRATION_STATUS_NO_SERVICE_WORKER:
65 return "Unregistration failed - no Service Worker";
67 case PUSH_UNREGISTRATION_STATUS_SERVICE_NOT_AVAILABLE:
68 return "Unregistration failed - push service not available";
70 case PUSH_UNREGISTRATION_STATUS_PENDING_SERVICE_ERROR:
71 return "Unregistration pending - a push service error occurred, but it "
72 "will be retried until it succeeds";
74 case PUSH_UNREGISTRATION_STATUS_STORAGE_ERROR:
75 return "Unregistration failed - storage error";
77 case PUSH_UNREGISTRATION_STATUS_NETWORK_ERROR:
78 return "Unregistration failed - could not connect to push server";
80 NOTREACHED();
81 return "";
84 } // namespace content