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/udp_socket_resource_base.h" | 5 #include "ppapi/proxy/udp_socket_resource_base.h" |
6 | 6 |
7 #include <algorithm> | 7 #include <algorithm> |
8 #include <cstring> | 8 #include <cstring> |
9 | 9 |
10 #include "base/logging.h" | 10 #include "base/logging.h" |
(...skipping 302 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
313 read_buffer_ = NULL; | 313 read_buffer_ = NULL; |
314 bytes_to_read_ = -1; | 314 bytes_to_read_ = -1; |
315 recvfrom_addr_resource_ = NULL; | 315 recvfrom_addr_resource_ = NULL; |
316 | 316 |
317 RunCallback(recvfrom_callback_, result); | 317 RunCallback(recvfrom_callback_, result); |
318 } | 318 } |
319 | 319 |
320 void UDPSocketResourceBase::OnPluginMsgSendToReply( | 320 void UDPSocketResourceBase::OnPluginMsgSendToReply( |
321 const ResourceMessageReplyParams& params, | 321 const ResourceMessageReplyParams& params, |
322 int32_t bytes_written) { | 322 int32_t bytes_written) { |
| 323 // This can be empty if the socket was closed, but there are still tasks |
| 324 // to be posted for this resource. |
| 325 if (sendto_callbacks_.empty()) |
| 326 return; |
| 327 |
323 scoped_refptr<TrackedCallback> callback = sendto_callbacks_.front(); | 328 scoped_refptr<TrackedCallback> callback = sendto_callbacks_.front(); |
324 sendto_callbacks_.pop(); | 329 sendto_callbacks_.pop(); |
325 if (!TrackedCallback::IsPending(callback)) | 330 if (!TrackedCallback::IsPending(callback)) |
326 return; | 331 return; |
327 | 332 |
328 if (params.result() == PP_OK) | 333 if (params.result() == PP_OK) |
329 RunCallback(callback, bytes_written); | 334 RunCallback(callback, bytes_written); |
330 else | 335 else |
331 RunCallback(callback, params.result()); | 336 RunCallback(callback, params.result()); |
332 } | 337 } |
(...skipping 27 matching lines...) Expand all Loading... |
360 if (result == PP_OK && !data.empty()) | 365 if (result == PP_OK && !data.empty()) |
361 memcpy(output_buffer, data.c_str(), data.size()); | 366 memcpy(output_buffer, data.c_str(), data.size()); |
362 | 367 |
363 recvfrom_addr_ = addr; | 368 recvfrom_addr_ = addr; |
364 | 369 |
365 return result == PP_OK ? static_cast<int32_t>(data.size()) : result; | 370 return result == PP_OK ? static_cast<int32_t>(data.size()) : result; |
366 } | 371 } |
367 | 372 |
368 } // namespace proxy | 373 } // namespace proxy |
369 } // namespace ppapi | 374 } // namespace ppapi |
OLD | NEW |