From 8c8359ee20b952a54b3afb105b021c6e79f49ba1 Mon Sep 17 00:00:00 2001 From: "miket@chromium.org" Date: Mon, 9 Jul 2012 16:59:04 +0000 Subject: Add bitrate option to serial API. - Migrate more code over to the new-style argument parsing code. - Fix some browser tests whose arguments didn't get updated with the socket.create() signature change. - Change default to 9600 bps. - Moved the sample Arduino sketch out of comments into a separate file. BUG=120508 TEST=added TBR=penghuang@chromium.org Review URL: https://chromiumcodereview.appspot.com/10694061 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@145684 0039d316-1c4b-4281-b951-d872f2087c98 --- chrome/browser/extensions/api/socket/socket_api.cc | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) (limited to 'chrome/browser/extensions/api/socket/socket_api.cc') diff --git a/chrome/browser/extensions/api/socket/socket_api.cc b/chrome/browser/extensions/api/socket/socket_api.cc index c870171..f7bae9e 100644 --- a/chrome/browser/extensions/api/socket/socket_api.cc +++ b/chrome/browser/extensions/api/socket/socket_api.cc @@ -92,19 +92,22 @@ SocketCreateFunction::SocketCreateFunction() SocketCreateFunction::~SocketCreateFunction() {} bool SocketCreateFunction::Prepare() { - std::string socket_type_string; - EXTENSION_FUNCTION_VALIDATE(args_->GetString(0, &socket_type_string)); - if (socket_type_string == kTCPOption) { + params_ = api::experimental_socket::Create::Params::Create(*args_); + EXTENSION_FUNCTION_VALIDATE(params_.get()); + + if (params_->type == kTCPOption) { socket_type_ = kSocketTypeTCP; - } else if (socket_type_string == kUDPOption) { + } else if (params_->type == kUDPOption) { socket_type_ = kSocketTypeUDP; } else { error_ = kSocketTypeInvalidError; return false; } - - src_id_ = ExtractSrcId(1); - event_notifier_ = CreateEventNotifier(src_id_); + if (params_->options.get()) { + scoped_ptr options = params_->options->ToValue(); + src_id_ = ExtractSrcId(options.get()); + event_notifier_ = CreateEventNotifier(src_id_); + } return true; } -- cgit v1.1