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 "ppapi/tests/test_tcp_socket_private.h" | 5 #include "ppapi/tests/test_tcp_socket_private.h" |
6 | 6 |
7 #include <stdlib.h> | 7 #include <stdlib.h> |
8 | 8 |
9 #include <new> | 9 #include <new> |
10 | 10 |
(...skipping 228 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
239 } | 239 } |
240 return PP_ERROR_FAILED; | 240 return PP_ERROR_FAILED; |
241 } | 241 } |
242 | 242 |
243 int32_t TestTCPSocketPrivate::WriteStringToSocket(pp::TCPSocketPrivate* socket, | 243 int32_t TestTCPSocketPrivate::WriteStringToSocket(pp::TCPSocketPrivate* socket, |
244 const std::string& s) { | 244 const std::string& s) { |
245 const char* buffer = s.data(); | 245 const char* buffer = s.data(); |
246 size_t written = 0; | 246 size_t written = 0; |
247 while (written < s.size()) { | 247 while (written < s.size()) { |
248 TestCompletionCallback cb(instance_->pp_instance(), callback_type()); | 248 TestCompletionCallback cb(instance_->pp_instance(), callback_type()); |
249 int32_t rv = socket->Write(buffer + written, s.size() - written, | 249 int32_t rv = socket->Write(buffer + written, |
| 250 static_cast<int32_t>(s.size() - written), |
250 cb.GetCallback()); | 251 cb.GetCallback()); |
251 if (callback_type() == PP_REQUIRED && rv != PP_OK_COMPLETIONPENDING) | 252 if (callback_type() == PP_REQUIRED && rv != PP_OK_COMPLETIONPENDING) |
252 return PP_ERROR_FAILED; | 253 return PP_ERROR_FAILED; |
253 cb.WaitForResult(rv); | 254 cb.WaitForResult(rv); |
254 if (cb.result() < 0) | 255 if (cb.result() < 0) |
255 return cb.result(); | 256 return cb.result(); |
256 if (cb.result() == 0) | 257 if (cb.result() == 0) |
257 return PP_ERROR_FAILED; | 258 return PP_ERROR_FAILED; |
258 written += cb.result(); | 259 written += cb.result(); |
259 } | 260 } |
260 if (written != s.size()) | 261 if (written != s.size()) |
261 return PP_ERROR_FAILED; | 262 return PP_ERROR_FAILED; |
262 return PP_OK; | 263 return PP_OK; |
263 } | 264 } |
OLD | NEW |