| 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/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" |
| (...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 73 result->SetInteger(kSocketIdKey, controller()->AddAPIResource(socket)); | 73 result->SetInteger(kSocketIdKey, controller()->AddAPIResource(socket)); |
| 74 result_.reset(result); | 74 result_.reset(result); |
| 75 } | 75 } |
| 76 | 76 |
| 77 bool SocketDestroyFunction::Prepare() { | 77 bool SocketDestroyFunction::Prepare() { |
| 78 EXTENSION_FUNCTION_VALIDATE(args_->GetInteger(0, &socket_id_)); | 78 EXTENSION_FUNCTION_VALIDATE(args_->GetInteger(0, &socket_id_)); |
| 79 return true; | 79 return true; |
| 80 } | 80 } |
| 81 | 81 |
| 82 void SocketDestroyFunction::Work() { | 82 void SocketDestroyFunction::Work() { |
| 83 if (!controller()->RemoveAPIResource(socket_id_)) | 83 if (!controller()->RemoveSocket(socket_id_)) |
| 84 error_ = kSocketNotFoundError; | 84 error_ = kSocketNotFoundError; |
| 85 } | 85 } |
| 86 | 86 |
| 87 bool SocketConnectFunction::Prepare() { | 87 bool SocketConnectFunction::Prepare() { |
| 88 EXTENSION_FUNCTION_VALIDATE(args_->GetInteger(0, &socket_id_)); | 88 EXTENSION_FUNCTION_VALIDATE(args_->GetInteger(0, &socket_id_)); |
| 89 EXTENSION_FUNCTION_VALIDATE(args_->GetString(1, &address_)); | 89 EXTENSION_FUNCTION_VALIDATE(args_->GetString(1, &address_)); |
| 90 EXTENSION_FUNCTION_VALIDATE(args_->GetInteger(2, &port_)); | 90 EXTENSION_FUNCTION_VALIDATE(args_->GetInteger(2, &port_)); |
| 91 return true; | 91 return true; |
| 92 } | 92 } |
| 93 | 93 |
| (...skipping 207 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 301 | 301 |
| 302 void SocketSendToFunction::OnCompleted(int bytes_written) { | 302 void SocketSendToFunction::OnCompleted(int bytes_written) { |
| 303 DictionaryValue* result = new DictionaryValue(); | 303 DictionaryValue* result = new DictionaryValue(); |
| 304 result->SetInteger(kBytesWrittenKey, bytes_written); | 304 result->SetInteger(kBytesWrittenKey, bytes_written); |
| 305 result_.reset(result); | 305 result_.reset(result); |
| 306 | 306 |
| 307 AsyncWorkCompleted(); | 307 AsyncWorkCompleted(); |
| 308 } | 308 } |
| 309 | 309 |
| 310 } // namespace extensions | 310 } // namespace extensions |
| OLD | NEW |