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

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

Issue 10388207: Reverting due to memory waterfall failures. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: Created 8 years, 7 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 | « base/values_unittest.cc ('k') | no next file » | 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"
(...skipping 155 matching lines...) Expand 10 before | Expand all | Expand 10 after
166 166
167 void SocketReadFunction::OnCompleted(int bytes_read, 167 void SocketReadFunction::OnCompleted(int bytes_read,
168 scoped_refptr<net::IOBuffer> io_buffer) { 168 scoped_refptr<net::IOBuffer> io_buffer) {
169 DictionaryValue* result = new DictionaryValue(); 169 DictionaryValue* result = new DictionaryValue();
170 result->SetInteger(kResultCodeKey, bytes_read); 170 result->SetInteger(kResultCodeKey, bytes_read);
171 if (bytes_read > 0) { 171 if (bytes_read > 0) {
172 result->Set(kDataKey, 172 result->Set(kDataKey,
173 base::BinaryValue::CreateWithCopiedBuffer(io_buffer->data(), 173 base::BinaryValue::CreateWithCopiedBuffer(io_buffer->data(),
174 bytes_read)); 174 bytes_read));
175 } else { 175 } else {
176 result->Set(kDataKey, new base::BinaryValue()); 176 // BinaryValue does not support NULL buffer. Workaround it with new char[1].
177 // http://crbug.com/127630
178 result->Set(kDataKey, base::BinaryValue::Create(new char[1], 0));
177 } 179 }
178 result_.reset(result); 180 result_.reset(result);
179 181
180 AsyncWorkCompleted(); 182 AsyncWorkCompleted();
181 } 183 }
182 184
183 SocketWriteFunction::SocketWriteFunction() 185 SocketWriteFunction::SocketWriteFunction()
184 : socket_id_(0), 186 : socket_id_(0),
185 io_buffer_(NULL), 187 io_buffer_(NULL),
186 io_buffer_size_(0) { 188 io_buffer_size_(0) {
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after
247 scoped_refptr<net::IOBuffer> io_buffer, 249 scoped_refptr<net::IOBuffer> io_buffer,
248 const std::string& address, 250 const std::string& address,
249 int port) { 251 int port) {
250 DictionaryValue* result = new DictionaryValue(); 252 DictionaryValue* result = new DictionaryValue();
251 result->SetInteger(kResultCodeKey, bytes_read); 253 result->SetInteger(kResultCodeKey, bytes_read);
252 if (bytes_read > 0) { 254 if (bytes_read > 0) {
253 result->Set(kDataKey, 255 result->Set(kDataKey,
254 base::BinaryValue::CreateWithCopiedBuffer(io_buffer->data(), 256 base::BinaryValue::CreateWithCopiedBuffer(io_buffer->data(),
255 bytes_read)); 257 bytes_read));
256 } else { 258 } else {
257 result->Set(kDataKey, new base::BinaryValue()); 259 // BinaryValue does not support NULL buffer. Workaround it with new char[1].
260 // http://crbug.com/127630
261 result->Set(kDataKey, base::BinaryValue::Create(new char[1], 0));
258 } 262 }
259 result->SetString(kAddressKey, address); 263 result->SetString(kAddressKey, address);
260 result->SetInteger(kPortKey, port); 264 result->SetInteger(kPortKey, port);
261 result_.reset(result); 265 result_.reset(result);
262 266
263 AsyncWorkCompleted(); 267 AsyncWorkCompleted();
264 } 268 }
265 269
266 SocketSendToFunction::SocketSendToFunction() 270 SocketSendToFunction::SocketSendToFunction()
267 : socket_id_(0), 271 : socket_id_(0),
(...skipping 29 matching lines...) Expand all
297 301
298 void SocketSendToFunction::OnCompleted(int bytes_written) { 302 void SocketSendToFunction::OnCompleted(int bytes_written) {
299 DictionaryValue* result = new DictionaryValue(); 303 DictionaryValue* result = new DictionaryValue();
300 result->SetInteger(kBytesWrittenKey, bytes_written); 304 result->SetInteger(kBytesWrittenKey, bytes_written);
301 result_.reset(result); 305 result_.reset(result);
302 306
303 AsyncWorkCompleted(); 307 AsyncWorkCompleted();
304 } 308 }
305 309
306 } // namespace extensions 310 } // namespace extensions
OLDNEW
« no previous file with comments | « base/values_unittest.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698