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 "ppapi/proxy/ppb_url_loader_proxy.h" | 5 #include "ppapi/proxy/ppb_url_loader_proxy.h" |
6 | 6 |
7 #include <algorithm> | 7 #include <algorithm> |
8 #include <deque> | 8 #include <deque> |
9 #include <vector> | 9 #include <vector> |
10 | 10 |
(...skipping 154 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
165 // Always need to fire completion callbacks to prevent a leak in the plugin. | 165 // Always need to fire completion callbacks to prevent a leak in the plugin. |
166 if (current_read_callback_.func) { | 166 if (current_read_callback_.func) { |
167 // TODO(brettw) the callbacks at this level should be refactored with a | 167 // TODO(brettw) the callbacks at this level should be refactored with a |
168 // more automatic tracking system like we have in the renderer. | 168 // more automatic tracking system like we have in the renderer. |
169 MessageLoop::current()->PostTask(FROM_HERE, base::Bind( | 169 MessageLoop::current()->PostTask(FROM_HERE, base::Bind( |
170 current_read_callback_.func, current_read_callback_.user_data, | 170 current_read_callback_.func, current_read_callback_.user_data, |
171 static_cast<int32_t>(PP_ERROR_ABORTED))); | 171 static_cast<int32_t>(PP_ERROR_ABORTED))); |
172 } | 172 } |
173 | 173 |
174 if (response_info_) | 174 if (response_info_) |
175 PpapiGlobals::Get()->GetResourceTracker()->ReleaseResource(response_info_); | 175 PluginResourceTracker::GetInstance()->ReleaseResource(response_info_); |
176 } | 176 } |
177 | 177 |
178 PPB_URLLoader_API* URLLoader::AsPPB_URLLoader_API() { | 178 PPB_URLLoader_API* URLLoader::AsPPB_URLLoader_API() { |
179 return this; | 179 return this; |
180 } | 180 } |
181 | 181 |
182 int32_t URLLoader::Open(PP_Resource request_id, | 182 int32_t URLLoader::Open(PP_Resource request_id, |
183 PP_CompletionCallback callback) { | 183 PP_CompletionCallback callback) { |
184 EnterResourceNoLock<thunk::PPB_URLRequestInfo_API> enter(request_id, true); | 184 EnterResourceNoLock<thunk::PPB_URLRequestInfo_API> enter(request_id, true); |
185 if (enter.failed()) | 185 if (enter.failed()) |
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
233 GetDispatcher()->Send(new PpapiHostMsg_PPBURLLoader_GetResponseInfo( | 233 GetDispatcher()->Send(new PpapiHostMsg_PPBURLLoader_GetResponseInfo( |
234 INTERFACE_ID_PPB_URL_LOADER, host_resource(), &response_id)); | 234 INTERFACE_ID_PPB_URL_LOADER, host_resource(), &response_id)); |
235 if (response_id.is_null()) | 235 if (response_id.is_null()) |
236 return 0; | 236 return 0; |
237 | 237 |
238 response_info_ = PPB_URLResponseInfo_Proxy::CreateResponseForResource( | 238 response_info_ = PPB_URLResponseInfo_Proxy::CreateResponseForResource( |
239 response_id); | 239 response_id); |
240 } | 240 } |
241 | 241 |
242 // The caller expects to get a ref, and we want to keep holding ours. | 242 // The caller expects to get a ref, and we want to keep holding ours. |
243 PpapiGlobals::Get()->GetResourceTracker()->AddRefResource(response_info_); | 243 PluginResourceTracker::GetInstance()->AddRefResource(response_info_); |
244 return response_info_; | 244 return response_info_; |
245 } | 245 } |
246 | 246 |
247 int32_t URLLoader::ReadResponseBody(void* buffer, | 247 int32_t URLLoader::ReadResponseBody(void* buffer, |
248 int32_t bytes_to_read, | 248 int32_t bytes_to_read, |
249 PP_CompletionCallback callback) { | 249 PP_CompletionCallback callback) { |
250 if (!buffer || bytes_to_read <= 0) | 250 if (!buffer || bytes_to_read <= 0) |
251 return PP_ERROR_BADARGUMENT; // Must specify an output buffer. | 251 return PP_ERROR_BADARGUMENT; // Must specify an output buffer. |
252 if (current_read_callback_.func) | 252 if (current_read_callback_.func) |
253 return PP_ERROR_INPROGRESS; // Can only have one request pending. | 253 return PP_ERROR_INPROGRESS; // Can only have one request pending. |
(...skipping 320 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
574 info->read_buffer.resize(bytes_read); | 574 info->read_buffer.resize(bytes_read); |
575 | 575 |
576 dispatcher()->Send(new PpapiMsg_PPBURLLoader_ReadResponseBody_Ack( | 576 dispatcher()->Send(new PpapiMsg_PPBURLLoader_ReadResponseBody_Ack( |
577 INTERFACE_ID_PPB_URL_LOADER, info->resource, result, info->read_buffer)); | 577 INTERFACE_ID_PPB_URL_LOADER, info->resource, result, info->read_buffer)); |
578 | 578 |
579 delete info; | 579 delete info; |
580 } | 580 } |
581 | 581 |
582 } // namespace proxy | 582 } // namespace proxy |
583 } // namespace ppapi | 583 } // namespace ppapi |
OLD | NEW |