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

Side by Side Diff: chrome/browser/extensions/api/socket/socket_api.cc

Issue 10168021: Pass through readInfo.resultCode. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Improve test. Created 8 years, 8 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 unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « no previous file | chrome/common/extensions/api/experimental.socket.idl » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "chrome/browser/extensions/api/socket/socket_api.h" 5 #include "chrome/browser/extensions/api/socket/socket_api.h"
6 6
7 #include "base/bind.h" 7 #include "base/bind.h"
8 #include "chrome/browser/extensions/api/api_resource_controller.h" 8 #include "chrome/browser/extensions/api/api_resource_controller.h"
9 #include "chrome/browser/extensions/api/socket/socket.h" 9 #include "chrome/browser/extensions/api/socket/socket.h"
10 #include "chrome/browser/extensions/api/socket/tcp_socket.h" 10 #include "chrome/browser/extensions/api/socket/tcp_socket.h"
11 #include "chrome/browser/extensions/api/socket/udp_socket.h" 11 #include "chrome/browser/extensions/api/socket/udp_socket.h"
12 #include "chrome/browser/extensions/extension_service.h" 12 #include "chrome/browser/extensions/extension_service.h"
13 #include "net/base/io_buffer.h" 13 #include "net/base/io_buffer.h"
14 14
15 namespace extensions { 15 namespace extensions {
16 16
17 const char kBytesWrittenKey[] = "bytesWritten"; 17 const char kBytesWrittenKey[] = "bytesWritten";
18 const char kDataKey[] = "data"; 18 const char kDataKey[] = "data";
19 const char kResultCodeKey[] = "resultCode";
19 const char kSocketIdKey[] = "socketId"; 20 const char kSocketIdKey[] = "socketId";
20 const char kTCPOption[] = "tcp"; 21 const char kTCPOption[] = "tcp";
21 const char kUDPOption[] = "udp"; 22 const char kUDPOption[] = "udp";
22 23
23 const char kSocketNotFoundError[] = "Socket not found"; 24 const char kSocketNotFoundError[] = "Socket not found";
24 25
25 SocketCreateFunction::SocketCreateFunction() 26 SocketCreateFunction::SocketCreateFunction()
26 : src_id_(-1), event_notifier_(NULL) { 27 : src_id_(-1), event_notifier_(NULL) {
27 } 28 }
28 29
(...skipping 111 matching lines...) Expand 10 before | Expand all | Expand 10 after
140 // this is short-term code, to be replaced with ArrayBuffer code. 141 // this is short-term code, to be replaced with ArrayBuffer code.
141 DictionaryValue* result = new DictionaryValue(); 142 DictionaryValue* result = new DictionaryValue();
142 ListValue* data_value = new ListValue(); 143 ListValue* data_value = new ListValue();
143 if (bytes_read > 0) { 144 if (bytes_read > 0) {
144 size_t bytes_size = static_cast<size_t>(bytes_read); 145 size_t bytes_size = static_cast<size_t>(bytes_read);
145 const char* io_buffer_start = io_buffer->data(); 146 const char* io_buffer_start = io_buffer->data();
146 for (size_t i = 0; i < bytes_size; ++i) { 147 for (size_t i = 0; i < bytes_size; ++i) {
147 data_value->Set(i, Value::CreateIntegerValue(io_buffer_start[i])); 148 data_value->Set(i, Value::CreateIntegerValue(io_buffer_start[i]));
148 } 149 }
149 } 150 }
151 result->SetInteger(kResultCodeKey, bytes_read);
150 result->Set(kDataKey, data_value); 152 result->Set(kDataKey, data_value);
151 result_.reset(result); 153 result_.reset(result);
152 } 154 }
153 155
154 bool SocketReadFunction::Respond() { 156 bool SocketReadFunction::Respond() {
155 return true; 157 return true;
156 } 158 }
157 159
158 SocketWriteFunction::SocketWriteFunction() 160 SocketWriteFunction::SocketWriteFunction()
159 : socket_id_(0), 161 : socket_id_(0),
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after
196 DictionaryValue* result = new DictionaryValue(); 198 DictionaryValue* result = new DictionaryValue();
197 result->SetInteger(kBytesWrittenKey, bytes_written); 199 result->SetInteger(kBytesWrittenKey, bytes_written);
198 result_.reset(result); 200 result_.reset(result);
199 } 201 }
200 202
201 bool SocketWriteFunction::Respond() { 203 bool SocketWriteFunction::Respond() {
202 return true; 204 return true;
203 } 205 }
204 206
205 } // namespace extensions 207 } // namespace extensions
OLDNEW
« no previous file with comments | « no previous file | chrome/common/extensions/api/experimental.socket.idl » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698