summaryrefslogtreecommitdiffstats
path: root/extensions/browser/api
diff options
context:
space:
mode:
authordcheng <dcheng@chromium.org>2016-03-03 14:09:15 -0800
committerCommit bot <commit-bot@chromium.org>2016-03-03 22:10:20 +0000
commit6e5c22f946c8713f3a585e54b40954d770402579 (patch)
tree3e68b77dcca4c3ce77008122c4aa3671b8634067 /extensions/browser/api
parent60d08d73239ed483f80d19a34954560daac392e8 (diff)
downloadchromium_src-6e5c22f946c8713f3a585e54b40954d770402579.zip
chromium_src-6e5c22f946c8713f3a585e54b40954d770402579.tar.gz
chromium_src-6e5c22f946c8713f3a585e54b40954d770402579.tar.bz2
Change scoped_ptr to be a type alias for std::unique_ptr on OS_LINUX.
BUG=554298,579269,579270 R=danakj@chromium.org,ddorwin@chromium.org,lcwu@chromium.org,rdvelin.cronin@chromium.org,satorux@chromium.org TBR=thakis@chromium.org,yoshiki@chromium.org Review URL: https://codereview.chromium.org/1750143004 Cr-Commit-Position: refs/heads/master@{#379108}
Diffstat (limited to 'extensions/browser/api')
-rw-r--r--extensions/browser/api/hid/hid_api.cc29
-rw-r--r--extensions/browser/api/webcam_private/webcam_private_api_chromeos.cc3
2 files changed, 27 insertions, 5 deletions
diff --git a/extensions/browser/api/hid/hid_api.cc b/extensions/browser/api/hid/hid_api.cc
index 59e2bfb..77972ea 100644
--- a/extensions/browser/api/hid/hid_api.cc
+++ b/extensions/browser/api/hid/hid_api.cc
@@ -20,6 +20,27 @@
#include "extensions/common/api/hid.h"
#include "net/base/io_buffer.h"
+// The normal EXTENSION_FUNCTION_VALIDATE macro doesn't work well here. It's
+// used in functions that returns a bool. However, EXTENSION_FUNCTION_VALIDATE
+// returns a smart pointer on failure.
+//
+// With C++11, this is problematic since a smart pointer that uses explicit
+// operator bool won't allow this conversion, since it's not in a context (such
+// as a conditional) where a contextual conversion to bool would be allowed.
+// TODO(rdevlin.cronin): restructure this code to remove the need for the
+// additional macro.
+#ifdef NDEBUG
+#define EXTENSION_FUNCTION_VALIDATE_RETURN_FALSE_ON_ERROR(test) \
+ do { \
+ if (!(test)) { \
+ this->bad_message_ = true; \
+ return false; \
+ } \
+ } while (0)
+#else // NDEBUG
+#define EXTENSION_FUNCTION_VALIDATE_RETURN_FALSE_ON_ERROR(test) CHECK(test)
+#endif // NDEBUG
+
namespace hid = extensions::api::hid;
using device::HidConnection;
@@ -250,7 +271,7 @@ HidReceiveFunction::~HidReceiveFunction() {}
bool HidReceiveFunction::ValidateParameters() {
parameters_ = hid::Receive::Params::Create(*args_);
- EXTENSION_FUNCTION_VALIDATE(parameters_);
+ EXTENSION_FUNCTION_VALIDATE_RETURN_FALSE_ON_ERROR(parameters_);
set_connection_id(parameters_->connection_id);
return true;
}
@@ -280,7 +301,7 @@ HidSendFunction::~HidSendFunction() {}
bool HidSendFunction::ValidateParameters() {
parameters_ = hid::Send::Params::Create(*args_);
- EXTENSION_FUNCTION_VALIDATE(parameters_);
+ EXTENSION_FUNCTION_VALIDATE_RETURN_FALSE_ON_ERROR(parameters_);
set_connection_id(parameters_->connection_id);
return true;
}
@@ -309,7 +330,7 @@ HidReceiveFeatureReportFunction::~HidReceiveFeatureReportFunction() {}
bool HidReceiveFeatureReportFunction::ValidateParameters() {
parameters_ = hid::ReceiveFeatureReport::Params::Create(*args_);
- EXTENSION_FUNCTION_VALIDATE(parameters_);
+ EXTENSION_FUNCTION_VALIDATE_RETURN_FALSE_ON_ERROR(parameters_);
set_connection_id(parameters_->connection_id);
return true;
}
@@ -338,7 +359,7 @@ HidSendFeatureReportFunction::~HidSendFeatureReportFunction() {}
bool HidSendFeatureReportFunction::ValidateParameters() {
parameters_ = hid::SendFeatureReport::Params::Create(*args_);
- EXTENSION_FUNCTION_VALIDATE(parameters_);
+ EXTENSION_FUNCTION_VALIDATE_RETURN_FALSE_ON_ERROR(parameters_);
set_connection_id(parameters_->connection_id);
return true;
}
diff --git a/extensions/browser/api/webcam_private/webcam_private_api_chromeos.cc b/extensions/browser/api/webcam_private/webcam_private_api_chromeos.cc
index 02edcfa..31e381b 100644
--- a/extensions/browser/api/webcam_private/webcam_private_api_chromeos.cc
+++ b/extensions/browser/api/webcam_private/webcam_private_api_chromeos.cc
@@ -408,7 +408,8 @@ bool WebcamPrivateResetFunction::RunAsync() {
return false;
}
- webcam->Reset(params->config.pan, params->config.tilt, params->config.zoom,
+ webcam->Reset(params->config.pan != nullptr, params->config.tilt != nullptr,
+ params->config.zoom != nullptr,
base::Bind(&WebcamPrivateResetFunction::OnResetWebcam, this));
return true;