| OLD | NEW |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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 "extensions/browser/api/socket/socket_api.h" | 5 #include "extensions/browser/api/socket/socket_api.h" |
| 6 | 6 |
| 7 #include <vector> | 7 #include <vector> |
| 8 | 8 |
| 9 #include "base/bind.h" | 9 #include "base/bind.h" |
| 10 #include "base/containers/hash_tables.h" | 10 #include "base/containers/hash_tables.h" |
| (...skipping 332 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 343 | 343 |
| 344 void SocketDisconnectFunction::Work() { | 344 void SocketDisconnectFunction::Work() { |
| 345 Socket* socket = GetSocket(socket_id_); | 345 Socket* socket = GetSocket(socket_id_); |
| 346 if (socket) | 346 if (socket) |
| 347 socket->Disconnect(); | 347 socket->Disconnect(); |
| 348 else | 348 else |
| 349 error_ = kSocketNotFoundError; | 349 error_ = kSocketNotFoundError; |
| 350 SetResult(base::Value::CreateNullValue()); | 350 SetResult(base::Value::CreateNullValue()); |
| 351 } | 351 } |
| 352 | 352 |
| 353 SocketBindFunction::SocketBindFunction() = default; |
| 354 |
| 353 bool SocketBindFunction::Prepare() { | 355 bool SocketBindFunction::Prepare() { |
| 354 EXTENSION_FUNCTION_VALIDATE(args_->GetInteger(0, &socket_id_)); | 356 EXTENSION_FUNCTION_VALIDATE(args_->GetInteger(0, &socket_id_)); |
| 355 EXTENSION_FUNCTION_VALIDATE(args_->GetString(1, &address_)); | 357 EXTENSION_FUNCTION_VALIDATE(args_->GetString(1, &address_)); |
| 356 int port; | 358 int port; |
| 357 EXTENSION_FUNCTION_VALIDATE( | 359 EXTENSION_FUNCTION_VALIDATE( |
| 358 args_->GetInteger(2, &port) && port >= 0 && port <= 65535); | 360 args_->GetInteger(2, &port) && port >= 0 && port <= 65535); |
| 359 port_ = static_cast<uint16>(port); | 361 port_ = static_cast<uint16>(port); |
| 360 return true; | 362 return true; |
| 361 } | 363 } |
| 362 | 364 |
| (...skipping 703 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1066 } else { | 1068 } else { |
| 1067 RemoveSocket(params_->socket_id); | 1069 RemoveSocket(params_->socket_id); |
| 1068 error_ = net::ErrorToString(result); | 1070 error_ = net::ErrorToString(result); |
| 1069 } | 1071 } |
| 1070 | 1072 |
| 1071 results_ = api::socket::Secure::Results::Create(result); | 1073 results_ = api::socket::Secure::Results::Create(result); |
| 1072 AsyncWorkCompleted(); | 1074 AsyncWorkCompleted(); |
| 1073 } | 1075 } |
| 1074 | 1076 |
| 1075 } // namespace extensions | 1077 } // namespace extensions |
| OLD | NEW |