Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(26)

Side by Side Diff: content/renderer/pepper/pepper_url_loader_host.cc

Issue 225903006: PPAPI: Run clang_format.py on content/renderer/pepper (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 6 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. 1 // Copyright (c) 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 "content/renderer/pepper/pepper_url_loader_host.h" 5 #include "content/renderer/pepper/pepper_url_loader_host.h"
6 6
7 #include "content/renderer/pepper/pepper_plugin_instance_impl.h" 7 #include "content/renderer/pepper/pepper_plugin_instance_impl.h"
8 #include "content/renderer/pepper/renderer_ppapi_host_impl.h" 8 #include "content/renderer/pepper/renderer_ppapi_host_impl.h"
9 #include "content/renderer/pepper/url_request_info_util.h" 9 #include "content/renderer/pepper/url_request_info_util.h"
10 #include "content/renderer/pepper/url_response_info_util.h" 10 #include "content/renderer/pepper/url_response_info_util.h"
(...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after
98 // re-entering the scoped_ptr destructor with the same scoped_ptr object 98 // re-entering the scoped_ptr destructor with the same scoped_ptr object
99 // via loader_.reset(). Be sure that loader_ is first NULL then destroy 99 // via loader_.reset(). Be sure that loader_ is first NULL then destroy
100 // the scoped_ptr. See http://crbug.com/159429. 100 // the scoped_ptr. See http://crbug.com/159429.
101 scoped_ptr<blink::WebURLLoader> for_destruction_only(loader_.release()); 101 scoped_ptr<blink::WebURLLoader> for_destruction_only(loader_.release());
102 } 102 }
103 103
104 int32_t PepperURLLoaderHost::OnResourceMessageReceived( 104 int32_t PepperURLLoaderHost::OnResourceMessageReceived(
105 const IPC::Message& msg, 105 const IPC::Message& msg,
106 ppapi::host::HostMessageContext* context) { 106 ppapi::host::HostMessageContext* context) {
107 IPC_BEGIN_MESSAGE_MAP(PepperURLLoaderHost, msg) 107 IPC_BEGIN_MESSAGE_MAP(PepperURLLoaderHost, msg)
108 PPAPI_DISPATCH_HOST_RESOURCE_CALL( 108 PPAPI_DISPATCH_HOST_RESOURCE_CALL(PpapiHostMsg_URLLoader_Open, OnHostMsgOpen)
109 PpapiHostMsg_URLLoader_Open, 109 PPAPI_DISPATCH_HOST_RESOURCE_CALL(PpapiHostMsg_URLLoader_SetDeferLoading,
110 OnHostMsgOpen) 110 OnHostMsgSetDeferLoading)
111 PPAPI_DISPATCH_HOST_RESOURCE_CALL( 111 PPAPI_DISPATCH_HOST_RESOURCE_CALL_0(PpapiHostMsg_URLLoader_Close,
112 PpapiHostMsg_URLLoader_SetDeferLoading, 112 OnHostMsgClose);
113 OnHostMsgSetDeferLoading) 113 PPAPI_DISPATCH_HOST_RESOURCE_CALL_0(
114 PPAPI_DISPATCH_HOST_RESOURCE_CALL_0( 114 PpapiHostMsg_URLLoader_GrantUniversalAccess,
115 PpapiHostMsg_URLLoader_Close, 115 OnHostMsgGrantUniversalAccess)
116 OnHostMsgClose);
117 PPAPI_DISPATCH_HOST_RESOURCE_CALL_0(
118 PpapiHostMsg_URLLoader_GrantUniversalAccess,
119 OnHostMsgGrantUniversalAccess)
120 IPC_END_MESSAGE_MAP() 116 IPC_END_MESSAGE_MAP()
121 return PP_ERROR_FAILED; 117 return PP_ERROR_FAILED;
122 } 118 }
123 119
124 void PepperURLLoaderHost::willSendRequest( 120 void PepperURLLoaderHost::willSendRequest(
125 WebURLLoader* loader, 121 WebURLLoader* loader,
126 WebURLRequest& new_request, 122 WebURLRequest& new_request,
127 const WebURLResponse& redirect_response) { 123 const WebURLResponse& redirect_response) {
128 DCHECK(out_of_order_replies_.empty()); 124 DCHECK(out_of_order_replies_.empty());
129 if (!request_data_.follow_redirects) { 125 if (!request_data_.follow_redirects) {
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after
173 } 169 }
174 170
175 void PepperURLLoaderHost::didFinishLoading(WebURLLoader* loader, 171 void PepperURLLoaderHost::didFinishLoading(WebURLLoader* loader,
176 double finish_time, 172 double finish_time,
177 int64_t total_encoded_data_length) { 173 int64_t total_encoded_data_length) {
178 // Note that |loader| will be NULL for document loads. 174 // Note that |loader| will be NULL for document loads.
179 SendUpdateToPlugin(new PpapiPluginMsg_URLLoader_FinishedLoading(PP_OK)); 175 SendUpdateToPlugin(new PpapiPluginMsg_URLLoader_FinishedLoading(PP_OK));
180 } 176 }
181 177
182 void PepperURLLoaderHost::didFail(WebURLLoader* loader, 178 void PepperURLLoaderHost::didFail(WebURLLoader* loader,
183 const WebURLError& error) { 179 const WebURLError& error) {
184 // Note that |loader| will be NULL for document loads. 180 // Note that |loader| will be NULL for document loads.
185 int32_t pp_error = PP_ERROR_FAILED; 181 int32_t pp_error = PP_ERROR_FAILED;
186 if (error.domain.equals(WebString::fromUTF8(net::kErrorDomain))) { 182 if (error.domain.equals(WebString::fromUTF8(net::kErrorDomain))) {
187 // TODO(bbudge): Extend pp_errors.h to cover interesting network errors 183 // TODO(bbudge): Extend pp_errors.h to cover interesting network errors
188 // from the net error domain. 184 // from the net error domain.
189 switch (error.reason) { 185 switch (error.reason) {
190 case net::ERR_ACCESS_DENIED: 186 case net::ERR_ACCESS_DENIED:
191 case net::ERR_NETWORK_ACCESS_DENIED: 187 case net::ERR_NETWORK_ACCESS_DENIED:
192 pp_error = PP_ERROR_NOACCESS; 188 pp_error = PP_ERROR_NOACCESS;
193 break; 189 break;
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after
230 if (main_document_loader_) 226 if (main_document_loader_)
231 return PP_ERROR_INPROGRESS; 227 return PP_ERROR_INPROGRESS;
232 228
233 // Create a copy of the request data since CreateWebURLRequest will populate 229 // Create a copy of the request data since CreateWebURLRequest will populate
234 // the file refs. 230 // the file refs.
235 ppapi::URLRequestInfoData filled_in_request_data = request_data; 231 ppapi::URLRequestInfoData filled_in_request_data = request_data;
236 232
237 if (URLRequestRequiresUniversalAccess(filled_in_request_data) && 233 if (URLRequestRequiresUniversalAccess(filled_in_request_data) &&
238 !has_universal_access_) { 234 !has_universal_access_) {
239 ppapi::PpapiGlobals::Get()->LogWithSource( 235 ppapi::PpapiGlobals::Get()->LogWithSource(
240 pp_instance(), PP_LOGLEVEL_ERROR, std::string(), 236 pp_instance(),
237 PP_LOGLEVEL_ERROR,
238 std::string(),
241 "PPB_URLLoader.Open: The URL you're requesting is " 239 "PPB_URLLoader.Open: The URL you're requesting is "
242 " on a different security origin than your plugin. To request " 240 " on a different security origin than your plugin. To request "
243 " cross-origin resources, see " 241 " cross-origin resources, see "
244 " PP_URLREQUESTPROPERTY_ALLOWCROSSORIGINREQUESTS."); 242 " PP_URLREQUESTPROPERTY_ALLOWCROSSORIGINREQUESTS.");
245 return PP_ERROR_NOACCESS; 243 return PP_ERROR_NOACCESS;
246 } 244 }
247 245
248 if (loader_.get()) 246 if (loader_.get())
249 return PP_ERROR_INPROGRESS; 247 return PP_ERROR_INPROGRESS;
250 248
251 WebFrame* frame = GetFrame(); 249 WebFrame* frame = GetFrame();
252 if (!frame) 250 if (!frame)
253 return PP_ERROR_FAILED; 251 return PP_ERROR_FAILED;
254 252
255 WebURLRequest web_request; 253 WebURLRequest web_request;
256 if (!CreateWebURLRequest(pp_instance(), 254 if (!CreateWebURLRequest(
257 &filled_in_request_data, 255 pp_instance(), &filled_in_request_data, frame, &web_request)) {
258 frame,
259 &web_request)) {
260 return PP_ERROR_FAILED; 256 return PP_ERROR_FAILED;
261 } 257 }
262 258
263 web_request.setTargetType(WebURLRequest::TargetIsObject); 259 web_request.setTargetType(WebURLRequest::TargetIsObject);
264 web_request.setRequestorProcessID(renderer_ppapi_host_->GetPluginPID()); 260 web_request.setRequestorProcessID(renderer_ppapi_host_->GetPluginPID());
265 261
266 WebURLLoaderOptions options; 262 WebURLLoaderOptions options;
267 if (has_universal_access_) { 263 if (has_universal_access_) {
268 options.allowCredentials = true; 264 options.allowCredentials = true;
269 options.crossOriginRequestPolicy = 265 options.crossOriginRequestPolicy =
(...skipping 125 matching lines...) Expand 10 before | Expand all | Expand 10 after
395 // messages we send to the plugin are not sent out of order. See 391 // messages we send to the plugin are not sent out of order. See
396 // SendUpdateToPlugin() for more details. 392 // SendUpdateToPlugin() for more details.
397 DCHECK(!pending_response_); 393 DCHECK(!pending_response_);
398 pending_response_ = true; 394 pending_response_ = true;
399 395
400 DataFromWebURLResponse( 396 DataFromWebURLResponse(
401 renderer_ppapi_host_, 397 renderer_ppapi_host_,
402 pp_instance(), 398 pp_instance(),
403 response, 399 response,
404 base::Bind(&PepperURLLoaderHost::DidDataFromWebURLResponse, 400 base::Bind(&PepperURLLoaderHost::DidDataFromWebURLResponse,
405 weak_factory_.GetWeakPtr())); 401 weak_factory_.GetWeakPtr()));
406 } 402 }
407 } 403 }
408 404
409 void PepperURLLoaderHost::DidDataFromWebURLResponse( 405 void PepperURLLoaderHost::DidDataFromWebURLResponse(
410 const ppapi::URLResponseInfoData& data) { 406 const ppapi::URLResponseInfoData& data) {
411 SendUpdateToPlugin(new PpapiPluginMsg_URLLoader_ReceivedResponse(data)); 407 SendUpdateToPlugin(new PpapiPluginMsg_URLLoader_ReceivedResponse(data));
412 } 408 }
413 409
414 void PepperURLLoaderHost::UpdateProgress() { 410 void PepperURLLoaderHost::UpdateProgress() {
415 bool record_download = request_data_.record_download_progress; 411 bool record_download = request_data_.record_download_progress;
416 bool record_upload = request_data_.record_upload_progress; 412 bool record_upload = request_data_.record_upload_progress;
417 if (record_download || record_upload) { 413 if (record_download || record_upload) {
418 // Here we go through some effort to only send the exact information that 414 // Here we go through some effort to only send the exact information that
419 // the requestor wanted in the request flags. It would be just as 415 // the requestor wanted in the request flags. It would be just as
420 // efficient to send all of it, but we don't want people to rely on 416 // efficient to send all of it, but we don't want people to rely on
421 // getting download progress when they happen to set the upload progress 417 // getting download progress when they happen to set the upload progress
422 // flag. 418 // flag.
423 ppapi::proxy::ResourceMessageReplyParams params; 419 ppapi::proxy::ResourceMessageReplyParams params;
424 SendUpdateToPlugin(new PpapiPluginMsg_URLLoader_UpdateProgress( 420 SendUpdateToPlugin(new PpapiPluginMsg_URLLoader_UpdateProgress(
425 record_upload ? bytes_sent_ : -1, 421 record_upload ? bytes_sent_ : -1,
426 record_upload ? total_bytes_to_be_sent_ : -1, 422 record_upload ? total_bytes_to_be_sent_ : -1,
427 record_download ? bytes_received_ : -1, 423 record_download ? bytes_received_ : -1,
428 record_download ? total_bytes_to_be_received_ : -1)); 424 record_download ? total_bytes_to_be_received_ : -1));
429 } 425 }
430 } 426 }
431 427
432 } // namespace content 428 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698