| 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 <memory> | 7 #include <memory> |
| 8 #include <utility> | 8 #include <utility> |
| 9 #include <vector> | 9 #include <vector> |
| 10 | 10 |
| (...skipping 344 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 355 EXTENSION_FUNCTION_VALIDATE(args_->GetInteger(0, &socket_id_)); | 355 EXTENSION_FUNCTION_VALIDATE(args_->GetInteger(0, &socket_id_)); |
| 356 return true; | 356 return true; |
| 357 } | 357 } |
| 358 | 358 |
| 359 void SocketDisconnectFunction::Work() { | 359 void SocketDisconnectFunction::Work() { |
| 360 Socket* socket = GetSocket(socket_id_); | 360 Socket* socket = GetSocket(socket_id_); |
| 361 if (socket) | 361 if (socket) |
| 362 socket->Disconnect(false /* socket_destroying */); | 362 socket->Disconnect(false /* socket_destroying */); |
| 363 else | 363 else |
| 364 error_ = kSocketNotFoundError; | 364 error_ = kSocketNotFoundError; |
| 365 SetResult(base::Value::CreateNullValue()); | 365 SetResult(base::MakeUnique<base::Value>()); |
| 366 } | 366 } |
| 367 | 367 |
| 368 bool SocketBindFunction::Prepare() { | 368 bool SocketBindFunction::Prepare() { |
| 369 EXTENSION_FUNCTION_VALIDATE(args_->GetInteger(0, &socket_id_)); | 369 EXTENSION_FUNCTION_VALIDATE(args_->GetInteger(0, &socket_id_)); |
| 370 EXTENSION_FUNCTION_VALIDATE(args_->GetString(1, &address_)); | 370 EXTENSION_FUNCTION_VALIDATE(args_->GetString(1, &address_)); |
| 371 int port; | 371 int port; |
| 372 EXTENSION_FUNCTION_VALIDATE(args_->GetInteger(2, &port)); | 372 EXTENSION_FUNCTION_VALIDATE(args_->GetInteger(2, &port)); |
| 373 if (!IsPortValid(port)) { | 373 if (!IsPortValid(port)) { |
| 374 error_ = kPortInvalidError; | 374 error_ = kPortInvalidError; |
| 375 return false; | 375 return false; |
| (...skipping 713 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1089 } else { | 1089 } else { |
| 1090 RemoveSocket(params_->socket_id); | 1090 RemoveSocket(params_->socket_id); |
| 1091 error_ = net::ErrorToString(result); | 1091 error_ = net::ErrorToString(result); |
| 1092 } | 1092 } |
| 1093 | 1093 |
| 1094 results_ = api::socket::Secure::Results::Create(result); | 1094 results_ = api::socket::Secure::Results::Create(result); |
| 1095 AsyncWorkCompleted(); | 1095 AsyncWorkCompleted(); |
| 1096 } | 1096 } |
| 1097 | 1097 |
| 1098 } // namespace extensions | 1098 } // namespace extensions |
| OLD | NEW |