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

Side by Side Diff: content/browser/loader/resource_dispatcher_host_impl.cc

Issue 2785523002: Reduce/remove usage of BrowserThread in content/browser/loader. (Closed)
Patch Set: Remove stray include Created 3 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
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 // 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 "content/browser/loader/resource_dispatcher_host_impl.h" 7 #include "content/browser/loader/resource_dispatcher_host_impl.h"
8 8
9 #include <stddef.h> 9 #include <stddef.h>
10 10
(...skipping 14 matching lines...) Expand all
25 #include "base/memory/ptr_util.h" 25 #include "base/memory/ptr_util.h"
26 #include "base/memory/shared_memory.h" 26 #include "base/memory/shared_memory.h"
27 #include "base/message_loop/message_loop.h" 27 #include "base/message_loop/message_loop.h"
28 #include "base/metrics/field_trial.h" 28 #include "base/metrics/field_trial.h"
29 #include "base/metrics/histogram_macros.h" 29 #include "base/metrics/histogram_macros.h"
30 #include "base/metrics/sparse_histogram.h" 30 #include "base/metrics/sparse_histogram.h"
31 #include "base/profiler/scoped_tracker.h" 31 #include "base/profiler/scoped_tracker.h"
32 #include "base/stl_util.h" 32 #include "base/stl_util.h"
33 #include "base/strings/string_util.h" 33 #include "base/strings/string_util.h"
34 #include "base/third_party/dynamic_annotations/dynamic_annotations.h" 34 #include "base/third_party/dynamic_annotations/dynamic_annotations.h"
35 #include "base/threading/thread_task_runner_handle.h"
35 #include "base/timer/timer.h" 36 #include "base/timer/timer.h"
36 #include "content/browser/appcache/appcache_interceptor.h" 37 #include "content/browser/appcache/appcache_interceptor.h"
37 #include "content/browser/appcache/appcache_navigation_handle_core.h" 38 #include "content/browser/appcache/appcache_navigation_handle_core.h"
38 #include "content/browser/appcache/chrome_appcache_service.h" 39 #include "content/browser/appcache/chrome_appcache_service.h"
39 #include "content/browser/bad_message.h" 40 #include "content/browser/bad_message.h"
40 #include "content/browser/blob_storage/chrome_blob_storage_context.h" 41 #include "content/browser/blob_storage/chrome_blob_storage_context.h"
41 #include "content/browser/child_process_security_policy_impl.h" 42 #include "content/browser/child_process_security_policy_impl.h"
42 #include "content/browser/frame_host/navigation_request_info.h" 43 #include "content/browser/frame_host/navigation_request_info.h"
43 #include "content/browser/loader/async_resource_handler.h" 44 #include "content/browser/loader/async_resource_handler.h"
44 #include "content/browser/loader/detachable_resource_handler.h" 45 #include "content/browser/loader/detachable_resource_handler.h"
(...skipping 286 matching lines...) Expand 10 before | Expand all | Expand 10 after
331 332
332 ResourceDispatcherHostImpl::HeaderInterceptorInfo::HeaderInterceptorInfo( 333 ResourceDispatcherHostImpl::HeaderInterceptorInfo::HeaderInterceptorInfo(
333 const HeaderInterceptorInfo& other) {} 334 const HeaderInterceptorInfo& other) {}
334 335
335 // static 336 // static
336 ResourceDispatcherHost* ResourceDispatcherHost::Get() { 337 ResourceDispatcherHost* ResourceDispatcherHost::Get() {
337 return g_resource_dispatcher_host; 338 return g_resource_dispatcher_host;
338 } 339 }
339 340
340 ResourceDispatcherHostImpl::ResourceDispatcherHostImpl( 341 ResourceDispatcherHostImpl::ResourceDispatcherHostImpl(
341 CreateDownloadHandlerIntercept download_handler_intercept) 342 CreateDownloadHandlerIntercept download_handler_intercept,
343 const scoped_refptr<base::SingleThreadTaskRunner>& main_thread_runner,
jam 2017/04/03 14:47:03 since RDH is always created on the main thread, no
ananta 2017/04/03 22:58:19 Done.
344 const scoped_refptr<base::SingleThreadTaskRunner>& io_thread_runner)
342 : request_id_(-1), 345 : request_id_(-1),
343 is_shutdown_(false), 346 is_shutdown_(false),
344 num_in_flight_requests_(0), 347 num_in_flight_requests_(0),
345 max_num_in_flight_requests_(base::SharedMemory::GetHandleLimit()), 348 max_num_in_flight_requests_(base::SharedMemory::GetHandleLimit()),
346 max_num_in_flight_requests_per_process_(static_cast<int>( 349 max_num_in_flight_requests_per_process_(static_cast<int>(
347 max_num_in_flight_requests_ * kMaxRequestsPerProcessRatio)), 350 max_num_in_flight_requests_ * kMaxRequestsPerProcessRatio)),
348 max_outstanding_requests_cost_per_process_( 351 max_outstanding_requests_cost_per_process_(
349 kMaxOutstandingRequestsCostPerProcess), 352 kMaxOutstandingRequestsCostPerProcess),
350 delegate_(nullptr), 353 delegate_(nullptr),
351 loader_delegate_(nullptr), 354 loader_delegate_(nullptr),
352 allow_cross_origin_auth_prompt_(false), 355 allow_cross_origin_auth_prompt_(false),
353 create_download_handler_intercept_(download_handler_intercept) { 356 create_download_handler_intercept_(download_handler_intercept),
354 DCHECK_CURRENTLY_ON(BrowserThread::UI); 357 main_thread_task_runner_(main_thread_runner),
358 io_thread_task_runner_(io_thread_runner) {
359 DCHECK(main_thread_task_runner_->BelongsToCurrentThread());
355 DCHECK(!g_resource_dispatcher_host); 360 DCHECK(!g_resource_dispatcher_host);
356 g_resource_dispatcher_host = this; 361 g_resource_dispatcher_host = this;
357 362
358 ANNOTATE_BENIGN_RACE( 363 ANNOTATE_BENIGN_RACE(
359 &last_user_gesture_time_, 364 &last_user_gesture_time_,
360 "We don't care about the precise value, see http://crbug.com/92889"); 365 "We don't care about the precise value, see http://crbug.com/92889");
361 366
362 BrowserThread::PostTask(BrowserThread::IO, 367 io_thread_task_runner_->PostTask(
363 FROM_HERE, 368 FROM_HERE,
364 base::Bind(&ResourceDispatcherHostImpl::OnInit, 369 base::Bind(&ResourceDispatcherHostImpl::OnInit, base::Unretained(this)));
365 base::Unretained(this)));
366 370
367 update_load_states_timer_.reset(new base::RepeatingTimer()); 371 update_load_states_timer_.reset(new base::RepeatingTimer());
368 } 372 }
369 373
374 // The default ctor is only used by unittests. It is reasonable to assume that
375 // the main thread and the IO thread are the same for unittests.
370 ResourceDispatcherHostImpl::ResourceDispatcherHostImpl() 376 ResourceDispatcherHostImpl::ResourceDispatcherHostImpl()
371 : ResourceDispatcherHostImpl(CreateDownloadHandlerIntercept()) {} 377 : ResourceDispatcherHostImpl(CreateDownloadHandlerIntercept(),
378 base::ThreadTaskRunnerHandle::Get(),
379 base::ThreadTaskRunnerHandle::Get()) {}
372 380
373 ResourceDispatcherHostImpl::~ResourceDispatcherHostImpl() { 381 ResourceDispatcherHostImpl::~ResourceDispatcherHostImpl() {
374 DCHECK(outstanding_requests_stats_map_.empty()); 382 DCHECK(outstanding_requests_stats_map_.empty());
375 DCHECK(g_resource_dispatcher_host); 383 DCHECK(g_resource_dispatcher_host);
376 DCHECK_CURRENTLY_ON(BrowserThread::UI); 384 DCHECK(main_thread_task_runner_->BelongsToCurrentThread());
377 g_resource_dispatcher_host = NULL; 385 g_resource_dispatcher_host = NULL;
378 } 386 }
379 387
380 // static 388 // static
381 ResourceDispatcherHostImpl* ResourceDispatcherHostImpl::Get() { 389 ResourceDispatcherHostImpl* ResourceDispatcherHostImpl::Get() {
382 return g_resource_dispatcher_host; 390 return g_resource_dispatcher_host;
383 } 391 }
384 392
385 void ResourceDispatcherHostImpl::SetDelegate( 393 void ResourceDispatcherHostImpl::SetDelegate(
386 ResourceDispatcherHostDelegate* delegate) { 394 ResourceDispatcherHostDelegate* delegate) {
387 delegate_ = delegate; 395 delegate_ = delegate;
388 } 396 }
389 397
390 void ResourceDispatcherHostImpl::SetAllowCrossOriginAuthPrompt(bool value) { 398 void ResourceDispatcherHostImpl::SetAllowCrossOriginAuthPrompt(bool value) {
391 allow_cross_origin_auth_prompt_ = value; 399 allow_cross_origin_auth_prompt_ = value;
392 } 400 }
393 401
394 void ResourceDispatcherHostImpl::CancelRequestsForContext( 402 void ResourceDispatcherHostImpl::CancelRequestsForContext(
395 ResourceContext* context) { 403 ResourceContext* context) {
396 DCHECK_CURRENTLY_ON(BrowserThread::IO); 404 DCHECK(io_thread_task_runner_->BelongsToCurrentThread());
397 DCHECK(context); 405 DCHECK(context);
398 406
399 // Note that request cancellation has side effects. Therefore, we gather all 407 // Note that request cancellation has side effects. Therefore, we gather all
400 // the requests to cancel first, and then we start cancelling. We assert at 408 // the requests to cancel first, and then we start cancelling. We assert at
401 // the end that there are no more to cancel since the context is about to go 409 // the end that there are no more to cancel since the context is about to go
402 // away. 410 // away.
403 typedef std::vector<std::unique_ptr<ResourceLoader>> LoaderList; 411 typedef std::vector<std::unique_ptr<ResourceLoader>> LoaderList;
404 LoaderList loaders_to_cancel; 412 LoaderList loaders_to_cancel;
405 413
406 for (LoaderMap::iterator i = pending_loaders_.begin(); 414 for (LoaderMap::iterator i = pending_loaders_.begin();
(...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after
485 http_header_interceptor_map_.end()); 493 http_header_interceptor_map_.end());
486 494
487 HeaderInterceptorInfo interceptor_info; 495 HeaderInterceptorInfo interceptor_info;
488 interceptor_info.starts_with = starts_with; 496 interceptor_info.starts_with = starts_with;
489 interceptor_info.interceptor = interceptor; 497 interceptor_info.interceptor = interceptor;
490 498
491 http_header_interceptor_map_[http_header] = interceptor_info; 499 http_header_interceptor_map_[http_header] = interceptor_info;
492 } 500 }
493 501
494 void ResourceDispatcherHostImpl::Shutdown() { 502 void ResourceDispatcherHostImpl::Shutdown() {
495 DCHECK_CURRENTLY_ON(BrowserThread::UI); 503 DCHECK(main_thread_task_runner_->BelongsToCurrentThread());
496 BrowserThread::PostTask(BrowserThread::IO, 504 io_thread_task_runner_->PostTask(
497 FROM_HERE, 505 FROM_HERE, base::Bind(&ResourceDispatcherHostImpl::OnShutdown,
498 base::Bind(&ResourceDispatcherHostImpl::OnShutdown, 506 base::Unretained(this)));
499 base::Unretained(this)));
500 } 507 }
501 508
502 std::unique_ptr<ResourceHandler> 509 std::unique_ptr<ResourceHandler>
503 ResourceDispatcherHostImpl::CreateResourceHandlerForDownload( 510 ResourceDispatcherHostImpl::CreateResourceHandlerForDownload(
504 net::URLRequest* request, 511 net::URLRequest* request,
505 bool is_content_initiated, 512 bool is_content_initiated,
506 bool must_download, 513 bool must_download,
507 bool is_new_request) { 514 bool is_new_request) {
508 DCHECK(!create_download_handler_intercept_.is_null()); 515 DCHECK(!create_download_handler_intercept_.is_null());
509 // TODO(ananta) 516 // TODO(ananta)
(...skipping 263 matching lines...) Expand 10 before | Expand all | Expand 10 after
773 ResourceDispatcherHostImpl::CreateClientCertStore(ResourceLoader* loader) { 780 ResourceDispatcherHostImpl::CreateClientCertStore(ResourceLoader* loader) {
774 return delegate_->CreateClientCertStore( 781 return delegate_->CreateClientCertStore(
775 loader->GetRequestInfo()->GetContext()); 782 loader->GetRequestInfo()->GetContext());
776 } 783 }
777 784
778 void ResourceDispatcherHostImpl::OnInit() { 785 void ResourceDispatcherHostImpl::OnInit() {
779 scheduler_.reset(new ResourceScheduler); 786 scheduler_.reset(new ResourceScheduler);
780 } 787 }
781 788
782 void ResourceDispatcherHostImpl::OnShutdown() { 789 void ResourceDispatcherHostImpl::OnShutdown() {
783 DCHECK_CURRENTLY_ON(BrowserThread::IO); 790 DCHECK(io_thread_task_runner_->BelongsToCurrentThread());
784 791
785 is_shutdown_ = true; 792 is_shutdown_ = true;
786 pending_loaders_.clear(); 793 pending_loaders_.clear();
787 794
788 // Make sure we shutdown the timer now, otherwise by the time our destructor 795 // Make sure we shutdown the timer now, otherwise by the time our destructor
789 // runs if the timer is still running the Task is deleted twice (once by 796 // runs if the timer is still running the Task is deleted twice (once by
790 // the MessageLoop and the second time by RepeatingTimer). 797 // the MessageLoop and the second time by RepeatingTimer).
791 update_load_states_timer_.reset(); 798 update_load_states_timer_.reset();
792 799
793 // Clear blocked requests if any left. 800 // Clear blocked requests if any left.
(...skipping 10 matching lines...) Expand all
804 for (const auto& routing_id : ids) { 811 for (const auto& routing_id : ids) {
805 CancelBlockedRequestsForRoute(routing_id); 812 CancelBlockedRequestsForRoute(routing_id);
806 } 813 }
807 814
808 scheduler_.reset(); 815 scheduler_.reset();
809 } 816 }
810 817
811 bool ResourceDispatcherHostImpl::OnMessageReceived( 818 bool ResourceDispatcherHostImpl::OnMessageReceived(
812 const IPC::Message& message, 819 const IPC::Message& message,
813 ResourceRequesterInfo* requester_info) { 820 ResourceRequesterInfo* requester_info) {
814 DCHECK_CURRENTLY_ON(BrowserThread::IO); 821 DCHECK(io_thread_task_runner_->BelongsToCurrentThread());
815 822
816 bool handled = true; 823 bool handled = true;
817 IPC_BEGIN_MESSAGE_MAP_WITH_PARAM(ResourceDispatcherHostImpl, message, 824 IPC_BEGIN_MESSAGE_MAP_WITH_PARAM(ResourceDispatcherHostImpl, message,
818 requester_info) 825 requester_info)
819 IPC_MESSAGE_HANDLER(ResourceHostMsg_RequestResource, OnRequestResource) 826 IPC_MESSAGE_HANDLER(ResourceHostMsg_RequestResource, OnRequestResource)
820 IPC_MESSAGE_HANDLER_WITH_PARAM_DELAY_REPLY(ResourceHostMsg_SyncLoad, 827 IPC_MESSAGE_HANDLER_WITH_PARAM_DELAY_REPLY(ResourceHostMsg_SyncLoad,
821 OnSyncLoad) 828 OnSyncLoad)
822 IPC_MESSAGE_HANDLER(ResourceHostMsg_ReleaseDownloadedFile, 829 IPC_MESSAGE_HANDLER(ResourceHostMsg_ReleaseDownloadedFile,
823 OnReleaseDownloadedFile) 830 OnReleaseDownloadedFile)
824 IPC_MESSAGE_HANDLER(ResourceHostMsg_CancelRequest, OnCancelRequest) 831 IPC_MESSAGE_HANDLER(ResourceHostMsg_CancelRequest, OnCancelRequest)
(...skipping 693 matching lines...) Expand 10 before | Expand all | Expand 10 after
1518 delegate_->RequestBeginning(request, 1525 delegate_->RequestBeginning(request,
1519 resource_context, 1526 resource_context,
1520 appcache_service, 1527 appcache_service,
1521 resource_type, 1528 resource_type,
1522 &throttles); 1529 &throttles);
1523 } 1530 }
1524 1531
1525 if (request->has_upload()) { 1532 if (request->has_upload()) {
1526 // Block power save while uploading data. 1533 // Block power save while uploading data.
1527 throttles.push_back(base::MakeUnique<PowerSaveBlockResourceThrottle>( 1534 throttles.push_back(base::MakeUnique<PowerSaveBlockResourceThrottle>(
1528 request->url().host(), 1535 request->url().host(), main_thread_task_runner_,
1529 BrowserThread::GetTaskRunnerForThread(BrowserThread::UI),
1530 BrowserThread::GetTaskRunnerForThread(BrowserThread::FILE))); 1536 BrowserThread::GetTaskRunnerForThread(BrowserThread::FILE)));
1531 } 1537 }
1532 1538
1533 // TODO(ricea): Stop looking this up so much. 1539 // TODO(ricea): Stop looking this up so much.
1534 ResourceRequestInfoImpl* info = ResourceRequestInfoImpl::ForRequest(request); 1540 ResourceRequestInfoImpl* info = ResourceRequestInfoImpl::ForRequest(request);
1535 throttles.push_back(scheduler_->ScheduleRequest(child_id, route_id, 1541 throttles.push_back(scheduler_->ScheduleRequest(child_id, route_id,
1536 info->IsAsync(), request)); 1542 info->IsAsync(), request));
1537 1543
1538 // Split the handler in two groups: the ones that need to execute 1544 // Split the handler in two groups: the ones that need to execute
1539 // WillProcessResponse before mime sniffing and the others. 1545 // WillProcessResponse before mime sniffing and the others.
(...skipping 655 matching lines...) Expand 10 before | Expand all | Expand 10 after
2195 2201
2196 void ResourceDispatcherHostImpl::InitializeURLRequest( 2202 void ResourceDispatcherHostImpl::InitializeURLRequest(
2197 net::URLRequest* request, 2203 net::URLRequest* request,
2198 const Referrer& referrer, 2204 const Referrer& referrer,
2199 bool is_download, 2205 bool is_download,
2200 int render_process_host_id, 2206 int render_process_host_id,
2201 int render_view_routing_id, 2207 int render_view_routing_id,
2202 int render_frame_routing_id, 2208 int render_frame_routing_id,
2203 PreviewsState previews_state, 2209 PreviewsState previews_state,
2204 ResourceContext* context) { 2210 ResourceContext* context) {
2205 DCHECK_CURRENTLY_ON(BrowserThread::IO); 2211 DCHECK(io_thread_task_runner_->BelongsToCurrentThread());
2206 DCHECK(!request->is_pending()); 2212 DCHECK(!request->is_pending());
2207 2213
2208 Referrer::SetReferrerForRequest(request, referrer); 2214 Referrer::SetReferrerForRequest(request, referrer);
2209 2215
2210 ResourceRequestInfoImpl* info = CreateRequestInfo( 2216 ResourceRequestInfoImpl* info = CreateRequestInfo(
2211 render_process_host_id, render_view_routing_id, render_frame_routing_id, 2217 render_process_host_id, render_view_routing_id, render_frame_routing_id,
2212 previews_state, is_download, context); 2218 previews_state, is_download, context);
2213 // Request takes ownership. 2219 // Request takes ownership.
2214 info->AssociateWithRequest(request); 2220 info->AssociateWithRequest(request);
2215 } 2221 }
2216 2222
2217 void ResourceDispatcherHostImpl::BeginURLRequest( 2223 void ResourceDispatcherHostImpl::BeginURLRequest(
2218 std::unique_ptr<net::URLRequest> request, 2224 std::unique_ptr<net::URLRequest> request,
2219 std::unique_ptr<ResourceHandler> handler, 2225 std::unique_ptr<ResourceHandler> handler,
2220 bool is_download, 2226 bool is_download,
2221 bool is_content_initiated, 2227 bool is_content_initiated,
2222 bool do_not_prompt_for_login, 2228 bool do_not_prompt_for_login,
2223 ResourceContext* context) { 2229 ResourceContext* context) {
2224 DCHECK_CURRENTLY_ON(BrowserThread::IO); 2230 DCHECK(io_thread_task_runner_->BelongsToCurrentThread());
2225 DCHECK(!request->is_pending()); 2231 DCHECK(!request->is_pending());
2226 2232
2227 ResourceRequestInfoImpl* info = 2233 ResourceRequestInfoImpl* info =
2228 ResourceRequestInfoImpl::ForRequest(request.get()); 2234 ResourceRequestInfoImpl::ForRequest(request.get());
2229 DCHECK(info); 2235 DCHECK(info);
2230 info->set_do_not_prompt_for_login(do_not_prompt_for_login); 2236 info->set_do_not_prompt_for_login(do_not_prompt_for_login);
2231 2237
2232 // TODO(ananta) 2238 // TODO(ananta)
2233 // Find a better place for notifying the delegate about the download start. 2239 // Find a better place for notifying the delegate about the download start.
2234 if (is_download && delegate()) { 2240 if (is_download && delegate()) {
(...skipping 11 matching lines...) Expand all
2246 request->original_url())); 2252 request->original_url()));
2247 } 2253 }
2248 handler = HandleDownloadStarted( 2254 handler = HandleDownloadStarted(
2249 request.get(), std::move(handler), is_content_initiated, 2255 request.get(), std::move(handler), is_content_initiated,
2250 true /* force_download */, true /* is_new_request */); 2256 true /* force_download */, true /* is_new_request */);
2251 } 2257 }
2252 BeginRequestInternal(std::move(request), std::move(handler)); 2258 BeginRequestInternal(std::move(request), std::move(handler));
2253 } 2259 }
2254 2260
2255 int ResourceDispatcherHostImpl::MakeRequestID() { 2261 int ResourceDispatcherHostImpl::MakeRequestID() {
2256 DCHECK_CURRENTLY_ON(BrowserThread::IO); 2262 DCHECK(io_thread_task_runner_->BelongsToCurrentThread());
2257 return --request_id_; 2263 return --request_id_;
2258 } 2264 }
2259 2265
2260 void ResourceDispatcherHostImpl::CancelRequestFromRenderer( 2266 void ResourceDispatcherHostImpl::CancelRequestFromRenderer(
2261 GlobalRequestID request_id) { 2267 GlobalRequestID request_id) {
2262 // When the old renderer dies, it sends a message to us to cancel its 2268 // When the old renderer dies, it sends a message to us to cancel its
2263 // requests. 2269 // requests.
2264 if (IsTransferredNavigation(request_id)) 2270 if (IsTransferredNavigation(request_id))
2265 return; 2271 return;
2266 2272
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after
2320 2326
2321 if (a_uploading_size != b_uploading_size) 2327 if (a_uploading_size != b_uploading_size)
2322 return a_uploading_size > b_uploading_size; 2328 return a_uploading_size > b_uploading_size;
2323 2329
2324 return a.load_state.state > b.load_state.state; 2330 return a.load_state.state > b.load_state.state;
2325 } 2331 }
2326 2332
2327 // static 2333 // static
2328 void ResourceDispatcherHostImpl::UpdateLoadStateOnUI( 2334 void ResourceDispatcherHostImpl::UpdateLoadStateOnUI(
2329 LoaderDelegate* loader_delegate, std::unique_ptr<LoadInfoList> infos) { 2335 LoaderDelegate* loader_delegate, std::unique_ptr<LoadInfoList> infos) {
2330 DCHECK_CURRENTLY_ON(BrowserThread::UI); 2336 DCHECK(Get()->main_thread_task_runner_->BelongsToCurrentThread());
2337
2331 std::unique_ptr<LoadInfoMap> info_map = 2338 std::unique_ptr<LoadInfoMap> info_map =
2332 PickMoreInterestingLoadInfos(std::move(infos)); 2339 PickMoreInterestingLoadInfos(std::move(infos));
2333 for (const auto& load_info: *info_map) { 2340 for (const auto& load_info: *info_map) {
2334 loader_delegate->LoadStateChanged( 2341 loader_delegate->LoadStateChanged(
2335 load_info.first, 2342 load_info.first,
2336 load_info.second.url, load_info.second.load_state, 2343 load_info.second.url, load_info.second.load_state,
2337 load_info.second.upload_position, load_info.second.upload_size); 2344 load_info.second.upload_position, load_info.second.upload_size);
2338 } 2345 }
2339 } 2346 }
2340 2347
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after
2387 if (infos->empty() || !scheduler_->HasLoadingClients()) { 2394 if (infos->empty() || !scheduler_->HasLoadingClients()) {
2388 update_load_states_timer_->Stop(); 2395 update_load_states_timer_->Stop();
2389 return; 2396 return;
2390 } 2397 }
2391 2398
2392 // We need to be able to compare all requests to find the most important one 2399 // We need to be able to compare all requests to find the most important one
2393 // per tab. Since some requests may be navigation requests and we don't have 2400 // per tab. Since some requests may be navigation requests and we don't have
2394 // their render frame routing IDs yet (which is what we have for subresource 2401 // their render frame routing IDs yet (which is what we have for subresource
2395 // requests), we must go to the UI thread and compare the requests using their 2402 // requests), we must go to the UI thread and compare the requests using their
2396 // WebContents. 2403 // WebContents.
2397 BrowserThread::PostTask( 2404 main_thread_task_runner_->PostTask(
2398 BrowserThread::UI, 2405 FROM_HERE,
2399 FROM_HERE, 2406 base::Bind(UpdateLoadStateOnUI, loader_delegate_, base::Passed(&infos)));
2400 base::Bind(UpdateLoadStateOnUI,
2401 loader_delegate_, base::Passed(&infos)));
2402 } 2407 }
2403 2408
2404 void ResourceDispatcherHostImpl::BlockRequestsForRoute( 2409 void ResourceDispatcherHostImpl::BlockRequestsForRoute(
2405 const GlobalFrameRoutingId& global_routing_id) { 2410 const GlobalFrameRoutingId& global_routing_id) {
2406 DCHECK_CURRENTLY_ON(BrowserThread::IO); 2411 DCHECK(io_thread_task_runner_->BelongsToCurrentThread());
2407 DCHECK(blocked_loaders_map_.find(global_routing_id) == 2412 DCHECK(blocked_loaders_map_.find(global_routing_id) ==
2408 blocked_loaders_map_.end()) 2413 blocked_loaders_map_.end())
2409 << "BlockRequestsForRoute called multiple time for the same RFH"; 2414 << "BlockRequestsForRoute called multiple time for the same RFH";
2410 blocked_loaders_map_[global_routing_id] = 2415 blocked_loaders_map_[global_routing_id] =
2411 base::MakeUnique<BlockedLoadersList>(); 2416 base::MakeUnique<BlockedLoadersList>();
2412 } 2417 }
2413 2418
2414 void ResourceDispatcherHostImpl::ResumeBlockedRequestsForRoute( 2419 void ResourceDispatcherHostImpl::ResumeBlockedRequestsForRoute(
2415 const GlobalFrameRoutingId& global_routing_id) { 2420 const GlobalFrameRoutingId& global_routing_id) {
2416 ProcessBlockedRequestsForRoute(global_routing_id, false); 2421 ProcessBlockedRequestsForRoute(global_routing_id, false);
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after
2471 } 2476 }
2472 2477
2473 bool ResourceDispatcherHostImpl::IsTransferredNavigation( 2478 bool ResourceDispatcherHostImpl::IsTransferredNavigation(
2474 const GlobalRequestID& id) const { 2479 const GlobalRequestID& id) const {
2475 ResourceLoader* loader = GetLoader(id); 2480 ResourceLoader* loader = GetLoader(id);
2476 return loader ? loader->is_transferring() : false; 2481 return loader ? loader->is_transferring() : false;
2477 } 2482 }
2478 2483
2479 ResourceLoader* ResourceDispatcherHostImpl::GetLoader( 2484 ResourceLoader* ResourceDispatcherHostImpl::GetLoader(
2480 const GlobalRequestID& id) const { 2485 const GlobalRequestID& id) const {
2481 DCHECK_CURRENTLY_ON(BrowserThread::IO); 2486 DCHECK(io_thread_task_runner_->BelongsToCurrentThread());
2482 2487
2483 LoaderMap::const_iterator i = pending_loaders_.find(id); 2488 LoaderMap::const_iterator i = pending_loaders_.find(id);
2484 if (i == pending_loaders_.end()) 2489 if (i == pending_loaders_.end())
2485 return NULL; 2490 return NULL;
2486 2491
2487 return i->second.get(); 2492 return i->second.get();
2488 } 2493 }
2489 2494
2490 ResourceLoader* ResourceDispatcherHostImpl::GetLoader(int child_id, 2495 ResourceLoader* ResourceDispatcherHostImpl::GetLoader(int child_id,
2491 int request_id) const { 2496 int request_id) const {
(...skipping 121 matching lines...) Expand 10 before | Expand all | Expand 10 after
2613 &throttles); 2618 &throttles);
2614 if (!throttles.empty()) { 2619 if (!throttles.empty()) {
2615 handler.reset(new ThrottlingResourceHandler(std::move(handler), request, 2620 handler.reset(new ThrottlingResourceHandler(std::move(handler), request,
2616 std::move(throttles))); 2621 std::move(throttles)));
2617 } 2622 }
2618 } 2623 }
2619 return handler; 2624 return handler;
2620 } 2625 }
2621 2626
2622 } // namespace content 2627 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698