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 125 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
136 | 136 |
137 bool SocketDestroyFunction::Prepare() { | 137 bool SocketDestroyFunction::Prepare() { |
138 EXTENSION_FUNCTION_VALIDATE(args_->GetInteger(0, &socket_id_)); | 138 EXTENSION_FUNCTION_VALIDATE(args_->GetInteger(0, &socket_id_)); |
139 return true; | 139 return true; |
140 } | 140 } |
141 | 141 |
142 void SocketDestroyFunction::Work() { | 142 void SocketDestroyFunction::Work() { |
143 manager_->Remove(socket_id_); | 143 manager_->Remove(socket_id_); |
144 } | 144 } |
145 | 145 |
146 SocketConnectFunction::SocketConnectFunction() { | 146 SocketConnectFunction::SocketConnectFunction() |
| 147 : socket_id_(0), |
| 148 port_(0) { |
147 } | 149 } |
148 | 150 |
149 SocketConnectFunction::~SocketConnectFunction() { | 151 SocketConnectFunction::~SocketConnectFunction() { |
150 } | 152 } |
151 | 153 |
152 bool SocketConnectFunction::Prepare() { | 154 bool SocketConnectFunction::Prepare() { |
153 EXTENSION_FUNCTION_VALIDATE(args_->GetInteger(0, &socket_id_)); | 155 EXTENSION_FUNCTION_VALIDATE(args_->GetInteger(0, &socket_id_)); |
154 EXTENSION_FUNCTION_VALIDATE(args_->GetString(1, &hostname_)); | 156 EXTENSION_FUNCTION_VALIDATE(args_->GetString(1, &hostname_)); |
155 EXTENSION_FUNCTION_VALIDATE(args_->GetInteger(2, &port_)); | 157 EXTENSION_FUNCTION_VALIDATE(args_->GetInteger(2, &port_)); |
156 return true; | 158 return true; |
(...skipping 284 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
441 bool result = false; | 443 bool result = false; |
442 Socket* socket = manager_->Get(params_->socket_id); | 444 Socket* socket = manager_->Get(params_->socket_id); |
443 if (socket) | 445 if (socket) |
444 result = socket->SetNoDelay(params_->no_delay); | 446 result = socket->SetNoDelay(params_->no_delay); |
445 else | 447 else |
446 error_ = kSocketNotFoundError; | 448 error_ = kSocketNotFoundError; |
447 SetResult(Value::CreateBooleanValue(result)); | 449 SetResult(Value::CreateBooleanValue(result)); |
448 } | 450 } |
449 | 451 |
450 } // namespace extensions | 452 } // namespace extensions |
OLD | NEW |