| OLD | NEW |
| 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/hid/hid_api.h" | 5 #include "extensions/browser/api/hid/hid_api.h" |
| 6 | 6 |
| 7 #include <stdint.h> | 7 #include <stdint.h> |
| 8 | 8 |
| 9 #include <string> | 9 #include <string> |
| 10 #include <utility> | 10 #include <utility> |
| (...skipping 17 matching lines...) Expand all Loading... |
| 28 // | 28 // |
| 29 // With C++11, this is problematic since a smart pointer that uses explicit | 29 // With C++11, this is problematic since a smart pointer that uses explicit |
| 30 // operator bool won't allow this conversion, since it's not in a context (such | 30 // operator bool won't allow this conversion, since it's not in a context (such |
| 31 // as a conditional) where a contextual conversion to bool would be allowed. | 31 // as a conditional) where a contextual conversion to bool would be allowed. |
| 32 // TODO(rdevlin.cronin): restructure this code to remove the need for the | 32 // TODO(rdevlin.cronin): restructure this code to remove the need for the |
| 33 // additional macro. | 33 // additional macro. |
| 34 #ifdef NDEBUG | 34 #ifdef NDEBUG |
| 35 #define EXTENSION_FUNCTION_VALIDATE_RETURN_FALSE_ON_ERROR(test) \ | 35 #define EXTENSION_FUNCTION_VALIDATE_RETURN_FALSE_ON_ERROR(test) \ |
| 36 do { \ | 36 do { \ |
| 37 if (!(test)) { \ | 37 if (!(test)) { \ |
| 38 this->bad_message_ = true; \ | 38 this->set_bad_message(true); \ |
| 39 return false; \ | 39 return false; \ |
| 40 } \ | 40 } \ |
| 41 } while (0) | 41 } while (0) |
| 42 #else // NDEBUG | 42 #else // NDEBUG |
| 43 #define EXTENSION_FUNCTION_VALIDATE_RETURN_FALSE_ON_ERROR(test) CHECK(test) | 43 #define EXTENSION_FUNCTION_VALIDATE_RETURN_FALSE_ON_ERROR(test) CHECK(test) |
| 44 #endif // NDEBUG | 44 #endif // NDEBUG |
| 45 | 45 |
| 46 namespace hid = extensions::api::hid; | 46 namespace hid = extensions::api::hid; |
| 47 | 47 |
| 48 using device::HidConnection; | 48 using device::HidConnection; |
| (...skipping 194 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 243 return RespondNow(NoArguments()); | 243 return RespondNow(NoArguments()); |
| 244 } | 244 } |
| 245 | 245 |
| 246 HidConnectionIoFunction::HidConnectionIoFunction() { | 246 HidConnectionIoFunction::HidConnectionIoFunction() { |
| 247 } | 247 } |
| 248 | 248 |
| 249 HidConnectionIoFunction::~HidConnectionIoFunction() { | 249 HidConnectionIoFunction::~HidConnectionIoFunction() { |
| 250 } | 250 } |
| 251 | 251 |
| 252 ExtensionFunction::ResponseAction HidConnectionIoFunction::Run() { | 252 ExtensionFunction::ResponseAction HidConnectionIoFunction::Run() { |
| 253 if (!ValidateParameters()) { | 253 EXTENSION_FUNCTION_VALIDATE(ValidateParameters()); |
| 254 return RespondNow(Error(error_)); | |
| 255 } | |
| 256 | 254 |
| 257 ApiResourceManager<HidConnectionResource>* connection_manager = | 255 ApiResourceManager<HidConnectionResource>* connection_manager = |
| 258 ApiResourceManager<HidConnectionResource>::Get(browser_context()); | 256 ApiResourceManager<HidConnectionResource>::Get(browser_context()); |
| 259 CHECK(connection_manager); | 257 CHECK(connection_manager); |
| 260 | 258 |
| 261 HidConnectionResource* resource = | 259 HidConnectionResource* resource = |
| 262 connection_manager->Get(extension_id(), connection_id_); | 260 connection_manager->Get(extension_id(), connection_id_); |
| 263 if (!resource) { | 261 if (!resource) { |
| 264 return RespondNow(Error(kErrorConnectionNotFound)); | 262 return RespondNow(Error(kErrorConnectionNotFound)); |
| 265 } | 263 } |
| (...skipping 114 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 380 | 378 |
| 381 void HidSendFeatureReportFunction::OnFinished(bool success) { | 379 void HidSendFeatureReportFunction::OnFinished(bool success) { |
| 382 if (success) { | 380 if (success) { |
| 383 Respond(NoArguments()); | 381 Respond(NoArguments()); |
| 384 } else { | 382 } else { |
| 385 Respond(Error(kErrorTransfer)); | 383 Respond(Error(kErrorTransfer)); |
| 386 } | 384 } |
| 387 } | 385 } |
| 388 | 386 |
| 389 } // namespace extensions | 387 } // namespace extensions |
| OLD | NEW |