| OLD | NEW |
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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 "webkit/plugins/ppapi/ppb_flash_net_connector_impl.h" | 5 #include "webkit/plugins/ppapi/ppb_flash_net_connector_impl.h" |
| 6 | 6 |
| 7 #include "ppapi/c/pp_completion_callback.h" | 7 #include "ppapi/c/pp_completion_callback.h" |
| 8 #include "ppapi/c/private/ppb_flash_net_connector.h" | 8 #include "ppapi/c/private/ppb_flash_net_connector.h" |
| 9 #include "webkit/plugins/ppapi/common.h" | 9 #include "webkit/plugins/ppapi/common.h" |
| 10 #include "webkit/plugins/ppapi/plugin_delegate.h" | 10 #include "webkit/plugins/ppapi/plugin_delegate.h" |
| (...skipping 18 matching lines...) Expand all Loading... |
| 29 | 29 |
| 30 PPB_Flash_NetConnector_API* | 30 PPB_Flash_NetConnector_API* |
| 31 PPB_Flash_NetConnector_Impl::AsPPB_Flash_NetConnector_API() { | 31 PPB_Flash_NetConnector_Impl::AsPPB_Flash_NetConnector_API() { |
| 32 return this; | 32 return this; |
| 33 } | 33 } |
| 34 | 34 |
| 35 int32_t PPB_Flash_NetConnector_Impl::ConnectTcp( | 35 int32_t PPB_Flash_NetConnector_Impl::ConnectTcp( |
| 36 const char* host, | 36 const char* host, |
| 37 uint16_t port, | 37 uint16_t port, |
| 38 PP_FileHandle* socket_out, | 38 PP_FileHandle* socket_out, |
| 39 PP_Flash_NetAddress* local_addr_out, | 39 PP_NetAddress_Private* local_addr_out, |
| 40 PP_Flash_NetAddress* remote_addr_out, | 40 PP_NetAddress_Private* remote_addr_out, |
| 41 PP_CompletionCallback callback) { | 41 PP_CompletionCallback callback) { |
| 42 // |socket_out| is not optional. | 42 // |socket_out| is not optional. |
| 43 if (!socket_out) | 43 if (!socket_out) |
| 44 return PP_ERROR_BADARGUMENT; | 44 return PP_ERROR_BADARGUMENT; |
| 45 | 45 |
| 46 if (!callback.func) | 46 if (!callback.func) |
| 47 return PP_ERROR_BLOCKS_MAIN_THREAD; | 47 return PP_ERROR_BLOCKS_MAIN_THREAD; |
| 48 | 48 |
| 49 if (callback_.get() && !callback_->completed()) | 49 if (callback_.get() && !callback_->completed()) |
| 50 return PP_ERROR_INPROGRESS; | 50 return PP_ERROR_INPROGRESS; |
| (...skipping 11 matching lines...) Expand all Loading... |
| 62 local_addr_out_ = local_addr_out; | 62 local_addr_out_ = local_addr_out; |
| 63 remote_addr_out_ = remote_addr_out; | 63 remote_addr_out_ = remote_addr_out; |
| 64 } else { | 64 } else { |
| 65 // This should never be completed synchronously successfully. | 65 // This should never be completed synchronously successfully. |
| 66 DCHECK_NE(rv, PP_OK); | 66 DCHECK_NE(rv, PP_OK); |
| 67 } | 67 } |
| 68 return rv; | 68 return rv; |
| 69 } | 69 } |
| 70 | 70 |
| 71 int32_t PPB_Flash_NetConnector_Impl::ConnectTcpAddress( | 71 int32_t PPB_Flash_NetConnector_Impl::ConnectTcpAddress( |
| 72 const PP_Flash_NetAddress* addr, | 72 const PP_NetAddress_Private* addr, |
| 73 PP_FileHandle* socket_out, | 73 PP_FileHandle* socket_out, |
| 74 PP_Flash_NetAddress* local_addr_out, | 74 PP_NetAddress_Private* local_addr_out, |
| 75 PP_Flash_NetAddress* remote_addr_out, | 75 PP_NetAddress_Private* remote_addr_out, |
| 76 PP_CompletionCallback callback) { | 76 PP_CompletionCallback callback) { |
| 77 // |socket_out| is not optional. | 77 // |socket_out| is not optional. |
| 78 if (!socket_out) | 78 if (!socket_out) |
| 79 return PP_ERROR_BADARGUMENT; | 79 return PP_ERROR_BADARGUMENT; |
| 80 | 80 |
| 81 if (!callback.func) | 81 if (!callback.func) |
| 82 return PP_ERROR_BLOCKS_MAIN_THREAD; | 82 return PP_ERROR_BLOCKS_MAIN_THREAD; |
| 83 | 83 |
| 84 if (callback_.get() && !callback_->completed()) | 84 if (callback_.get() && !callback_->completed()) |
| 85 return PP_ERROR_INPROGRESS; | 85 return PP_ERROR_INPROGRESS; |
| (...skipping 12 matching lines...) Expand all Loading... |
| 98 remote_addr_out_ = remote_addr_out; | 98 remote_addr_out_ = remote_addr_out; |
| 99 } else { | 99 } else { |
| 100 // This should never be completed synchronously successfully. | 100 // This should never be completed synchronously successfully. |
| 101 DCHECK_NE(rv, PP_OK); | 101 DCHECK_NE(rv, PP_OK); |
| 102 } | 102 } |
| 103 return rv; | 103 return rv; |
| 104 } | 104 } |
| 105 | 105 |
| 106 void PPB_Flash_NetConnector_Impl::CompleteConnectTcp( | 106 void PPB_Flash_NetConnector_Impl::CompleteConnectTcp( |
| 107 PP_FileHandle socket, | 107 PP_FileHandle socket, |
| 108 const PP_Flash_NetAddress& local_addr, | 108 const PP_NetAddress_Private& local_addr, |
| 109 const PP_Flash_NetAddress& remote_addr) { | 109 const PP_NetAddress_Private& remote_addr) { |
| 110 int32_t rv = PP_ERROR_ABORTED; | 110 int32_t rv = PP_ERROR_ABORTED; |
| 111 if (!callback_->aborted()) { | 111 if (!callback_->aborted()) { |
| 112 CHECK(!callback_->completed()); | 112 CHECK(!callback_->completed()); |
| 113 | 113 |
| 114 // Write output data. | 114 // Write output data. |
| 115 *socket_out_ = socket; | 115 *socket_out_ = socket; |
| 116 if (socket != PP_kInvalidFileHandle) { | 116 if (socket != PP_kInvalidFileHandle) { |
| 117 if (local_addr_out_) | 117 if (local_addr_out_) |
| 118 *local_addr_out_ = local_addr; | 118 *local_addr_out_ = local_addr; |
| 119 if (remote_addr_out_) | 119 if (remote_addr_out_) |
| (...skipping 12 matching lines...) Expand all Loading... |
| 132 socket_out_ = NULL; | 132 socket_out_ = NULL; |
| 133 local_addr_out_ = NULL; | 133 local_addr_out_ = NULL; |
| 134 remote_addr_out_ = NULL; | 134 remote_addr_out_ = NULL; |
| 135 | 135 |
| 136 callback->Run(rv); // Will complete abortively if necessary. | 136 callback->Run(rv); // Will complete abortively if necessary. |
| 137 } | 137 } |
| 138 | 138 |
| 139 } // namespace ppapi | 139 } // namespace ppapi |
| 140 } // namespace webkit | 140 } // namespace webkit |
| 141 | 141 |
| OLD | NEW |