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

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

Issue 1544293002: Convert Pass()→std::move() in //content (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 12 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 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 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/web_url_loader_impl.h" 5 #include "content/child/web_url_loader_impl.h"
6 6
7 #include <stdint.h> 7 #include <stdint.h>
8
9 #include <algorithm> 8 #include <algorithm>
10 #include <string> 9 #include <string>
10 #include <utility>
11 11
12 #include "base/bind.h" 12 #include "base/bind.h"
13 #include "base/files/file_path.h" 13 #include "base/files/file_path.h"
14 #include "base/logging.h" 14 #include "base/logging.h"
15 #include "base/memory/scoped_ptr.h" 15 #include "base/memory/scoped_ptr.h"
16 #include "base/single_thread_task_runner.h" 16 #include "base/single_thread_task_runner.h"
17 #include "base/strings/string_util.h" 17 #include "base/strings/string_util.h"
18 #include "base/time/time.h" 18 #include "base/time/time.h"
19 #include "build/build_config.h" 19 #include "build/build_config.h"
20 #include "components/mime_util/mime_util.h" 20 #include "components/mime_util/mime_util.h"
(...skipping 313 matching lines...) Expand 10 before | Expand all | Expand 10 after
334 int request_id_; 334 int request_id_;
335 }; 335 };
336 336
337 WebURLLoaderImpl::Context::Context( 337 WebURLLoaderImpl::Context::Context(
338 WebURLLoaderImpl* loader, 338 WebURLLoaderImpl* loader,
339 ResourceDispatcher* resource_dispatcher, 339 ResourceDispatcher* resource_dispatcher,
340 scoped_ptr<blink::WebTaskRunner> web_task_runner) 340 scoped_ptr<blink::WebTaskRunner> web_task_runner)
341 : loader_(loader), 341 : loader_(loader),
342 client_(NULL), 342 client_(NULL),
343 resource_dispatcher_(resource_dispatcher), 343 resource_dispatcher_(resource_dispatcher),
344 web_task_runner_(web_task_runner.Pass()), 344 web_task_runner_(std::move(web_task_runner)),
345 referrer_policy_(blink::WebReferrerPolicyDefault), 345 referrer_policy_(blink::WebReferrerPolicyDefault),
346 defers_loading_(NOT_DEFERRING), 346 defers_loading_(NOT_DEFERRING),
347 request_id_(-1) { 347 request_id_(-1) {}
348 }
349 348
350 void WebURLLoaderImpl::Context::Cancel() { 349 void WebURLLoaderImpl::Context::Cancel() {
351 if (resource_dispatcher_ && // NULL in unittest. 350 if (resource_dispatcher_ && // NULL in unittest.
352 request_id_ != -1) { 351 request_id_ != -1) {
353 resource_dispatcher_->Cancel(request_id_); 352 resource_dispatcher_->Cancel(request_id_);
354 request_id_ = -1; 353 request_id_ = -1;
355 } 354 }
356 355
357 if (body_stream_writer_) 356 if (body_stream_writer_)
358 body_stream_writer_->Fail(); 357 body_stream_writer_->Fail();
(...skipping 154 matching lines...) Expand 10 before | Expand all | Expand 10 after
513 request_info, request_body.get(), sync_load_response); 512 request_info, request_body.get(), sync_load_response);
514 return; 513 return;
515 } 514 }
516 515
517 request_id_ = resource_dispatcher_->StartAsync( 516 request_id_ = resource_dispatcher_->StartAsync(
518 request_info, request_body.get(), this); 517 request_info, request_body.get(), this);
519 } 518 }
520 519
521 void WebURLLoaderImpl::Context::SetWebTaskRunner( 520 void WebURLLoaderImpl::Context::SetWebTaskRunner(
522 scoped_ptr<blink::WebTaskRunner> web_task_runner) { 521 scoped_ptr<blink::WebTaskRunner> web_task_runner) {
523 web_task_runner_ = web_task_runner.Pass(); 522 web_task_runner_ = std::move(web_task_runner);
524 } 523 }
525 524
526 void WebURLLoaderImpl::Context::OnUploadProgress(uint64_t position, 525 void WebURLLoaderImpl::Context::OnUploadProgress(uint64_t position,
527 uint64_t size) { 526 uint64_t size) {
528 if (client_) 527 if (client_)
529 client_->didSendData(loader_, position, size); 528 client_->didSendData(loader_, position, size);
530 } 529 }
531 530
532 bool WebURLLoaderImpl::Context::OnReceivedRedirect( 531 bool WebURLLoaderImpl::Context::OnReceivedRedirect(
533 const net::RedirectInfo& redirect_info, 532 const net::RedirectInfo& redirect_info,
(...skipping 159 matching lines...) Expand 10 before | Expand all | Expand 10 after
693 } else { 692 } else {
694 scoped_refptr<Context> protect(this); 693 scoped_refptr<Context> protect(this);
695 // We dispatch the data even when |useStreamOnResponse()| is set, in order 694 // We dispatch the data even when |useStreamOnResponse()| is set, in order
696 // to make Devtools work. 695 // to make Devtools work.
697 client_->didReceiveData(loader_, payload, data_length, encoded_data_length); 696 client_->didReceiveData(loader_, payload, data_length, encoded_data_length);
698 697
699 if (request_.useStreamOnResponse()) { 698 if (request_.useStreamOnResponse()) {
700 // We don't support ftp_listening_delegate_ and multipart_delegate_ for 699 // We don't support ftp_listening_delegate_ and multipart_delegate_ for
701 // now. 700 // now.
702 // TODO(yhirano): Support ftp listening and multipart. 701 // TODO(yhirano): Support ftp listening and multipart.
703 body_stream_writer_->AddData(data.Pass()); 702 body_stream_writer_->AddData(std::move(data));
704 } 703 }
705 } 704 }
706 } 705 }
707 706
708 void WebURLLoaderImpl::Context::OnReceivedCachedMetadata( 707 void WebURLLoaderImpl::Context::OnReceivedCachedMetadata(
709 const char* data, int len) { 708 const char* data, int len) {
710 if (client_) 709 if (client_)
711 client_->didReceiveCachedMetadata(loader_, data, len); 710 client_->didReceiveCachedMetadata(loader_, data, len);
712 } 711 }
713 712
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after
756 int error_code, 755 int error_code,
757 bool was_ignored_by_handler, 756 bool was_ignored_by_handler,
758 bool stale_copy_in_cache, 757 bool stale_copy_in_cache,
759 const std::string& security_info, 758 const std::string& security_info,
760 const base::TimeTicks& completion_time, 759 const base::TimeTicks& completion_time,
761 int64_t total_transfer_size) { 760 int64_t total_transfer_size) {
762 scoped_refptr<Context> protect(this); 761 scoped_refptr<Context> protect(this);
763 762
764 OnReceivedResponse(info); 763 OnReceivedResponse(info);
765 if (data) 764 if (data)
766 OnReceivedData(data.Pass()); 765 OnReceivedData(std::move(data));
767 OnCompletedRequest(error_code, was_ignored_by_handler, stale_copy_in_cache, 766 OnCompletedRequest(error_code, was_ignored_by_handler, stale_copy_in_cache,
768 security_info, completion_time, total_transfer_size); 767 security_info, completion_time, total_transfer_size);
769 } 768 }
770 769
771 WebURLLoaderImpl::Context::~Context() { 770 WebURLLoaderImpl::Context::~Context() {
772 if (request_id_ >= 0) { 771 if (request_id_ >= 0) {
773 resource_dispatcher_->RemovePendingRequest(request_id_); 772 resource_dispatcher_->RemovePendingRequest(request_id_);
774 } 773 }
775 } 774 }
776 775
(...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after
862 861
863 OnCompletedRequest(error_code, false, false, info.security_info, 862 OnCompletedRequest(error_code, false, false, info.security_info,
864 base::TimeTicks::Now(), 0); 863 base::TimeTicks::Now(), 0);
865 } 864 }
866 865
867 // WebURLLoaderImpl ----------------------------------------------------------- 866 // WebURLLoaderImpl -----------------------------------------------------------
868 867
869 WebURLLoaderImpl::WebURLLoaderImpl( 868 WebURLLoaderImpl::WebURLLoaderImpl(
870 ResourceDispatcher* resource_dispatcher, 869 ResourceDispatcher* resource_dispatcher,
871 scoped_ptr<blink::WebTaskRunner> web_task_runner) 870 scoped_ptr<blink::WebTaskRunner> web_task_runner)
872 : context_(new Context(this, resource_dispatcher, web_task_runner.Pass())) { 871 : context_(
873 } 872 new Context(this, resource_dispatcher, std::move(web_task_runner))) {}
874 873
875 WebURLLoaderImpl::~WebURLLoaderImpl() { 874 WebURLLoaderImpl::~WebURLLoaderImpl() {
876 cancel(); 875 cancel();
877 } 876 }
878 877
879 void WebURLLoaderImpl::PopulateURLResponse(const GURL& url, 878 void WebURLLoaderImpl::PopulateURLResponse(const GURL& url,
880 const ResourceResponseInfo& info, 879 const ResourceResponseInfo& info,
881 WebURLResponse* response, 880 WebURLResponse* response,
882 bool report_security_info) { 881 bool report_security_info) {
883 response->setURL(url); 882 response->setURL(url);
(...skipping 207 matching lines...) Expand 10 before | Expand all | Expand 10 after
1091 } 1090 }
1092 1091
1093 void WebURLLoaderImpl::setLoadingTaskRunner( 1092 void WebURLLoaderImpl::setLoadingTaskRunner(
1094 blink::WebTaskRunner* loading_task_runner) { 1093 blink::WebTaskRunner* loading_task_runner) {
1095 // There's no guarantee on the lifetime of |loading_task_runner| so we take a 1094 // There's no guarantee on the lifetime of |loading_task_runner| so we take a
1096 // copy. 1095 // copy.
1097 context_->SetWebTaskRunner(make_scoped_ptr(loading_task_runner->clone())); 1096 context_->SetWebTaskRunner(make_scoped_ptr(loading_task_runner->clone()));
1098 } 1097 }
1099 1098
1100 } // namespace content 1099 } // namespace content
OLDNEW
« no previous file with comments | « content/child/web_process_memory_dump_impl.cc ('k') | content/child/web_url_loader_impl_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698