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

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

Issue 8896013: Implement onEvent callback framework for UDP (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Put back the bracket. Created 9 years 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 f2cf86c0b1422d008d0171d5563817e7fcf40b5c..4a54978232eba6c2d7c471799377cbc1c116eb4e 100644
--- a/chrome/browser/extensions/api/socket/socket_api.cc
+++ b/chrome/browser/extensions/api/socket/socket_api.cc
@@ -49,10 +49,26 @@ void SocketApiFunction::RespondOnUIThread() {
SendResponse(Respond());
}
+SocketCreateFunction::SocketCreateFunction()
+ : src_id_(-1) {}
+
bool SocketCreateFunction::Prepare() {
std::string socket_type;
EXTENSION_FUNCTION_VALIDATE(args_->GetString(0, &socket_type));
+ scoped_ptr<DictionaryValue> options(new DictionaryValue());
+ if (args_->GetSize() >= 2) {
+ DictionaryValue* temp_options = NULL;
+ if (args_->GetDictionary(1, &temp_options))
+ options.reset(temp_options->DeepCopy());
+ }
+
+ // If we tacked on a srcId to the options object, pull it out here to provide
+ // to the Socket.
+ if (options->HasKey(kSrcIdKey)) {
+ EXTENSION_FUNCTION_VALIDATE(options->GetInteger(kSrcIdKey, &src_id_));
+ }
+
// TODO(miket): this constitutes a second form of truth as to the enum
// validity. But our unit-test framework skips the enum validation. So in
// order to get an invalid-enum test to pass, we need duplicative
@@ -66,7 +82,7 @@ bool SocketCreateFunction::Prepare() {
void SocketCreateFunction::Work() {
DictionaryValue* result = new DictionaryValue();
- int socket_id = controller()->CreateUdp(profile(), extension_id(),
+ int socket_id = controller()->CreateUdp(profile(), extension_id(), src_id_,
source_url());
result->SetInteger(kSocketIdKey, socket_id);
result_.reset(result);
« no previous file with comments | « chrome/browser/extensions/api/socket/socket_api.h ('k') | chrome/browser/extensions/api/socket/socket_api_controller.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698