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

Side by Side Diff: webkit/glue/weburlloader_impl.cc

Issue 12243002: Pass WebKit priority changes and parsing messages up to the browser process. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Rename IPC Created 7 years, 10 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) 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 // An implementation of WebURLLoader in terms of ResourceLoaderBridge. 5 // An implementation of WebURLLoader in terms of ResourceLoaderBridge.
6 6
7 #include "webkit/glue/weburlloader_impl.h" 7 #include "webkit/glue/weburlloader_impl.h"
8 8
9 #include "base/bind.h" 9 #include "base/bind.h"
10 #include "base/file_path.h" 10 #include "base/file_path.h"
(...skipping 250 matching lines...) Expand 10 before | Expand all | Expand 10 after
261 261
262 // Build up the header map. 262 // Build up the header map.
263 void* iter = NULL; 263 void* iter = NULL;
264 std::string name; 264 std::string name;
265 while (headers->EnumerateHeaderLines(&iter, &name, &value)) { 265 while (headers->EnumerateHeaderLines(&iter, &name, &value)) {
266 response->addHTTPHeaderField(WebString::fromUTF8(name), 266 response->addHTTPHeaderField(WebString::fromUTF8(name),
267 WebString::fromUTF8(value)); 267 WebString::fromUTF8(value));
268 } 268 }
269 } 269 }
270 270
271 net::RequestPriority ConvertWebKitPriorityToNetPriority(
272 const WebURLRequest::Priority& priority) {
273 switch (priority) {
274 case WebURLRequest::PriorityVeryHigh:
275 return net::HIGHEST;
276
277 case WebURLRequest::PriorityHigh:
278 return net::MEDIUM;
279
280 case WebURLRequest::PriorityMedium:
281 return net::LOW;
282
283 case WebURLRequest::PriorityLow:
284 return net::LOWEST;
285
286 case WebURLRequest::PriorityVeryLow:
287 return net::IDLE;
288
289 case WebURLRequest::PriorityUnresolved:
290 default:
291 NOTREACHED();
292 return net::LOW;
293 }
294 }
295
271 } // namespace 296 } // namespace
272 297
273 // WebURLLoaderImpl::Context -------------------------------------------------- 298 // WebURLLoaderImpl::Context --------------------------------------------------
274 299
275 // This inner class exists since the WebURLLoader may be deleted while inside a 300 // This inner class exists since the WebURLLoader may be deleted while inside a
276 // call to WebURLLoaderClient. The bridge requires its Peer to stay alive 301 // call to WebURLLoaderClient. The bridge requires its Peer to stay alive
277 // until it receives OnCompletedRequest. 302 // until it receives OnCompletedRequest.
278 class WebURLLoaderImpl::Context : public base::RefCounted<Context>, 303 class WebURLLoaderImpl::Context : public base::RefCounted<Context>,
279 public ResourceLoaderBridge::Peer { 304 public ResourceLoaderBridge::Peer {
280 public: 305 public:
281 explicit Context(WebURLLoaderImpl* loader); 306 explicit Context(WebURLLoaderImpl* loader);
282 307
283 WebURLLoaderClient* client() const { return client_; } 308 WebURLLoaderClient* client() const { return client_; }
284 void set_client(WebURLLoaderClient* client) { client_ = client; } 309 void set_client(WebURLLoaderClient* client) { client_ = client; }
285 310
286 void Cancel(); 311 void Cancel();
287 void SetDefersLoading(bool value); 312 void SetDefersLoading(bool value);
313 void DidChangePriority(WebURLRequest::Priority new_priority);
288 void Start( 314 void Start(
289 const WebURLRequest& request, 315 const WebURLRequest& request,
290 ResourceLoaderBridge::SyncLoadResponse* sync_load_response, 316 ResourceLoaderBridge::SyncLoadResponse* sync_load_response,
291 WebKitPlatformSupportImpl* platform); 317 WebKitPlatformSupportImpl* platform);
292 318
293 // ResourceLoaderBridge::Peer methods: 319 // ResourceLoaderBridge::Peer methods:
294 virtual void OnUploadProgress(uint64 position, uint64 size); 320 virtual void OnUploadProgress(uint64 position, uint64 size);
295 virtual bool OnReceivedRedirect( 321 virtual bool OnReceivedRedirect(
296 const GURL& new_url, 322 const GURL& new_url,
297 const ResourceResponseInfo& info, 323 const ResourceResponseInfo& info,
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after
346 // Do not make any further calls to the client. 372 // Do not make any further calls to the client.
347 client_ = NULL; 373 client_ = NULL;
348 loader_ = NULL; 374 loader_ = NULL;
349 } 375 }
350 376
351 void WebURLLoaderImpl::Context::SetDefersLoading(bool value) { 377 void WebURLLoaderImpl::Context::SetDefersLoading(bool value) {
352 if (bridge_.get()) 378 if (bridge_.get())
353 bridge_->SetDefersLoading(value); 379 bridge_->SetDefersLoading(value);
354 } 380 }
355 381
382 void WebURLLoaderImpl::Context::DidChangePriority(
383 WebURLRequest::Priority new_priority) {
384 if (bridge_.get())
385 bridge_->DidChangePriority(
386 ConvertWebKitPriorityToNetPriority(new_priority));
387 }
388
356 void WebURLLoaderImpl::Context::Start( 389 void WebURLLoaderImpl::Context::Start(
357 const WebURLRequest& request, 390 const WebURLRequest& request,
358 ResourceLoaderBridge::SyncLoadResponse* sync_load_response, 391 ResourceLoaderBridge::SyncLoadResponse* sync_load_response,
359 WebKitPlatformSupportImpl* platform) { 392 WebKitPlatformSupportImpl* platform) {
360 DCHECK(!bridge_.get()); 393 DCHECK(!bridge_.get());
361 394
362 request_ = request; // Save the request. 395 request_ = request; // Save the request.
363 396
364 GURL url = request.url(); 397 GURL url = request.url();
365 if (url.SchemeIs("data") && CanHandleDataURL(url)) { 398 if (url.SchemeIs("data") && CanHandleDataURL(url)) {
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after
425 request_info.first_party_for_cookies = request.firstPartyForCookies(); 458 request_info.first_party_for_cookies = request.firstPartyForCookies();
426 request_info.referrer = referrer_url; 459 request_info.referrer = referrer_url;
427 request_info.headers = flattener.GetBuffer(); 460 request_info.headers = flattener.GetBuffer();
428 request_info.load_flags = load_flags; 461 request_info.load_flags = load_flags;
429 // requestor_pid only needs to be non-zero if the request originates outside 462 // requestor_pid only needs to be non-zero if the request originates outside
430 // the render process, so we can use requestorProcessID even for requests 463 // the render process, so we can use requestorProcessID even for requests
431 // from in-process plugins. 464 // from in-process plugins.
432 request_info.requestor_pid = request.requestorProcessID(); 465 request_info.requestor_pid = request.requestorProcessID();
433 request_info.request_type = 466 request_info.request_type =
434 ResourceType::FromTargetType(request.targetType()); 467 ResourceType::FromTargetType(request.targetType());
435 request_info.priority = request.priority(); 468 request_info.priority =
469 ConvertWebKitPriorityToNetPriority(request.priority());
436 request_info.appcache_host_id = request.appCacheHostID(); 470 request_info.appcache_host_id = request.appCacheHostID();
437 request_info.routing_id = request.requestorID(); 471 request_info.routing_id = request.requestorID();
438 request_info.download_to_file = request.downloadToFile(); 472 request_info.download_to_file = request.downloadToFile();
439 request_info.has_user_gesture = request.hasUserGesture(); 473 request_info.has_user_gesture = request.hasUserGesture();
440 request_info.extra_data = request.extraData(); 474 request_info.extra_data = request.extraData();
441 if (request.extraData()) { 475 if (request.extraData()) {
442 referrer_policy_ = static_cast<WebURLRequestExtraDataImpl*>( 476 referrer_policy_ = static_cast<WebURLRequestExtraDataImpl*>(
443 request.extraData())->referrer_policy(); 477 request.extraData())->referrer_policy();
444 request_info.referrer_policy = referrer_policy_; 478 request_info.referrer_policy = referrer_policy_;
445 } 479 }
(...skipping 330 matching lines...) Expand 10 before | Expand all | Expand 10 after
776 } 810 }
777 811
778 void WebURLLoaderImpl::cancel() { 812 void WebURLLoaderImpl::cancel() {
779 context_->Cancel(); 813 context_->Cancel();
780 } 814 }
781 815
782 void WebURLLoaderImpl::setDefersLoading(bool value) { 816 void WebURLLoaderImpl::setDefersLoading(bool value) {
783 context_->SetDefersLoading(value); 817 context_->SetDefersLoading(value);
784 } 818 }
785 819
820 void WebURLLoaderImpl::didChangePriority(WebURLRequest::Priority new_priority) {
821 context_->DidChangePriority(new_priority);
822 }
823
786 } // namespace webkit_glue 824 } // namespace webkit_glue
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698