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

Unified Diff: chrome/browser/extensions/api/socket/socket_api.cc

Issue 10907151: Extensions Docs Server: Enum values do not show up if enum is a type (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: ToString and FromString Created 8 years, 3 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 side-by-side diff with in-line comments
Download patch
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..269d0d7a3206e8fd1504de91a99fc0f670a795df 100644
--- a/chrome/browser/extensions/api/socket/socket_api.cc
+++ b/chrome/browser/extensions/api/socket/socket_api.cc
@@ -120,13 +120,14 @@ bool SocketCreateFunction::Prepare() {
params_ = api::socket::Create::Params::Create(*args_);
EXTENSION_FUNCTION_VALIDATE(params_.get());
- if (params_->type == kTCPOption) {
+ std::string type = extensions::api::socket::ToString(params_->type);
+ if (type.empty())
+ type = kUnknown;
not at google - send to devlin 2012/09/18 03:55:20 going to string here is actually unnecessary, you
cduvall 2012/09/21 00:39:28 Done.
+
+ if (type == kTCPOption) {
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 +535,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::SOCKET_SOCKET_TYPE_TCP;
+ else
+ info.socket_type = extensions::api::socket::SOCKET_SOCKET_TYPE_UDP;
info.connected = socket->IsConnected();
// Grab the peer address as known by the OS. This and the call below will

Powered by Google App Engine
This is Rietveld 408576698