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

Side by Side Diff: content/common/net/url_fetcher_impl.cc

Issue 8416055: Convert some non-debug logging on content/common to debug logging. (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: '' Created 9 years, 1 month 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
« no previous file with comments | « content/common/mac/font_loader.mm ('k') | content/common/npobject_stub.cc » ('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 (c) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 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/common/net/url_fetcher_impl.h" 5 #include "content/common/net/url_fetcher_impl.h"
6 6
7 #include <set> 7 #include <set>
8 8
9 #include "base/bind.h" 9 #include "base/bind.h"
10 #include "base/compiler_specific.h" 10 #include "base/compiler_specific.h"
(...skipping 316 matching lines...) Expand 10 before | Expand all | Expand 10 after
327 file_message_loop_proxy_(file_message_loop_proxy), 327 file_message_loop_proxy_(file_message_loop_proxy),
328 temp_file_handle_(base::kInvalidPlatformFileValue) { 328 temp_file_handle_(base::kInvalidPlatformFileValue) {
329 } 329 }
330 330
331 URLFetcherImpl::Core::TempFileWriter::~TempFileWriter() { 331 URLFetcherImpl::Core::TempFileWriter::~TempFileWriter() {
332 RemoveTempFile(); 332 RemoveTempFile();
333 } 333 }
334 334
335 void URLFetcherImpl::Core::TempFileWriter::CreateTempFile() { 335 void URLFetcherImpl::Core::TempFileWriter::CreateTempFile() {
336 DCHECK(core_->io_message_loop_proxy_->BelongsToCurrentThread()); 336 DCHECK(core_->io_message_loop_proxy_->BelongsToCurrentThread());
337 CHECK(file_message_loop_proxy_.get()); 337 DCHECK(file_message_loop_proxy_.get());
338 base::FileUtilProxy::CreateTemporary( 338 base::FileUtilProxy::CreateTemporary(
339 file_message_loop_proxy_, 339 file_message_loop_proxy_,
340 0, // No additional file flags. 340 0, // No additional file flags.
341 base::Bind(&URLFetcherImpl::Core::TempFileWriter::DidCreateTempFile, 341 base::Bind(&URLFetcherImpl::Core::TempFileWriter::DidCreateTempFile,
342 weak_factory_.GetWeakPtr())); 342 weak_factory_.GetWeakPtr()));
343 } 343 }
344 344
345 void URLFetcherImpl::Core::TempFileWriter::DidCreateTempFile( 345 void URLFetcherImpl::Core::TempFileWriter::DidCreateTempFile(
346 base::PlatformFileError error_code, 346 base::PlatformFileError error_code,
347 base::PassPlatformFile file_handle, 347 base::PassPlatformFile file_handle,
(...skipping 183 matching lines...) Expand 10 before | Expand all | Expand 10 after
531 } 531 }
532 532
533 URLFetcherImpl::Core::~Core() { 533 URLFetcherImpl::Core::~Core() {
534 // |request_| should be NULL. If not, it's unsafe to delete it here since we 534 // |request_| should be NULL. If not, it's unsafe to delete it here since we
535 // may not be on the IO thread. 535 // may not be on the IO thread.
536 DCHECK(!request_.get()); 536 DCHECK(!request_.get());
537 } 537 }
538 538
539 void URLFetcherImpl::Core::Start() { 539 void URLFetcherImpl::Core::Start() {
540 DCHECK(delegate_loop_proxy_); 540 DCHECK(delegate_loop_proxy_);
541 CHECK(request_context_getter_) << "We need an URLRequestContext!"; 541 DCHECK(request_context_getter_) << "We need an URLRequestContext!";
542 if (io_message_loop_proxy_) { 542 if (io_message_loop_proxy_) {
543 DCHECK_EQ(io_message_loop_proxy_, 543 DCHECK_EQ(io_message_loop_proxy_,
544 request_context_getter_->GetIOMessageLoopProxy()); 544 request_context_getter_->GetIOMessageLoopProxy());
545 } else { 545 } else {
546 io_message_loop_proxy_ = request_context_getter_->GetIOMessageLoopProxy(); 546 io_message_loop_proxy_ = request_context_getter_->GetIOMessageLoopProxy();
547 } 547 }
548 CHECK(io_message_loop_proxy_.get()) << "We need an IO message loop proxy"; 548 DCHECK(io_message_loop_proxy_.get()) << "We need an IO message loop proxy";
549 549
550 io_message_loop_proxy_->PostTask( 550 io_message_loop_proxy_->PostTask(
551 FROM_HERE, base::Bind(&Core::StartOnIOThread, this)); 551 FROM_HERE, base::Bind(&Core::StartOnIOThread, this));
552 } 552 }
553 553
554 void URLFetcherImpl::Core::StartOnIOThread() { 554 void URLFetcherImpl::Core::StartOnIOThread() {
555 DCHECK(io_message_loop_proxy_->BelongsToCurrentThread()); 555 DCHECK(io_message_loop_proxy_->BelongsToCurrentThread());
556 556
557 switch (response_destination_) { 557 switch (response_destination_) {
558 case STRING: 558 case STRING:
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after
619 DCHECK(request_.get()); 619 DCHECK(request_.get());
620 DCHECK(!content.empty()); 620 DCHECK(!content.empty());
621 request_->AppendChunkToUpload(content.data(), 621 request_->AppendChunkToUpload(content.data(),
622 static_cast<int>(content.length()), 622 static_cast<int>(content.length()),
623 is_last_chunk); 623 is_last_chunk);
624 } 624 }
625 625
626 void URLFetcherImpl::Core::AppendChunkToUpload(const std::string& content, 626 void URLFetcherImpl::Core::AppendChunkToUpload(const std::string& content,
627 bool is_last_chunk) { 627 bool is_last_chunk) {
628 DCHECK(delegate_loop_proxy_); 628 DCHECK(delegate_loop_proxy_);
629 CHECK(io_message_loop_proxy_.get()); 629 DCHECK(io_message_loop_proxy_.get());
630 io_message_loop_proxy_->PostTask( 630 io_message_loop_proxy_->PostTask(
631 FROM_HERE, 631 FROM_HERE,
632 base::Bind(&Core::CompleteAddingUploadDataChunk, this, content, 632 base::Bind(&Core::CompleteAddingUploadDataChunk, this, content,
633 is_last_chunk)); 633 is_last_chunk));
634 } 634 }
635 635
636 // Return true if the write was done and reading may continue. 636 // Return true if the write was done and reading may continue.
637 // Return false if the write is pending, and the next read will 637 // Return false if the write is pending, and the next read will
638 // be done later. 638 // be done later.
639 bool URLFetcherImpl::Core::WriteBuffer(int num_bytes) { 639 bool URLFetcherImpl::Core::WriteBuffer(int num_bytes) {
(...skipping 115 matching lines...) Expand 10 before | Expand all | Expand 10 after
755 755
756 void URLFetcherImpl::Core::StartURLRequest() { 756 void URLFetcherImpl::Core::StartURLRequest() {
757 DCHECK(io_message_loop_proxy_->BelongsToCurrentThread()); 757 DCHECK(io_message_loop_proxy_->BelongsToCurrentThread());
758 758
759 if (was_cancelled_) { 759 if (was_cancelled_) {
760 // Since StartURLRequest() is posted as a *delayed* task, it may 760 // Since StartURLRequest() is posted as a *delayed* task, it may
761 // run after the URLFetcher was already stopped. 761 // run after the URLFetcher was already stopped.
762 return; 762 return;
763 } 763 }
764 764
765 CHECK(request_context_getter_); 765 DCHECK(request_context_getter_);
766 DCHECK(!request_.get()); 766 DCHECK(!request_.get());
767 767
768 g_registry.Get().AddURLFetcherCore(this); 768 g_registry.Get().AddURLFetcherCore(this);
769 request_.reset(new net::URLRequest(original_url_, this)); 769 request_.reset(new net::URLRequest(original_url_, this));
770 int flags = request_->load_flags() | load_flags_; 770 int flags = request_->load_flags() | load_flags_;
771 if (!g_interception_enabled) { 771 if (!g_interception_enabled) {
772 flags = flags | net::LOAD_DISABLE_INTERCEPT; 772 flags = flags | net::LOAD_DISABLE_INTERCEPT;
773 } 773 }
774 if (is_chunked_upload_) 774 if (is_chunked_upload_)
775 request_->EnableChunkedUpload(); 775 request_->EnableChunkedUpload();
(...skipping 27 matching lines...) Expand all
803 } 803 }
804 804
805 if (!extra_request_headers_.IsEmpty()) 805 if (!extra_request_headers_.IsEmpty())
806 request_->SetExtraRequestHeaders(extra_request_headers_); 806 request_->SetExtraRequestHeaders(extra_request_headers_);
807 807
808 // There might be data left over from a previous request attempt. 808 // There might be data left over from a previous request attempt.
809 data_.clear(); 809 data_.clear();
810 810
811 // If we are writing the response to a file, the only caller 811 // If we are writing the response to a file, the only caller
812 // of this function should have created it and not written yet. 812 // of this function should have created it and not written yet.
813 CHECK(!temp_file_writer_.get() || 813 DCHECK(!temp_file_writer_.get() ||
814 temp_file_writer_->total_bytes_written() == 0); 814 temp_file_writer_->total_bytes_written() == 0);
815 815
816 request_->Start(); 816 request_->Start();
817 } 817 }
818 818
819 void URLFetcherImpl::Core::StartURLRequestWhenAppropriate() { 819 void URLFetcherImpl::Core::StartURLRequestWhenAppropriate() {
820 DCHECK(io_message_loop_proxy_->BelongsToCurrentThread()); 820 DCHECK(io_message_loop_proxy_->BelongsToCurrentThread());
821 821
822 if (was_cancelled_) 822 if (was_cancelled_)
823 return; 823 return;
824 824
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after
859 DCHECK(delegate_loop_proxy_->BelongsToCurrentThread()); 859 DCHECK(delegate_loop_proxy_->BelongsToCurrentThread());
860 860
861 // Save the status and backoff_delay so that delegates can read it. 861 // Save the status and backoff_delay so that delegates can read it.
862 if (delegate_) { 862 if (delegate_) {
863 backoff_delay_ = backoff_delay; 863 backoff_delay_ = backoff_delay;
864 InformDelegateFetchIsComplete(); 864 InformDelegateFetchIsComplete();
865 } 865 }
866 } 866 }
867 867
868 void URLFetcherImpl::Core::InformDelegateFetchIsComplete() { 868 void URLFetcherImpl::Core::InformDelegateFetchIsComplete() {
869 CHECK(delegate_loop_proxy_->BelongsToCurrentThread()); 869 DCHECK(delegate_loop_proxy_->BelongsToCurrentThread());
870 if (delegate_) { 870 if (delegate_) {
871 delegate_->OnURLFetchComplete(fetcher_); 871 delegate_->OnURLFetchComplete(fetcher_);
872 } 872 }
873 } 873 }
874 874
875 void URLFetcherImpl::Core::NotifyMalformedContent() { 875 void URLFetcherImpl::Core::NotifyMalformedContent() {
876 DCHECK(io_message_loop_proxy_->BelongsToCurrentThread()); 876 DCHECK(io_message_loop_proxy_->BelongsToCurrentThread());
877 if (url_throttler_entry_ != NULL) { 877 if (url_throttler_entry_ != NULL) {
878 int status_code = response_code_; 878 int status_code = response_code_;
879 if (status_code == RESPONSE_CODE_INVALID) { 879 if (status_code == RESPONSE_CODE_INVALID) {
(...skipping 225 matching lines...) Expand 10 before | Expand all | Expand 10 after
1105 1105
1106 // static 1106 // static
1107 content::URLFetcherFactory* URLFetcherImpl::factory() { 1107 content::URLFetcherFactory* URLFetcherImpl::factory() {
1108 return g_factory; 1108 return g_factory;
1109 } 1109 }
1110 1110
1111 // static 1111 // static
1112 void URLFetcherImpl::set_factory(content::URLFetcherFactory* factory) { 1112 void URLFetcherImpl::set_factory(content::URLFetcherFactory* factory) {
1113 g_factory = factory; 1113 g_factory = factory;
1114 } 1114 }
OLDNEW
« no previous file with comments | « content/common/mac/font_loader.mm ('k') | content/common/npobject_stub.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698