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

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

Issue 11270027: Add a ResourceScheduler to ResourceDispatcherHost. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Move Client back to .h -- broke Win 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) OVERRIDE; 320 virtual void OnUploadProgress(uint64 position, uint64 size) OVERRIDE;
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 49 matching lines...) Expand 10 before | Expand all | Expand 10 after
347 // Do not make any further calls to the client. 373 // Do not make any further calls to the client.
348 client_ = NULL; 374 client_ = NULL;
349 loader_ = NULL; 375 loader_ = NULL;
350 } 376 }
351 377
352 void WebURLLoaderImpl::Context::SetDefersLoading(bool value) { 378 void WebURLLoaderImpl::Context::SetDefersLoading(bool value) {
353 if (bridge_.get()) 379 if (bridge_.get())
354 bridge_->SetDefersLoading(value); 380 bridge_->SetDefersLoading(value);
355 } 381 }
356 382
383 void WebURLLoaderImpl::Context::DidChangePriority(
384 WebURLRequest::Priority new_priority) {
385 if (bridge_.get())
386 bridge_->DidChangePriority(
387 ConvertWebKitPriorityToNetPriority(new_priority));
388 }
389
357 void WebURLLoaderImpl::Context::Start( 390 void WebURLLoaderImpl::Context::Start(
358 const WebURLRequest& request, 391 const WebURLRequest& request,
359 ResourceLoaderBridge::SyncLoadResponse* sync_load_response, 392 ResourceLoaderBridge::SyncLoadResponse* sync_load_response,
360 WebKitPlatformSupportImpl* platform) { 393 WebKitPlatformSupportImpl* platform) {
361 DCHECK(!bridge_.get()); 394 DCHECK(!bridge_.get());
362 395
363 request_ = request; // Save the request. 396 request_ = request; // Save the request.
364 397
365 GURL url = request.url(); 398 GURL url = request.url();
366 if (url.SchemeIs("data") && CanHandleDataURL(url)) { 399 if (url.SchemeIs("data") && CanHandleDataURL(url)) {
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after
426 request_info.first_party_for_cookies = request.firstPartyForCookies(); 459 request_info.first_party_for_cookies = request.firstPartyForCookies();
427 request_info.referrer = referrer_url; 460 request_info.referrer = referrer_url;
428 request_info.headers = flattener.GetBuffer(); 461 request_info.headers = flattener.GetBuffer();
429 request_info.load_flags = load_flags; 462 request_info.load_flags = load_flags;
430 // requestor_pid only needs to be non-zero if the request originates outside 463 // requestor_pid only needs to be non-zero if the request originates outside
431 // the render process, so we can use requestorProcessID even for requests 464 // the render process, so we can use requestorProcessID even for requests
432 // from in-process plugins. 465 // from in-process plugins.
433 request_info.requestor_pid = request.requestorProcessID(); 466 request_info.requestor_pid = request.requestorProcessID();
434 request_info.request_type = 467 request_info.request_type =
435 ResourceType::FromTargetType(request.targetType()); 468 ResourceType::FromTargetType(request.targetType());
436 request_info.priority = request.priority(); 469 request_info.priority =
470 ConvertWebKitPriorityToNetPriority(request.priority());
437 request_info.appcache_host_id = request.appCacheHostID(); 471 request_info.appcache_host_id = request.appCacheHostID();
438 request_info.routing_id = request.requestorID(); 472 request_info.routing_id = request.requestorID();
439 request_info.download_to_file = request.downloadToFile(); 473 request_info.download_to_file = request.downloadToFile();
440 request_info.has_user_gesture = request.hasUserGesture(); 474 request_info.has_user_gesture = request.hasUserGesture();
441 request_info.extra_data = request.extraData(); 475 request_info.extra_data = request.extraData();
442 if (request.extraData()) { 476 if (request.extraData()) {
443 referrer_policy_ = static_cast<WebURLRequestExtraDataImpl*>( 477 referrer_policy_ = static_cast<WebURLRequestExtraDataImpl*>(
444 request.extraData())->referrer_policy(); 478 request.extraData())->referrer_policy();
445 request_info.referrer_policy = referrer_policy_; 479 request_info.referrer_policy = referrer_policy_;
446 } 480 }
(...skipping 330 matching lines...) Expand 10 before | Expand all | Expand 10 after
777 } 811 }
778 812
779 void WebURLLoaderImpl::cancel() { 813 void WebURLLoaderImpl::cancel() {
780 context_->Cancel(); 814 context_->Cancel();
781 } 815 }
782 816
783 void WebURLLoaderImpl::setDefersLoading(bool value) { 817 void WebURLLoaderImpl::setDefersLoading(bool value) {
784 context_->SetDefersLoading(value); 818 context_->SetDefersLoading(value);
785 } 819 }
786 820
821 void WebURLLoaderImpl::didChangePriority(WebURLRequest::Priority new_priority) {
822 context_->DidChangePriority(new_priority);
823 }
824
787 } // namespace webkit_glue 825 } // namespace webkit_glue
OLDNEW
« no previous file with comments | « webkit/glue/weburlloader_impl.h ('k') | webkit/tools/test_shell/simple_resource_loader_bridge.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698