OLD | NEW |
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/browser_process.h" | 8 #include "chrome/browser/browser_process.h" |
9 #include "chrome/browser/extensions/api/dns/host_resolver_wrapper.h" | 9 #include "chrome/browser/extensions/api/dns/host_resolver_wrapper.h" |
10 #include "chrome/browser/extensions/api/socket/socket.h" | 10 #include "chrome/browser/extensions/api/socket/socket.h" |
(...skipping 330 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
341 result->SetString(kAddressKey, address); | 341 result->SetString(kAddressKey, address); |
342 result->SetInteger(kPortKey, port); | 342 result->SetInteger(kPortKey, port); |
343 SetResult(result); | 343 SetResult(result); |
344 | 344 |
345 AsyncWorkCompleted(); | 345 AsyncWorkCompleted(); |
346 } | 346 } |
347 | 347 |
348 SocketSendToFunction::SocketSendToFunction() | 348 SocketSendToFunction::SocketSendToFunction() |
349 : socket_id_(0), | 349 : socket_id_(0), |
350 io_buffer_(NULL), | 350 io_buffer_(NULL), |
351 io_buffer_size_(0) { | 351 io_buffer_size_(0), |
| 352 port_(0) { |
352 } | 353 } |
353 | 354 |
354 SocketSendToFunction::~SocketSendToFunction() {} | 355 SocketSendToFunction::~SocketSendToFunction() {} |
355 | 356 |
356 bool SocketSendToFunction::Prepare() { | 357 bool SocketSendToFunction::Prepare() { |
357 EXTENSION_FUNCTION_VALIDATE(args_->GetInteger(0, &socket_id_)); | 358 EXTENSION_FUNCTION_VALIDATE(args_->GetInteger(0, &socket_id_)); |
358 base::BinaryValue *data = NULL; | 359 base::BinaryValue *data = NULL; |
359 EXTENSION_FUNCTION_VALIDATE(args_->GetBinary(1, &data)); | 360 EXTENSION_FUNCTION_VALIDATE(args_->GetBinary(1, &data)); |
360 EXTENSION_FUNCTION_VALIDATE(args_->GetString(2, &hostname_)); | 361 EXTENSION_FUNCTION_VALIDATE(args_->GetString(2, &hostname_)); |
361 EXTENSION_FUNCTION_VALIDATE(args_->GetInteger(3, &port_)); | 362 EXTENSION_FUNCTION_VALIDATE(args_->GetInteger(3, &port_)); |
(...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
440 bool result = false; | 441 bool result = false; |
441 Socket* socket = manager_->Get(params_->socket_id); | 442 Socket* socket = manager_->Get(params_->socket_id); |
442 if (socket) | 443 if (socket) |
443 result = socket->SetNoDelay(params_->no_delay); | 444 result = socket->SetNoDelay(params_->no_delay); |
444 else | 445 else |
445 error_ = kSocketNotFoundError; | 446 error_ = kSocketNotFoundError; |
446 SetResult(Value::CreateBooleanValue(result)); | 447 SetResult(Value::CreateBooleanValue(result)); |
447 } | 448 } |
448 | 449 |
449 } // namespace extensions | 450 } // namespace extensions |
OLD | NEW |