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

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

Issue 10071035: RefCounted types should not have public destructors, chrome/browser/extensions (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Compile fix 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
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 #include "net/base/ip_endpoint.h" 14 #include "net/base/ip_endpoint.h"
15 15
16 namespace extensions { 16 namespace extensions {
17 17
18 const char kAddressKey[] = "address"; 18 const char kAddressKey[] = "address";
19 const char kPortKey[] = "port"; 19 const char kPortKey[] = "port";
20 const char kBytesWrittenKey[] = "bytesWritten"; 20 const char kBytesWrittenKey[] = "bytesWritten";
21 const char kDataKey[] = "data"; 21 const char kDataKey[] = "data";
22 const char kResultCodeKey[] = "resultCode"; 22 const char kResultCodeKey[] = "resultCode";
23 const char kSocketIdKey[] = "socketId"; 23 const char kSocketIdKey[] = "socketId";
24 const char kTCPOption[] = "tcp"; 24 const char kTCPOption[] = "tcp";
25 const char kUDPOption[] = "udp"; 25 const char kUDPOption[] = "udp";
26 26
27 const char kSocketNotFoundError[] = "Socket not found"; 27 const char kSocketNotFoundError[] = "Socket not found";
28 28
29 SocketCreateFunction::SocketCreateFunction() 29 SocketCreateFunction::SocketCreateFunction()
30 : src_id_(-1), event_notifier_(NULL) { 30 : src_id_(-1),
31 event_notifier_(NULL) {
31 } 32 }
32 33
34 SocketCreateFunction::~SocketCreateFunction() {}
35
33 bool SocketCreateFunction::Prepare() { 36 bool SocketCreateFunction::Prepare() {
34 std::string socket_type_string; 37 std::string socket_type_string;
35 EXTENSION_FUNCTION_VALIDATE(args_->GetString(0, &socket_type_string)); 38 EXTENSION_FUNCTION_VALIDATE(args_->GetString(0, &socket_type_string));
36 if (socket_type_string == kTCPOption) 39 if (socket_type_string == kTCPOption)
37 socket_type_ = kSocketTypeTCP; 40 socket_type_ = kSocketTypeTCP;
38 else if (socket_type_string == kUDPOption) 41 else if (socket_type_string == kUDPOption)
39 socket_type_ = kSocketTypeUDP; 42 socket_type_ = kSocketTypeUDP;
40 else 43 else
41 return false; 44 return false;
42 45
(...skipping 132 matching lines...) Expand 10 before | Expand all | Expand 10 after
175 178
176 bool SocketReadFunction::Respond() { 179 bool SocketReadFunction::Respond() {
177 return true; 180 return true;
178 } 181 }
179 182
180 SocketWriteFunction::SocketWriteFunction() 183 SocketWriteFunction::SocketWriteFunction()
181 : socket_id_(0), 184 : socket_id_(0),
182 io_buffer_(NULL) { 185 io_buffer_(NULL) {
183 } 186 }
184 187
185 SocketWriteFunction::~SocketWriteFunction() { 188 SocketWriteFunction::~SocketWriteFunction() {}
186 }
187 189
188 bool SocketWriteFunction::Prepare() { 190 bool SocketWriteFunction::Prepare() {
189 EXTENSION_FUNCTION_VALIDATE(args_->GetInteger(0, &socket_id_)); 191 EXTENSION_FUNCTION_VALIDATE(args_->GetInteger(0, &socket_id_));
190 base::ListValue* data_list_value = NULL; 192 base::ListValue* data_list_value = NULL;
191 EXTENSION_FUNCTION_VALIDATE(args_->GetList(1, &data_list_value)); 193 EXTENSION_FUNCTION_VALIDATE(args_->GetList(1, &data_list_value));
192 194
193 size_t size = data_list_value->GetSize(); 195 size_t size = data_list_value->GetSize();
194 if (size != 0) { 196 if (size != 0) {
195 io_buffer_ = new net::IOBufferWithSize(size); 197 io_buffer_ = new net::IOBufferWithSize(size);
196 uint8* data_buffer = 198 uint8* data_buffer =
(...skipping 20 matching lines...) Expand all
217 219
218 DictionaryValue* result = new DictionaryValue(); 220 DictionaryValue* result = new DictionaryValue();
219 result->SetInteger(kBytesWrittenKey, bytes_written); 221 result->SetInteger(kBytesWrittenKey, bytes_written);
220 result_.reset(result); 222 result_.reset(result);
221 } 223 }
222 224
223 bool SocketWriteFunction::Respond() { 225 bool SocketWriteFunction::Respond() {
224 return true; 226 return true;
225 } 227 }
226 228
229 SocketRecvFromFunction::~SocketRecvFromFunction() {}
230
227 bool SocketRecvFromFunction::Prepare() { 231 bool SocketRecvFromFunction::Prepare() {
228 EXTENSION_FUNCTION_VALIDATE(args_->GetInteger(0, &socket_id_)); 232 EXTENSION_FUNCTION_VALIDATE(args_->GetInteger(0, &socket_id_));
229 return true; 233 return true;
230 } 234 }
231 235
232 void SocketRecvFromFunction::Work() { 236 void SocketRecvFromFunction::Work() {
233 // TODO(miket): this is an arbitrary number. Can we come up with one that 237 // TODO(miket): this is an arbitrary number. Can we come up with one that
234 // makes sense? 238 // makes sense?
235 const int buffer_len = 2048; 239 const int buffer_len = 2048;
236 scoped_refptr<net::IOBuffer> io_buffer(new net::IOBuffer(buffer_len)); 240 scoped_refptr<net::IOBuffer> io_buffer(new net::IOBuffer(buffer_len));
(...skipping 29 matching lines...) Expand all
266 270
267 bool SocketRecvFromFunction::Respond() { 271 bool SocketRecvFromFunction::Respond() {
268 return true; 272 return true;
269 } 273 }
270 274
271 SocketSendToFunction::SocketSendToFunction() 275 SocketSendToFunction::SocketSendToFunction()
272 : socket_id_(0), 276 : socket_id_(0),
273 io_buffer_(NULL) { 277 io_buffer_(NULL) {
274 } 278 }
275 279
276 SocketSendToFunction::~SocketSendToFunction() { 280 SocketSendToFunction::~SocketSendToFunction() {}
277 }
278 281
279 bool SocketSendToFunction::Prepare() { 282 bool SocketSendToFunction::Prepare() {
280 EXTENSION_FUNCTION_VALIDATE(args_->GetInteger(0, &socket_id_)); 283 EXTENSION_FUNCTION_VALIDATE(args_->GetInteger(0, &socket_id_));
281 base::ListValue *data_list_value; 284 base::ListValue *data_list_value;
282 EXTENSION_FUNCTION_VALIDATE(args_->GetList(1, &data_list_value)); 285 EXTENSION_FUNCTION_VALIDATE(args_->GetList(1, &data_list_value));
283 EXTENSION_FUNCTION_VALIDATE(args_->GetString(2, &address_)); 286 EXTENSION_FUNCTION_VALIDATE(args_->GetString(2, &address_));
284 EXTENSION_FUNCTION_VALIDATE(args_->GetInteger(3, &port_)); 287 EXTENSION_FUNCTION_VALIDATE(args_->GetInteger(3, &port_));
285 288
286 size_t size = data_list_value->GetSize(); 289 size_t size = data_list_value->GetSize();
287 if (size != 0) { 290 if (size != 0) {
(...skipping 25 matching lines...) Expand all
313 DictionaryValue* result = new DictionaryValue(); 316 DictionaryValue* result = new DictionaryValue();
314 result->SetInteger(kBytesWrittenKey, bytes_written); 317 result->SetInteger(kBytesWrittenKey, bytes_written);
315 result_.reset(result); 318 result_.reset(result);
316 } 319 }
317 320
318 bool SocketSendToFunction::Respond() { 321 bool SocketSendToFunction::Respond() {
319 return true; 322 return true;
320 } 323 }
321 324
322 } // namespace extensions 325 } // namespace extensions
OLDNEW
« no previous file with comments | « chrome/browser/extensions/api/socket/socket_api.h ('k') | chrome/browser/extensions/api/socket/tcp_socket_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698