OLD | NEW |
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 "chrome/browser/extensions/api/instance_id/instance_id_api.h" | 5 #include "chrome/browser/extensions/api/instance_id/instance_id_api.h" |
6 | 6 |
7 #include "base/logging.h" | 7 #include "base/logging.h" |
8 #include "chrome/browser/profiles/profile.h" | 8 #include "chrome/browser/profiles/profile.h" |
9 #include "chrome/browser/services/gcm/instance_id/instance_id_profile_service.h" | 9 #include "chrome/browser/services/gcm/instance_id/instance_id_profile_service.h" |
10 #include "chrome/browser/services/gcm/instance_id/instance_id_profile_service_fa
ctory.h" | 10 #include "chrome/browser/services/gcm/instance_id/instance_id_profile_service_fa
ctory.h" |
11 #include "chrome/common/extensions/api/instance_id.h" | 11 #include "chrome/common/extensions/api/instance_id.h" |
12 #include "components/gcm_driver/instance_id/instance_id_driver.h" | 12 #include "components/gcm_driver/instance_id/instance_id_driver.h" |
13 #include "extensions/common/extension.h" | 13 #include "extensions/common/extension.h" |
14 | 14 |
15 namespace extensions { | 15 namespace extensions { |
16 | 16 |
17 namespace { | 17 namespace { |
18 | 18 |
19 // Error messages. | 19 // Error messages. |
20 const char kInvalidParameter[] = "Function was called with invalid parameters."; | 20 const char kInvalidParameter[] = "Function was called with invalid parameters."; |
21 const char kDisabled[] = "Instance ID is currently disabled."; | 21 const char kDisabled[] = "Instance ID is currently disabled."; |
| 22 const char kAsyncOperationPending[] = "Asynchronous operation is pending."; |
22 const char kNetworkError[] = "Network error occurred."; | 23 const char kNetworkError[] = "Network error occurred."; |
23 const char kServerError[] = "Server error occurred."; | 24 const char kServerError[] = "Server error occurred."; |
24 const char kUnknownError[] = "Unknown error occurred."; | 25 const char kUnknownError[] = "Unknown error occurred."; |
25 | 26 |
26 const char* InstanceIDResultToError(instance_id::InstanceID::Result result) { | 27 const char* InstanceIDResultToError(instance_id::InstanceID::Result result) { |
27 switch (result) { | 28 switch (result) { |
28 case instance_id::InstanceID::INVALID_PARAMETER: | 29 case instance_id::InstanceID::INVALID_PARAMETER: |
29 return kInvalidParameter; | 30 return kInvalidParameter; |
30 case instance_id::InstanceID::DISABLED: | 31 case instance_id::InstanceID::DISABLED: |
31 return kDisabled; | 32 return kDisabled; |
| 33 case instance_id::InstanceID::ASYNC_OPERATION_PENDING: |
| 34 return kAsyncOperationPending; |
32 case instance_id::InstanceID::NETWORK_ERROR: | 35 case instance_id::InstanceID::NETWORK_ERROR: |
33 return kNetworkError; | 36 return kNetworkError; |
34 case instance_id::InstanceID::SERVER_ERROR: | 37 case instance_id::InstanceID::SERVER_ERROR: |
35 return kServerError; | 38 return kServerError; |
36 case instance_id::InstanceID::UNKNOWN_ERROR: | 39 case instance_id::InstanceID::UNKNOWN_ERROR: |
37 return kUnknownError; | 40 return kUnknownError; |
38 default: | 41 default: |
39 NOTREACHED() << "Unexpected value of result cannot be converted: " | 42 NOTREACHED() << "Unexpected value of result cannot be converted: " |
40 << result; | 43 << result; |
41 } | 44 } |
(...skipping 143 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
185 | 188 |
186 void InstanceIDDeleteIDFunction::DeleteIDCompleted( | 189 void InstanceIDDeleteIDFunction::DeleteIDCompleted( |
187 instance_id::InstanceID::Result result) { | 190 instance_id::InstanceID::Result result) { |
188 if (result == instance_id::InstanceID::SUCCESS) | 191 if (result == instance_id::InstanceID::SUCCESS) |
189 Respond(NoArguments()); | 192 Respond(NoArguments()); |
190 else | 193 else |
191 Respond(Error(InstanceIDResultToError(result))); | 194 Respond(Error(InstanceIDResultToError(result))); |
192 } | 195 } |
193 | 196 |
194 } // namespace extensions | 197 } // namespace extensions |
OLD | NEW |