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

Side by Side Diff: chrome/browser/renderer_host/resource_dispatcher_host.cc

Issue 42541: Prioritize which HTTP requests get a socket first by adding a priority level ... (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: '' Created 11 years, 9 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) 2006-2008 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2006-2008 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 // See http://dev.chromium.org/developers/design-documents/multi-process-resourc e-loading 5 // See http://dev.chromium.org/developers/design-documents/multi-process-resourc e-loading
6 6
7 #include "chrome/browser/renderer_host/resource_dispatcher_host.h" 7 #include "chrome/browser/renderer_host/resource_dispatcher_host.h"
8 8
9 #include <vector> 9 #include <vector>
10 10
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
46 // TODO(port): Move these includes to the above section when porting is done. 46 // TODO(port): Move these includes to the above section when porting is done.
47 #if defined(OS_POSIX) 47 #if defined(OS_POSIX)
48 #include "chrome/common/temp_scaffolding_stubs.h" 48 #include "chrome/common/temp_scaffolding_stubs.h"
49 #elif defined(OS_WIN) 49 #elif defined(OS_WIN)
50 #include "chrome/browser/login_prompt.h" 50 #include "chrome/browser/login_prompt.h"
51 #include "chrome/browser/renderer_host/render_view_host_delegate.h" 51 #include "chrome/browser/renderer_host/render_view_host_delegate.h"
52 #include "chrome/browser/safe_browsing/safe_browsing_service.h" 52 #include "chrome/browser/safe_browsing/safe_browsing_service.h"
53 #endif 53 #endif
54 54
55 // Uncomment to enable logging of request traffic. 55 // Uncomment to enable logging of request traffic.
56 //#define LOG_RESOURCE_DISPATCHER_REQUESTS 56 // #define LOG_RESOURCE_DISPATCHER_REQUESTS
57 57
58 #ifdef LOG_RESOURCE_DISPATCHER_REQUESTS 58 #ifdef LOG_RESOURCE_DISPATCHER_REQUESTS
59 # define RESOURCE_LOG(stuff) LOG(INFO) << stuff 59 # define RESOURCE_LOG(stuff) LOG(INFO) << stuff
60 #else 60 #else
61 # define RESOURCE_LOG(stuff) 61 # define RESOURCE_LOG(stuff)
62 #endif 62 #endif
63 63
64 using base::Time; 64 using base::Time;
65 using base::TimeDelta; 65 using base::TimeDelta;
66 using base::TimeTicks; 66 using base::TimeTicks;
(...skipping 254 matching lines...) Expand 10 before | Expand all | Expand 10 after
321 // Construct the request. 321 // Construct the request.
322 URLRequest* request = new URLRequest(request_data.url, this); 322 URLRequest* request = new URLRequest(request_data.url, this);
323 request->set_method(request_data.method); 323 request->set_method(request_data.method);
324 request->set_policy_url(request_data.policy_url); 324 request->set_policy_url(request_data.policy_url);
325 request->set_referrer(request_data.referrer.spec()); 325 request->set_referrer(request_data.referrer.spec());
326 request->SetExtraRequestHeaders(request_data.headers); 326 request->SetExtraRequestHeaders(request_data.headers);
327 request->set_load_flags(request_data.load_flags); 327 request->set_load_flags(request_data.load_flags);
328 request->set_context(context); 328 request->set_context(context);
329 request->set_origin_pid(request_data.origin_pid); 329 request->set_origin_pid(request_data.origin_pid);
330 330
331 // If the request is for the top level page or a frame/iframe, then we should
332 // prioritize it higher than other resource types. Currently, we just use
333 // priorities 1 and 0.
334 // TODO(willchan): Revisit the actual priorities when looking at considering
335 // boosting priorities for requests for the foreground tab.
336 if (request_data.resource_type == ResourceType::MAIN_FRAME ||
337 request_data.resource_type == ResourceType::SUB_FRAME) {
338 request->set_priority(1);
339 } else {
340 request->set_priority(0);
341 }
342
331 // Set upload data. 343 // Set upload data.
332 uint64 upload_size = 0; 344 uint64 upload_size = 0;
333 if (!request_data.upload_content.empty()) { 345 if (!request_data.upload_content.empty()) {
334 scoped_refptr<net::UploadData> upload = new net::UploadData(); 346 scoped_refptr<net::UploadData> upload = new net::UploadData();
335 upload->set_elements(request_data.upload_content); // Deep copy. 347 upload->set_elements(request_data.upload_content); // Deep copy.
336 request->set_upload(upload); 348 request->set_upload(upload);
337 upload_size = upload->GetContentLength(); 349 upload_size = upload->GetContentLength();
338 } 350 }
339 351
340 // Install a CrossSiteResourceHandler if this request is coming from a 352 // Install a CrossSiteResourceHandler if this request is coming from a
(...skipping 29 matching lines...) Expand all
370 ExtraRequestInfo* extra_info = 382 ExtraRequestInfo* extra_info =
371 new ExtraRequestInfo(handler, 383 new ExtraRequestInfo(handler,
372 process_type, 384 process_type,
373 process_id, 385 process_id,
374 route_id, 386 route_id,
375 request_id, 387 request_id,
376 request_data.frame_origin, 388 request_data.frame_origin,
377 request_data.main_frame_origin, 389 request_data.main_frame_origin,
378 request_data.resource_type, 390 request_data.resource_type,
379 upload_size); 391 upload_size);
380 extra_info->allow_download = ResourceType::IsFrame(request_data.resource_type) ; 392 extra_info->allow_download =
393 ResourceType::IsFrame(request_data.resource_type);
381 request->set_user_data(extra_info); // takes pointer ownership 394 request->set_user_data(extra_info); // takes pointer ownership
382 395
383 BeginRequestInternal(request); 396 BeginRequestInternal(request);
384 } 397 }
385 398
386 void ResourceDispatcherHost::OnDataReceivedACK(int request_id) { 399 void ResourceDispatcherHost::OnDataReceivedACK(int request_id) {
387 DataReceivedACK(receiver_->GetProcessId(), request_id); 400 DataReceivedACK(receiver_->GetProcessId(), request_id);
388 } 401 }
389 402
390 void ResourceDispatcherHost::DataReceivedACK(int process_id, int request_id) { 403 void ResourceDispatcherHost::DataReceivedACK(int process_id, int request_id) {
(...skipping 113 matching lines...) Expand 10 before | Expand all | Expand 10 after
504 517
505 ExtraRequestInfo* extra_info = 518 ExtraRequestInfo* extra_info =
506 new ExtraRequestInfo(handler, 519 new ExtraRequestInfo(handler,
507 ChildProcessInfo::RENDER_PROCESS, 520 ChildProcessInfo::RENDER_PROCESS,
508 process_id, 521 process_id,
509 route_id, 522 route_id,
510 request_id_, 523 request_id_,
511 "null", // frame_origin 524 "null", // frame_origin
512 "null", // main_frame_origin 525 "null", // main_frame_origin
513 ResourceType::SUB_RESOURCE, 526 ResourceType::SUB_RESOURCE,
514 0 /* upload_size */ ); 527 0 /* upload_size */);
515 extra_info->allow_download = true; 528 extra_info->allow_download = true;
516 extra_info->is_download = true; 529 extra_info->is_download = true;
517 request->set_user_data(extra_info); // Takes pointer ownership. 530 request->set_user_data(extra_info); // Takes pointer ownership.
518 531
519 BeginRequestInternal(request); 532 BeginRequestInternal(request);
520 } 533 }
521 534
522 // This function is only used for saving feature. 535 // This function is only used for saving feature.
523 void ResourceDispatcherHost::BeginSaveFile(const GURL& url, 536 void ResourceDispatcherHost::BeginSaveFile(const GURL& url,
524 const GURL& referrer, 537 const GURL& referrer,
(...skipping 1002 matching lines...) Expand 10 before | Expand all | Expand 10 after
1527 case ViewHostMsg_UploadProgress_ACK::ID: 1540 case ViewHostMsg_UploadProgress_ACK::ID:
1528 case ViewHostMsg_SyncLoad::ID: 1541 case ViewHostMsg_SyncLoad::ID:
1529 return true; 1542 return true;
1530 1543
1531 default: 1544 default:
1532 break; 1545 break;
1533 } 1546 }
1534 1547
1535 return false; 1548 return false;
1536 } 1549 }
OLDNEW
« no previous file with comments | « chrome/browser/renderer_host/resource_dispatcher_host.h ('k') | net/base/client_socket_handle.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698