OLD | NEW |
1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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 "ppapi/proxy/tcp_socket_resource_base.h" | 5 #include "ppapi/proxy/tcp_socket_resource_base.h" |
6 | 6 |
7 #include <cstring> | 7 #include <cstring> |
8 | 8 |
9 #include "base/bind.h" | 9 #include "base/bind.h" |
10 #include "base/logging.h" | 10 #include "base/logging.h" |
(...skipping 189 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
200 if (!buffer || bytes_to_read <= 0) | 200 if (!buffer || bytes_to_read <= 0) |
201 return PP_ERROR_BADARGUMENT; | 201 return PP_ERROR_BADARGUMENT; |
202 | 202 |
203 if (!state_.IsConnected()) | 203 if (!state_.IsConnected()) |
204 return PP_ERROR_FAILED; | 204 return PP_ERROR_FAILED; |
205 if (TrackedCallback::IsPending(read_callback_) || | 205 if (TrackedCallback::IsPending(read_callback_) || |
206 state_.IsPending(TCPSocketState::SSL_CONNECT)) | 206 state_.IsPending(TCPSocketState::SSL_CONNECT)) |
207 return PP_ERROR_INPROGRESS; | 207 return PP_ERROR_INPROGRESS; |
208 read_buffer_ = buffer; | 208 read_buffer_ = buffer; |
209 bytes_to_read_ = | 209 bytes_to_read_ = |
210 std::min(bytes_to_read, TCPSocketResourceConstants::kMaxReadSize); | 210 std::min(bytes_to_read, |
| 211 static_cast<int32_t>(TCPSocketResourceConstants::kMaxReadSize)); |
211 read_callback_ = callback; | 212 read_callback_ = callback; |
212 | 213 |
213 Call<PpapiPluginMsg_TCPSocket_ReadReply>( | 214 Call<PpapiPluginMsg_TCPSocket_ReadReply>( |
214 BROWSER, | 215 BROWSER, |
215 PpapiHostMsg_TCPSocket_Read(bytes_to_read_), | 216 PpapiHostMsg_TCPSocket_Read(bytes_to_read_), |
216 base::Bind(&TCPSocketResourceBase::OnPluginMsgReadReply, | 217 base::Bind(&TCPSocketResourceBase::OnPluginMsgReadReply, |
217 base::Unretained(this)), | 218 base::Unretained(this)), |
218 callback); | 219 callback); |
219 return PP_OK_COMPLETIONPENDING; | 220 return PP_OK_COMPLETIONPENDING; |
220 } | 221 } |
(...skipping 278 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
499 } | 500 } |
500 | 501 |
501 void TCPSocketResourceBase::RunCallback(scoped_refptr<TrackedCallback> callback, | 502 void TCPSocketResourceBase::RunCallback(scoped_refptr<TrackedCallback> callback, |
502 int32_t pp_result) { | 503 int32_t pp_result) { |
503 callback->Run(ConvertNetworkAPIErrorForCompatibility( | 504 callback->Run(ConvertNetworkAPIErrorForCompatibility( |
504 pp_result, version_ == TCP_SOCKET_VERSION_PRIVATE)); | 505 pp_result, version_ == TCP_SOCKET_VERSION_PRIVATE)); |
505 } | 506 } |
506 | 507 |
507 } // namespace ppapi | 508 } // namespace ppapi |
508 } // namespace proxy | 509 } // namespace proxy |
OLD | NEW |