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

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

Issue 2727683003: bluetooth: Clean up connection errors (Closed)
Patch Set: merge Created 3 years, 9 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 "extensions/browser/api/bluetooth_low_energy/bluetooth_low_energy_api.h " 5 #include "extensions/browser/api/bluetooth_low_energy/bluetooth_low_energy_api.h "
6 6
7 #include <stdint.h> 7 #include <stdint.h>
8 #include <algorithm> 8 #include <algorithm>
9 #include <iterator> 9 #include <iterator>
10 #include <utility> 10 #include <utility>
(...skipping 29 matching lines...) Expand all
40 namespace apibtle = extensions::api::bluetooth_low_energy; 40 namespace apibtle = extensions::api::bluetooth_low_energy;
41 41
42 namespace extensions { 42 namespace extensions {
43 43
44 namespace { 44 namespace {
45 45
46 const char kErrorAdapterNotInitialized[] = 46 const char kErrorAdapterNotInitialized[] =
47 "Could not initialize Bluetooth adapter"; 47 "Could not initialize Bluetooth adapter";
48 const char kErrorAlreadyConnected[] = "Already connected"; 48 const char kErrorAlreadyConnected[] = "Already connected";
49 const char kErrorAlreadyNotifying[] = "Already notifying"; 49 const char kErrorAlreadyNotifying[] = "Already notifying";
50 const char kErrorAttributeLengthInvalid[] = "Attribute length invalid";
51 const char kErrorAuthenticationFailed[] = "Authentication failed"; 50 const char kErrorAuthenticationFailed[] = "Authentication failed";
52 const char kErrorCanceled[] = "Request canceled"; 51 const char kErrorCanceled[] = "Request canceled";
53 const char kErrorConnectionCongested[] = "Connection congested";
54 const char kErrorGattNotSupported[] = "Operation not supported by this service"; 52 const char kErrorGattNotSupported[] = "Operation not supported by this service";
55 const char kErrorHigherSecurity[] = "Higher security needed"; 53 const char kErrorHigherSecurity[] = "Higher security needed";
56 const char kErrorInProgress[] = "In progress"; 54 const char kErrorInProgress[] = "In progress";
57 const char kErrorInsufficientAuthorization[] = "Insufficient authorization"; 55 const char kErrorInsufficientAuthorization[] = "Insufficient authorization";
58 const char kErrorInsufficientEncryption[] = "Insufficient encryption";
59 const char kErrorInvalidAdvertisementLength[] = "Invalid advertisement length"; 56 const char kErrorInvalidAdvertisementLength[] = "Invalid advertisement length";
60 const char kErrorInvalidLength[] = "Invalid attribute value length"; 57 const char kErrorInvalidLength[] = "Invalid attribute value length";
61 const char kErrorNotConnected[] = "Not connected"; 58 const char kErrorNotConnected[] = "Not connected";
62 const char kErrorNotFound[] = "Instance not found"; 59 const char kErrorNotFound[] = "Instance not found";
63 const char kErrorNotNotifying[] = "Not notifying"; 60 const char kErrorNotNotifying[] = "Not notifying";
64 const char kErrorOffsetInvalid[] = "Offset invalid";
65 const char kErrorOperationFailed[] = "Operation failed"; 61 const char kErrorOperationFailed[] = "Operation failed";
66 const char kErrorPermissionDenied[] = "Permission denied"; 62 const char kErrorPermissionDenied[] = "Permission denied";
67 const char kErrorPlatformNotSupported[] = 63 const char kErrorPlatformNotSupported[] =
68 "This operation is not supported on the current platform"; 64 "This operation is not supported on the current platform";
69 const char kErrorRequestNotSupported[] = "Request not supported";
70 const char kErrorTimeout[] = "Operation timed out"; 65 const char kErrorTimeout[] = "Operation timed out";
71 const char kErrorUnsupportedDevice[] = 66 const char kErrorUnsupportedDevice[] =
72 "This device is not supported on the current platform"; 67 "This device is not supported on the current platform";
73 const char kErrorInvalidServiceId[] = "The service ID doesn't exist."; 68 const char kErrorInvalidServiceId[] = "The service ID doesn't exist.";
74 const char kErrorInvalidCharacteristicId[] = 69 const char kErrorInvalidCharacteristicId[] =
75 "The characteristic ID doesn't exist."; 70 "The characteristic ID doesn't exist.";
76 const char kErrorNotifyPropertyNotSet[] = 71 const char kErrorNotifyPropertyNotSet[] =
77 "The characteristic does not have the notify property set."; 72 "The characteristic does not have the notify property set.";
78 const char kErrorIndicatePropertyNotSet[] = 73 const char kErrorIndicatePropertyNotSet[] =
79 "The characteristic does not have the indicate property set."; 74 "The characteristic does not have the indicate property set.";
(...skipping 13 matching lines...) Expand all
93 88
94 // Returns the correct error string based on error status |status|. This is used 89 // Returns the correct error string based on error status |status|. This is used
95 // to set the value of |chrome.runtime.lastError.message| and should not be 90 // to set the value of |chrome.runtime.lastError.message| and should not be
96 // passed |BluetoothLowEnergyEventRouter::kStatusSuccess|. 91 // passed |BluetoothLowEnergyEventRouter::kStatusSuccess|.
97 std::string StatusToString(BluetoothLowEnergyEventRouter::Status status) { 92 std::string StatusToString(BluetoothLowEnergyEventRouter::Status status) {
98 switch (status) { 93 switch (status) {
99 case BluetoothLowEnergyEventRouter::kStatusErrorAlreadyConnected: 94 case BluetoothLowEnergyEventRouter::kStatusErrorAlreadyConnected:
100 return kErrorAlreadyConnected; 95 return kErrorAlreadyConnected;
101 case BluetoothLowEnergyEventRouter::kStatusErrorAlreadyNotifying: 96 case BluetoothLowEnergyEventRouter::kStatusErrorAlreadyNotifying:
102 return kErrorAlreadyNotifying; 97 return kErrorAlreadyNotifying;
103 case BluetoothLowEnergyEventRouter::kStatusErrorAttributeLengthInvalid:
104 return kErrorAttributeLengthInvalid;
105 case BluetoothLowEnergyEventRouter::kStatusErrorAuthenticationFailed: 98 case BluetoothLowEnergyEventRouter::kStatusErrorAuthenticationFailed:
106 return kErrorAuthenticationFailed; 99 return kErrorAuthenticationFailed;
107 case BluetoothLowEnergyEventRouter::kStatusErrorCanceled: 100 case BluetoothLowEnergyEventRouter::kStatusErrorCanceled:
108 return kErrorCanceled; 101 return kErrorCanceled;
109 case BluetoothLowEnergyEventRouter::kStatusErrorConnectionCongested:
110 return kErrorConnectionCongested;
111 case BluetoothLowEnergyEventRouter::kStatusErrorGattNotSupported: 102 case BluetoothLowEnergyEventRouter::kStatusErrorGattNotSupported:
112 return kErrorGattNotSupported; 103 return kErrorGattNotSupported;
113 case BluetoothLowEnergyEventRouter::kStatusErrorHigherSecurity: 104 case BluetoothLowEnergyEventRouter::kStatusErrorHigherSecurity:
114 return kErrorHigherSecurity; 105 return kErrorHigherSecurity;
115 case BluetoothLowEnergyEventRouter::kStatusErrorInProgress: 106 case BluetoothLowEnergyEventRouter::kStatusErrorInProgress:
116 return kErrorInProgress; 107 return kErrorInProgress;
117 case BluetoothLowEnergyEventRouter::kStatusErrorInsufficientAuthorization: 108 case BluetoothLowEnergyEventRouter::kStatusErrorInsufficientAuthorization:
118 return kErrorInsufficientAuthorization; 109 return kErrorInsufficientAuthorization;
119 case BluetoothLowEnergyEventRouter::kStatusErrorInsufficientEncryption:
120 return kErrorInsufficientEncryption;
121 case BluetoothLowEnergyEventRouter::kStatusErrorInvalidLength: 110 case BluetoothLowEnergyEventRouter::kStatusErrorInvalidLength:
122 return kErrorInvalidLength; 111 return kErrorInvalidLength;
123 case BluetoothLowEnergyEventRouter::kStatusErrorNotConnected: 112 case BluetoothLowEnergyEventRouter::kStatusErrorNotConnected:
124 return kErrorNotConnected; 113 return kErrorNotConnected;
125 case BluetoothLowEnergyEventRouter::kStatusErrorNotFound: 114 case BluetoothLowEnergyEventRouter::kStatusErrorNotFound:
126 return kErrorNotFound; 115 return kErrorNotFound;
127 case BluetoothLowEnergyEventRouter::kStatusErrorNotNotifying: 116 case BluetoothLowEnergyEventRouter::kStatusErrorNotNotifying:
128 return kErrorNotNotifying; 117 return kErrorNotNotifying;
129 case BluetoothLowEnergyEventRouter::kStatusErrorOffsetInvalid:
130 return kErrorOffsetInvalid;
131 case BluetoothLowEnergyEventRouter::kStatusErrorPermissionDenied: 118 case BluetoothLowEnergyEventRouter::kStatusErrorPermissionDenied:
132 return kErrorPermissionDenied; 119 return kErrorPermissionDenied;
133 case BluetoothLowEnergyEventRouter::kStatusErrorRequestNotSupported:
134 return kErrorRequestNotSupported;
135 case BluetoothLowEnergyEventRouter::kStatusErrorTimeout: 120 case BluetoothLowEnergyEventRouter::kStatusErrorTimeout:
136 return kErrorTimeout; 121 return kErrorTimeout;
137 case BluetoothLowEnergyEventRouter::kStatusErrorUnsupportedDevice: 122 case BluetoothLowEnergyEventRouter::kStatusErrorUnsupportedDevice:
138 return kErrorUnsupportedDevice; 123 return kErrorUnsupportedDevice;
139 case BluetoothLowEnergyEventRouter::kStatusErrorInvalidServiceId: 124 case BluetoothLowEnergyEventRouter::kStatusErrorInvalidServiceId:
140 return kErrorInvalidServiceId; 125 return kErrorInvalidServiceId;
141 case BluetoothLowEnergyEventRouter::kStatusSuccess: 126 case BluetoothLowEnergyEventRouter::kStatusSuccess:
142 NOTREACHED(); 127 NOTREACHED();
143 break; 128 break;
144 default: 129 default:
(...skipping 1366 matching lines...) Expand 10 before | Expand all | Expand 10 after
1511 params_->response.value->end()); 1496 params_->response.value->end());
1512 } 1497 }
1513 event_router_->HandleRequestResponse( 1498 event_router_->HandleRequestResponse(
1514 extension(), params_->response.request_id, params_->response.is_error, 1499 extension(), params_->response.request_id, params_->response.is_error,
1515 uint8_vector); 1500 uint8_vector);
1516 Respond(NoArguments()); 1501 Respond(NoArguments());
1517 } 1502 }
1518 1503
1519 } // namespace api 1504 } // namespace api
1520 } // namespace extensions 1505 } // namespace extensions
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698