Chromium Code Reviews| Index: 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 ce400e52555c92c8b066844f108681bec9f28690..adbc5e96751193936122dbd7eb13e01bdaeb38ab 100644 |
| --- a/chrome/browser/extensions/api/socket/socket_api.cc |
| +++ b/chrome/browser/extensions/api/socket/socket_api.cc |
| @@ -120,13 +120,16 @@ bool SocketCreateFunction::Prepare() { |
| params_ = api::socket::Create::Params::Create(*args_); |
| EXTENSION_FUNCTION_VALIDATE(params_.get()); |
| - if (params_->type == kTCPOption) { |
| + std::string type = kUnknown; |
| + scoped_ptr<base::Value> type_value(extensions::api::socket::CreateEnumValue( |
| + params_->type)); |
| + if (type_value.get()) |
| + type_value->GetAsString(&type); |
| + |
| + if (type == kTCPOption) { |
|
not at google - send to devlin
2012/09/14 01:44:51
etc
cduvall
2012/09/17 22:07:46
Done.
|
| socket_type_ = kSocketTypeTCP; |
| - } else if (params_->type == kUDPOption) { |
| + } else if (type == kUDPOption) { |
| socket_type_ = kSocketTypeUDP; |
| - } else { |
| - error_ = kSocketTypeInvalidError; |
| - return false; |
| } |
| if (params_->options.get()) { |
| scoped_ptr<DictionaryValue> options = params_->options->ToValue(); |
| @@ -534,18 +537,10 @@ void SocketGetInfoFunction::Work() { |
| if (socket) { |
| // This represents what we know about the socket, and does not call through |
| // to the system. |
| - switch (socket->GetSocketType()) { |
| - case Socket::TYPE_TCP: |
| - info.socket_type = kTCPOption; |
| - break; |
| - case Socket::TYPE_UDP: |
| - info.socket_type = kUDPOption; |
| - break; |
| - default: |
| - NOTREACHED() << "Unknown socket type."; |
| - info.socket_type = kUnknown; |
| - break; |
| - } |
| + if (socket->GetSocketType() == Socket::TYPE_TCP) |
| + info.socket_type = extensions::api::socket::SOCKETTYPE_TCP; |
| + else |
| + info.socket_type = extensions::api::socket::SOCKETTYPE_UDP; |
| info.connected = socket->IsConnected(); |
| // Grab the peer address as known by the OS. This and the call below will |