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

Side by Side Diff: chrome/browser/extensions/api/bluetooth_low_energy/bluetooth_low_energy_api.cc

Issue 1464443002: bluetooth: android: Add BluetoothDevice::ConnectErrorCode enums (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: VI Created 4 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 2014 The Chromium Authors. All rights reserved. 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 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/bluetooth_low_energy/bluetooth_low_energ y_api.h" 5 #include "chrome/browser/extensions/api/bluetooth_low_energy/bluetooth_low_energ y_api.h"
6 6
7 #include <stdint.h> 7 #include <stdint.h>
8 #include <algorithm> 8 #include <algorithm>
9 #include <utility> 9 #include <utility>
10 10
(...skipping 21 matching lines...) Expand all
32 namespace apibtle = extensions::api::bluetooth_low_energy; 32 namespace apibtle = extensions::api::bluetooth_low_energy;
33 33
34 namespace extensions { 34 namespace extensions {
35 35
36 namespace { 36 namespace {
37 37
38 const char kErrorAdapterNotInitialized[] = 38 const char kErrorAdapterNotInitialized[] =
39 "Could not initialize Bluetooth adapter"; 39 "Could not initialize Bluetooth adapter";
40 const char kErrorAlreadyConnected[] = "Already connected"; 40 const char kErrorAlreadyConnected[] = "Already connected";
41 const char kErrorAlreadyNotifying[] = "Already notifying"; 41 const char kErrorAlreadyNotifying[] = "Already notifying";
42 const char kErrorAttributeLengthInvalid[] = "Attribute length invalid";
42 const char kErrorAuthenticationFailed[] = "Authentication failed"; 43 const char kErrorAuthenticationFailed[] = "Authentication failed";
43 const char kErrorCanceled[] = "Request canceled"; 44 const char kErrorCanceled[] = "Request canceled";
45 const char kErrorConnectionCongested[] = "Connection congested";
44 const char kErrorGattNotSupported[] = "Operation not supported by this service"; 46 const char kErrorGattNotSupported[] = "Operation not supported by this service";
45 const char kErrorHigherSecurity[] = "Higher security needed"; 47 const char kErrorHigherSecurity[] = "Higher security needed";
46 const char kErrorInProgress[] = "In progress"; 48 const char kErrorInProgress[] = "In progress";
47 const char kErrorInsufficientAuthorization[] = "Insufficient authorization"; 49 const char kErrorInsufficientAuthorization[] = "Insufficient authorization";
50 const char kErrorInsufficientEncryption[] = "Insufficient encryption";
51 const char kErrorInvalidAdvertisementLength[] = "Invalid advertisement length";
48 const char kErrorInvalidLength[] = "Invalid attribute value length"; 52 const char kErrorInvalidLength[] = "Invalid attribute value length";
49 const char kErrorNotConnected[] = "Not connected"; 53 const char kErrorNotConnected[] = "Not connected";
50 const char kErrorNotFound[] = "Instance not found"; 54 const char kErrorNotFound[] = "Instance not found";
51 const char kErrorNotNotifying[] = "Not notifying"; 55 const char kErrorNotNotifying[] = "Not notifying";
56 const char kErrorOffsetInvalid[] = "Offset invalid";
52 const char kErrorOperationFailed[] = "Operation failed"; 57 const char kErrorOperationFailed[] = "Operation failed";
53 const char kErrorPermissionDenied[] = "Permission denied"; 58 const char kErrorPermissionDenied[] = "Permission denied";
54 const char kErrorPlatformNotSupported[] = 59 const char kErrorPlatformNotSupported[] =
55 "This operation is not supported on the current platform"; 60 "This operation is not supported on the current platform";
61 const char kErrorRequestNotSupported[] = "Request not supported";
56 const char kErrorTimeout[] = "Operation timed out"; 62 const char kErrorTimeout[] = "Operation timed out";
57 const char kErrorUnsupportedDevice[] = 63 const char kErrorUnsupportedDevice[] =
58 "This device is not supported on the current platform"; 64 "This device is not supported on the current platform";
59 const char kErrorInvalidAdvertisementLength[] = "Invalid advertisement length";
60 const char kStatusAdvertisementAlreadyExists[] = 65 const char kStatusAdvertisementAlreadyExists[] =
61 "An advertisement is already advertising"; 66 "An advertisement is already advertising";
62 const char kStatusAdvertisementDoesNotExist[] = 67 const char kStatusAdvertisementDoesNotExist[] =
63 "This advertisement does not exist"; 68 "This advertisement does not exist";
64 69
65 // Returns the correct error string based on error status |status|. This is used 70 // Returns the correct error string based on error status |status|. This is used
66 // to set the value of |chrome.runtime.lastError.message| and should not be 71 // to set the value of |chrome.runtime.lastError.message| and should not be
67 // passed |BluetoothLowEnergyEventRouter::kStatusSuccess|. 72 // passed |BluetoothLowEnergyEventRouter::kStatusSuccess|.
68 std::string StatusToString(BluetoothLowEnergyEventRouter::Status status) { 73 std::string StatusToString(BluetoothLowEnergyEventRouter::Status status) {
69 switch (status) { 74 switch (status) {
70 case BluetoothLowEnergyEventRouter::kStatusErrorPermissionDenied:
71 return kErrorPermissionDenied;
72 case BluetoothLowEnergyEventRouter::kStatusErrorNotFound:
73 return kErrorNotFound;
74 case BluetoothLowEnergyEventRouter::kStatusErrorAlreadyConnected: 75 case BluetoothLowEnergyEventRouter::kStatusErrorAlreadyConnected:
75 return kErrorAlreadyConnected; 76 return kErrorAlreadyConnected;
76 case BluetoothLowEnergyEventRouter::kStatusErrorAlreadyNotifying: 77 case BluetoothLowEnergyEventRouter::kStatusErrorAlreadyNotifying:
77 return kErrorAlreadyNotifying; 78 return kErrorAlreadyNotifying;
79 case BluetoothLowEnergyEventRouter::kStatusErrorAttributeLengthInvalid:
80 return kErrorAttributeLengthInvalid;
81 case BluetoothLowEnergyEventRouter::kStatusErrorAuthenticationFailed:
82 return kErrorAuthenticationFailed;
83 case BluetoothLowEnergyEventRouter::kStatusErrorCanceled:
84 return kErrorCanceled;
85 case BluetoothLowEnergyEventRouter::kStatusErrorConnectionCongested:
86 return kErrorConnectionCongested;
87 case BluetoothLowEnergyEventRouter::kStatusErrorGattNotSupported:
88 return kErrorGattNotSupported;
89 case BluetoothLowEnergyEventRouter::kStatusErrorHigherSecurity:
90 return kErrorHigherSecurity;
91 case BluetoothLowEnergyEventRouter::kStatusErrorInProgress:
92 return kErrorInProgress;
93 case BluetoothLowEnergyEventRouter::kStatusErrorInsufficientAuthorization:
94 return kErrorInsufficientAuthorization;
95 case BluetoothLowEnergyEventRouter::kStatusErrorInsufficientEncryption:
96 return kErrorInsufficientEncryption;
97 case BluetoothLowEnergyEventRouter::kStatusErrorInvalidLength:
98 return kErrorInvalidLength;
78 case BluetoothLowEnergyEventRouter::kStatusErrorNotConnected: 99 case BluetoothLowEnergyEventRouter::kStatusErrorNotConnected:
79 return kErrorNotConnected; 100 return kErrorNotConnected;
80 case BluetoothLowEnergyEventRouter::kStatusErrorInsufficientAuthorization: 101 case BluetoothLowEnergyEventRouter::kStatusErrorNotFound:
81 return kErrorInsufficientAuthorization; 102 return kErrorNotFound;
82 case BluetoothLowEnergyEventRouter::kStatusErrorNotNotifying: 103 case BluetoothLowEnergyEventRouter::kStatusErrorNotNotifying:
83 return kErrorNotNotifying; 104 return kErrorNotNotifying;
84 case BluetoothLowEnergyEventRouter::kStatusErrorInProgress: 105 case BluetoothLowEnergyEventRouter::kStatusErrorOffsetInvalid:
85 return kErrorInProgress; 106 return kErrorOffsetInvalid;
86 case BluetoothLowEnergyEventRouter::kStatusErrorAuthenticationFailed: 107 case BluetoothLowEnergyEventRouter::kStatusErrorPermissionDenied:
87 return kErrorAuthenticationFailed; 108 return kErrorPermissionDenied;
88 case BluetoothLowEnergyEventRouter::kStatusErrorHigherSecurity: 109 case BluetoothLowEnergyEventRouter::kStatusErrorRequestNotSupported:
89 return kErrorHigherSecurity; 110 return kErrorRequestNotSupported;
90 case BluetoothLowEnergyEventRouter::kStatusErrorCanceled:
91 return kErrorCanceled;
92 case BluetoothLowEnergyEventRouter::kStatusErrorTimeout: 111 case BluetoothLowEnergyEventRouter::kStatusErrorTimeout:
93 return kErrorTimeout; 112 return kErrorTimeout;
94 case BluetoothLowEnergyEventRouter::kStatusErrorUnsupportedDevice: 113 case BluetoothLowEnergyEventRouter::kStatusErrorUnsupportedDevice:
95 return kErrorUnsupportedDevice; 114 return kErrorUnsupportedDevice;
96 case BluetoothLowEnergyEventRouter::kStatusErrorInvalidLength:
97 return kErrorInvalidLength;
98 case BluetoothLowEnergyEventRouter::kStatusErrorGattNotSupported:
99 return kErrorGattNotSupported;
100 case BluetoothLowEnergyEventRouter::kStatusSuccess: 115 case BluetoothLowEnergyEventRouter::kStatusSuccess:
101 NOTREACHED(); 116 NOTREACHED();
102 break; 117 break;
103 default: 118 default:
104 return kErrorOperationFailed; 119 return kErrorOperationFailed;
105 } 120 }
106 return ""; 121 return "";
107 } 122 }
108 123
109 extensions::BluetoothLowEnergyEventRouter* GetEventRouter( 124 extensions::BluetoothLowEnergyEventRouter* GetEventRouter(
(...skipping 941 matching lines...) Expand 10 before | Expand all | Expand 10 after
1051 SetError(kStatusAdvertisementDoesNotExist); 1066 SetError(kStatusAdvertisementDoesNotExist);
1052 break; 1067 break;
1053 default: 1068 default:
1054 SetError(kErrorOperationFailed); 1069 SetError(kErrorOperationFailed);
1055 } 1070 }
1056 SendResponse(false); 1071 SendResponse(false);
1057 } 1072 }
1058 1073
1059 } // namespace api 1074 } // namespace api
1060 } // namespace extensions 1075 } // namespace extensions
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698