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

Side by Side Diff: content/child/url_loader_client_impl.cc

Issue 2926693002: Make content::ThrottlingURLLoader take a task runner and more efficient. (Closed)
Patch Set: sync & resolve Created 3 years, 6 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
« no previous file with comments | « content/child/url_loader_client_impl.h ('k') | content/common/throttling_url_loader.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2016 The Chromium Authors. All rights reserved. 1 // Copyright 2016 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/child/url_loader_client_impl.h" 5 #include "content/child/url_loader_client_impl.h"
6 6
7 #include "base/callback.h" 7 #include "base/callback.h"
8 #include "base/single_thread_task_runner.h" 8 #include "base/single_thread_task_runner.h"
9 #include "content/child/resource_dispatcher.h" 9 #include "content/child/resource_dispatcher.h"
10 #include "content/child/url_response_body_consumer.h" 10 #include "content/child/url_response_body_consumer.h"
11 #include "content/common/resource_messages.h" 11 #include "content/common/resource_messages.h"
12 #include "net/url_request/redirect_info.h" 12 #include "net/url_request/redirect_info.h"
13 13
14 namespace content { 14 namespace content {
15 15
16 URLLoaderClientImpl::URLLoaderClientImpl( 16 URLLoaderClientImpl::URLLoaderClientImpl(
17 int request_id, 17 int request_id,
18 ResourceDispatcher* resource_dispatcher, 18 ResourceDispatcher* resource_dispatcher,
19 scoped_refptr<base::SingleThreadTaskRunner> task_runner) 19 scoped_refptr<base::SingleThreadTaskRunner> task_runner)
20 : binding_(this), 20 : request_id_(request_id),
21 request_id_(request_id),
22 resource_dispatcher_(resource_dispatcher), 21 resource_dispatcher_(resource_dispatcher),
23 task_runner_(std::move(task_runner)), 22 task_runner_(std::move(task_runner)),
24 weak_factory_(this) {} 23 weak_factory_(this) {}
25 24
26 URLLoaderClientImpl::~URLLoaderClientImpl() { 25 URLLoaderClientImpl::~URLLoaderClientImpl() {
27 if (body_consumer_) 26 if (body_consumer_)
28 body_consumer_->Cancel(); 27 body_consumer_->Cancel();
29 } 28 }
30 29
31 void URLLoaderClientImpl::Bind(mojom::URLLoaderClientPtr* client_ptr) {
32 binding_.Bind(mojo::MakeRequest(client_ptr), task_runner_);
33 }
34
35 void URLLoaderClientImpl::SetDefersLoading() { 30 void URLLoaderClientImpl::SetDefersLoading() {
36 is_deferred_ = true; 31 is_deferred_ = true;
37 if (body_consumer_) 32 if (body_consumer_)
38 body_consumer_->SetDefersLoading(); 33 body_consumer_->SetDefersLoading();
39 } 34 }
40 35
41 void URLLoaderClientImpl::UnsetDefersLoading() { 36 void URLLoaderClientImpl::UnsetDefersLoading() {
42 is_deferred_ = false; 37 is_deferred_ = false;
43 } 38 }
44 39
(...skipping 165 matching lines...) Expand 10 before | Expand all | Expand 10 after
210 StoreAndDispatch( 205 StoreAndDispatch(
211 ResourceMsg_UploadProgress(request_id_, current_position, total_size)); 206 ResourceMsg_UploadProgress(request_id_, current_position, total_size));
212 } else { 207 } else {
213 resource_dispatcher_->OnUploadProgress(request_id_, current_position, 208 resource_dispatcher_->OnUploadProgress(request_id_, current_position,
214 total_size); 209 total_size);
215 } 210 }
216 std::move(ack_callback).Run(); 211 std::move(ack_callback).Run();
217 } 212 }
218 213
219 } // namespace content 214 } // namespace content
OLDNEW
« no previous file with comments | « content/child/url_loader_client_impl.h ('k') | content/common/throttling_url_loader.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698