| OLD | NEW |
| 1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 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_filter.h" | 5 #include "ppapi/proxy/udp_socket_filter.h" |
| 6 | 6 |
| 7 #include <algorithm> | 7 #include <algorithm> |
| 8 #include <cstring> | 8 #include <cstring> |
| 9 #include <utility> | 9 #include <utility> |
| 10 | 10 |
| (...skipping 99 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 110 base::AutoLock acquire(lock_); | 110 base::AutoLock acquire(lock_); |
| 111 auto it = queues_.find(resource); | 111 auto it = queues_.find(resource); |
| 112 return it->second->GetLastAddrPrivate(); | 112 return it->second->GetLastAddrPrivate(); |
| 113 } | 113 } |
| 114 | 114 |
| 115 void UDPSocketFilter::OnPluginMsgPushRecvResult( | 115 void UDPSocketFilter::OnPluginMsgPushRecvResult( |
| 116 const ResourceMessageReplyParams& params, | 116 const ResourceMessageReplyParams& params, |
| 117 int32_t result, | 117 int32_t result, |
| 118 const std::string& data, | 118 const std::string& data, |
| 119 const PP_NetAddress_Private& addr) { | 119 const PP_NetAddress_Private& addr) { |
| 120 DCHECK(PluginGlobals::Get()->ipc_task_runner()->RunsTasksOnCurrentThread()); | 120 DCHECK(PluginGlobals::Get()->ipc_task_runner()->RunsTasksInCurrentSequence()); |
| 121 base::AutoLock acquire(lock_); | 121 base::AutoLock acquire(lock_); |
| 122 auto it = queues_.find(params.pp_resource()); | 122 auto it = queues_.find(params.pp_resource()); |
| 123 // The RecvQueue might be gone if there were messages in-flight for a | 123 // The RecvQueue might be gone if there were messages in-flight for a |
| 124 // resource that has been destroyed. | 124 // resource that has been destroyed. |
| 125 if (it != queues_.end()) { | 125 if (it != queues_.end()) { |
| 126 // TODO(yzshen): Support passing in a non-const string ref, so that we can | 126 // TODO(yzshen): Support passing in a non-const string ref, so that we can |
| 127 // eliminate one copy when storing the data in the buffer. | 127 // eliminate one copy when storing the data in the buffer. |
| 128 it->second->DataReceivedOnIOThread(result, data, addr); | 128 it->second->DataReceivedOnIOThread(result, data, addr); |
| 129 } | 129 } |
| 130 } | 130 } |
| (...skipping 13 matching lines...) Expand all Loading... |
| 144 | 144 |
| 145 UDPSocketFilter::RecvQueue::~RecvQueue() { | 145 UDPSocketFilter::RecvQueue::~RecvQueue() { |
| 146 if (TrackedCallback::IsPending(recvfrom_callback_)) | 146 if (TrackedCallback::IsPending(recvfrom_callback_)) |
| 147 recvfrom_callback_->PostAbort(); | 147 recvfrom_callback_->PostAbort(); |
| 148 } | 148 } |
| 149 | 149 |
| 150 void UDPSocketFilter::RecvQueue::DataReceivedOnIOThread( | 150 void UDPSocketFilter::RecvQueue::DataReceivedOnIOThread( |
| 151 int32_t result, | 151 int32_t result, |
| 152 const std::string& data, | 152 const std::string& data, |
| 153 const PP_NetAddress_Private& addr) { | 153 const PP_NetAddress_Private& addr) { |
| 154 DCHECK(PluginGlobals::Get()->ipc_task_runner()->RunsTasksOnCurrentThread()); | 154 DCHECK(PluginGlobals::Get()->ipc_task_runner()->RunsTasksInCurrentSequence()); |
| 155 DCHECK_LT(recv_buffers_.size(), | 155 DCHECK_LT(recv_buffers_.size(), |
| 156 static_cast<size_t>( | 156 static_cast<size_t>( |
| 157 UDPSocketResourceConstants::kPluginReceiveBufferSlots)); | 157 UDPSocketResourceConstants::kPluginReceiveBufferSlots)); |
| 158 | 158 |
| 159 if (!TrackedCallback::IsPending(recvfrom_callback_) || !read_buffer_) { | 159 if (!TrackedCallback::IsPending(recvfrom_callback_) || !read_buffer_) { |
| 160 recv_buffers_.push(RecvBuffer()); | 160 recv_buffers_.push(RecvBuffer()); |
| 161 RecvBuffer& back = recv_buffers_.back(); | 161 RecvBuffer& back = recv_buffers_.back(); |
| 162 back.result = result; | 162 back.result = result; |
| 163 back.data = data; | 163 back.data = data; |
| 164 back.addr = addr; | 164 back.addr = addr; |
| (...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 239 } | 239 } |
| 240 } | 240 } |
| 241 | 241 |
| 242 PP_NetAddress_Private UDPSocketFilter::RecvQueue::GetLastAddrPrivate() const { | 242 PP_NetAddress_Private UDPSocketFilter::RecvQueue::GetLastAddrPrivate() const { |
| 243 CHECK(private_api_); | 243 CHECK(private_api_); |
| 244 return last_recvfrom_addr_; | 244 return last_recvfrom_addr_; |
| 245 } | 245 } |
| 246 | 246 |
| 247 } // namespace proxy | 247 } // namespace proxy |
| 248 } // namespace ppapi | 248 } // namespace ppapi |
| OLD | NEW |