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

Side by Side Diff: components/gcm_driver/instance_id/instance_id_impl.cc

Issue 2427633005: Improve GCM enum switch type safety (Closed)
Patch Set: Rebase Created 4 years, 2 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 2015 The Chromium Authors. All rights reserved. 1 // Copyright 2015 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 "components/gcm_driver/instance_id/instance_id_impl.h" 5 #include "components/gcm_driver/instance_id/instance_id_impl.h"
6 6
7 #include <stdint.h> 7 #include <stdint.h>
8 8
9 #include <algorithm> 9 #include <algorithm>
10 #include <memory> 10 #include <memory>
(...skipping 11 matching lines...) Expand all
22 22
23 namespace { 23 namespace {
24 24
25 InstanceID::Result GCMClientResultToInstanceIDResult( 25 InstanceID::Result GCMClientResultToInstanceIDResult(
26 gcm::GCMClient::Result result) { 26 gcm::GCMClient::Result result) {
27 switch (result) { 27 switch (result) {
28 case gcm::GCMClient::SUCCESS: 28 case gcm::GCMClient::SUCCESS:
29 return InstanceID::SUCCESS; 29 return InstanceID::SUCCESS;
30 case gcm::GCMClient::INVALID_PARAMETER: 30 case gcm::GCMClient::INVALID_PARAMETER:
31 return InstanceID::INVALID_PARAMETER; 31 return InstanceID::INVALID_PARAMETER;
32 case gcm::GCMClient::GCM_DISABLED:
33 return InstanceID::DISABLED;
32 case gcm::GCMClient::ASYNC_OPERATION_PENDING: 34 case gcm::GCMClient::ASYNC_OPERATION_PENDING:
33 return InstanceID::ASYNC_OPERATION_PENDING; 35 return InstanceID::ASYNC_OPERATION_PENDING;
34 case gcm::GCMClient::GCM_DISABLED:
35 return InstanceID::DISABLED;
36 case gcm::GCMClient::NETWORK_ERROR: 36 case gcm::GCMClient::NETWORK_ERROR:
37 return InstanceID::NETWORK_ERROR; 37 return InstanceID::NETWORK_ERROR;
38 case gcm::GCMClient::SERVER_ERROR: 38 case gcm::GCMClient::SERVER_ERROR:
39 return InstanceID::SERVER_ERROR; 39 return InstanceID::SERVER_ERROR;
40 case gcm::GCMClient::UNKNOWN_ERROR: 40 case gcm::GCMClient::UNKNOWN_ERROR:
41 return InstanceID::UNKNOWN_ERROR; 41 return InstanceID::UNKNOWN_ERROR;
42 default: 42 case gcm::GCMClient::TTL_EXCEEDED:
43 NOTREACHED() << "Unexpected value of result cannot be converted: " 43 NOTREACHED();
44 << result; 44 break;
45 } 45 }
46 return InstanceID::UNKNOWN_ERROR; 46 return InstanceID::UNKNOWN_ERROR;
47 } 47 }
48 48
49 } // namespace 49 } // namespace
50 50
51 // static 51 // static
52 std::unique_ptr<InstanceID> InstanceID::CreateInternal( 52 std::unique_ptr<InstanceID> InstanceID::CreateInternal(
53 const std::string& app_id, 53 const std::string& app_id,
54 gcm::GCMDriver* gcm_driver) { 54 gcm::GCMDriver* gcm_driver) {
(...skipping 214 matching lines...) Expand 10 before | Expand all | Expand 10 after
269 } 269 }
270 270
271 gcm::InstanceIDHandler* InstanceIDImpl::Handler() { 271 gcm::InstanceIDHandler* InstanceIDImpl::Handler() {
272 gcm::InstanceIDHandler* handler = 272 gcm::InstanceIDHandler* handler =
273 gcm_driver()->GetInstanceIDHandlerInternal(); 273 gcm_driver()->GetInstanceIDHandlerInternal();
274 DCHECK(handler); 274 DCHECK(handler);
275 return handler; 275 return handler;
276 } 276 }
277 277
278 } // namespace instance_id 278 } // namespace instance_id
OLDNEW
« no previous file with comments | « components/gcm_driver/gcm_stats_recorder_impl.cc ('k') | google_apis/gcm/engine/account_mapping.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698