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

Side by Side Diff: chrome/browser/safe_browsing/protocol_manager.cc

Issue 16290004: Update chrome/ to use scoped_refptr<T>::get() rather than implicit "operator T*" (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 7 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 | Annotate | Revision Log
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 #include "chrome/browser/safe_browsing/protocol_manager.h" 5 #include "chrome/browser/safe_browsing/protocol_manager.h"
6 6
7 #ifndef NDEBUG 7 #ifndef NDEBUG
8 #include "base/base64.h" 8 #include "base/base64.h"
9 #endif 9 #endif
10 #include "base/environment.h" 10 #include "base/environment.h"
(...skipping 167 matching lines...) Expand 10 before | Expand all | Expand 10 after
178 GURL gethash_url = GetHashUrl(); 178 GURL gethash_url = GetHashUrl();
179 net::URLFetcher* fetcher = net::URLFetcher::Create( 179 net::URLFetcher* fetcher = net::URLFetcher::Create(
180 url_fetcher_id_++, gethash_url, net::URLFetcher::POST, this); 180 url_fetcher_id_++, gethash_url, net::URLFetcher::POST, this);
181 hash_requests_[fetcher] = FullHashDetails(callback, is_download); 181 hash_requests_[fetcher] = FullHashDetails(callback, is_download);
182 182
183 std::string get_hash; 183 std::string get_hash;
184 SafeBrowsingProtocolParser parser; 184 SafeBrowsingProtocolParser parser;
185 parser.FormatGetHash(prefixes, &get_hash); 185 parser.FormatGetHash(prefixes, &get_hash);
186 186
187 fetcher->SetLoadFlags(net::LOAD_DISABLE_CACHE); 187 fetcher->SetLoadFlags(net::LOAD_DISABLE_CACHE);
188 fetcher->SetRequestContext(request_context_getter_); 188 fetcher->SetRequestContext(request_context_getter_.get());
189 fetcher->SetUploadData("text/plain", get_hash); 189 fetcher->SetUploadData("text/plain", get_hash);
190 fetcher->Start(); 190 fetcher->Start();
191 } 191 }
192 192
193 void SafeBrowsingProtocolManager::GetNextUpdate() { 193 void SafeBrowsingProtocolManager::GetNextUpdate() {
194 DCHECK(CalledOnValidThread()); 194 DCHECK(CalledOnValidThread());
195 if (!request_.get() && request_type_ == NO_REQUEST) 195 if (!request_.get() && request_type_ == NO_REQUEST)
196 IssueUpdateRequest(); 196 IssueUpdateRequest();
197 } 197 }
198 198
(...skipping 347 matching lines...) Expand 10 before | Expand all | Expand 10 after
546 backup_update_reason < BACKUP_UPDATE_REASON_MAX); 546 backup_update_reason < BACKUP_UPDATE_REASON_MAX);
547 if (backup_url_prefixes_[backup_update_reason].empty()) 547 if (backup_url_prefixes_[backup_update_reason].empty())
548 return false; 548 return false;
549 request_type_ = BACKUP_UPDATE_REQUEST; 549 request_type_ = BACKUP_UPDATE_REQUEST;
550 backup_update_reason_ = backup_update_reason; 550 backup_update_reason_ = backup_update_reason;
551 551
552 GURL backup_update_url = BackupUpdateUrl(backup_update_reason); 552 GURL backup_update_url = BackupUpdateUrl(backup_update_reason);
553 request_.reset(net::URLFetcher::Create( 553 request_.reset(net::URLFetcher::Create(
554 url_fetcher_id_++, backup_update_url, net::URLFetcher::POST, this)); 554 url_fetcher_id_++, backup_update_url, net::URLFetcher::POST, this));
555 request_->SetLoadFlags(net::LOAD_DISABLE_CACHE); 555 request_->SetLoadFlags(net::LOAD_DISABLE_CACHE);
556 request_->SetRequestContext(request_context_getter_); 556 request_->SetRequestContext(request_context_getter_.get());
557 request_->SetUploadData("text/plain", update_list_data_); 557 request_->SetUploadData("text/plain", update_list_data_);
558 request_->Start(); 558 request_->Start();
559 559
560 // Begin the update request timeout. 560 // Begin the update request timeout.
561 timeout_timer_.Start(FROM_HERE, TimeDelta::FromSeconds(kSbMaxUpdateWaitSec), 561 timeout_timer_.Start(FROM_HERE, TimeDelta::FromSeconds(kSbMaxUpdateWaitSec),
562 this, 562 this,
563 &SafeBrowsingProtocolManager::UpdateResponseTimeout); 563 &SafeBrowsingProtocolManager::UpdateResponseTimeout);
564 564
565 return true; 565 return true;
566 } 566 }
567 567
568 void SafeBrowsingProtocolManager::IssueChunkRequest() { 568 void SafeBrowsingProtocolManager::IssueChunkRequest() {
569 DCHECK(CalledOnValidThread()); 569 DCHECK(CalledOnValidThread());
570 // We are only allowed to have one request outstanding at any time. Also, 570 // We are only allowed to have one request outstanding at any time. Also,
571 // don't get the next url until the previous one has been written to disk so 571 // don't get the next url until the previous one has been written to disk so
572 // that we don't use too much memory. 572 // that we don't use too much memory.
573 if (request_.get() || chunk_request_urls_.empty() || chunk_pending_to_write_) 573 if (request_.get() || chunk_request_urls_.empty() || chunk_pending_to_write_)
574 return; 574 return;
575 575
576 ChunkUrl next_chunk = chunk_request_urls_.front(); 576 ChunkUrl next_chunk = chunk_request_urls_.front();
577 DCHECK(!next_chunk.url.empty()); 577 DCHECK(!next_chunk.url.empty());
578 GURL chunk_url = NextChunkUrl(next_chunk.url); 578 GURL chunk_url = NextChunkUrl(next_chunk.url);
579 request_type_ = CHUNK_REQUEST; 579 request_type_ = CHUNK_REQUEST;
580 request_.reset(net::URLFetcher::Create( 580 request_.reset(net::URLFetcher::Create(
581 url_fetcher_id_++, chunk_url, net::URLFetcher::GET, this)); 581 url_fetcher_id_++, chunk_url, net::URLFetcher::GET, this));
582 request_->SetLoadFlags(net::LOAD_DISABLE_CACHE); 582 request_->SetLoadFlags(net::LOAD_DISABLE_CACHE);
583 request_->SetRequestContext(request_context_getter_); 583 request_->SetRequestContext(request_context_getter_.get());
584 chunk_request_start_ = base::Time::Now(); 584 chunk_request_start_ = base::Time::Now();
585 request_->Start(); 585 request_->Start();
586 } 586 }
587 587
588 void SafeBrowsingProtocolManager::OnGetChunksComplete( 588 void SafeBrowsingProtocolManager::OnGetChunksComplete(
589 const std::vector<SBListChunkRanges>& lists, bool database_error) { 589 const std::vector<SBListChunkRanges>& lists, bool database_error) {
590 DCHECK(CalledOnValidThread()); 590 DCHECK(CalledOnValidThread());
591 DCHECK_EQ(request_type_, UPDATE_REQUEST); 591 DCHECK_EQ(request_type_, UPDATE_REQUEST);
592 DCHECK(update_list_data_.empty()); 592 DCHECK(update_list_data_.empty());
593 if (database_error) { 593 if (database_error) {
(...skipping 26 matching lines...) Expand all
620 620
621 // Large requests are (probably) a sign of database corruption. 621 // Large requests are (probably) a sign of database corruption.
622 // Record stats to inform decisions about whether to automate 622 // Record stats to inform decisions about whether to automate
623 // deletion of such databases. http://crbug.com/120219 623 // deletion of such databases. http://crbug.com/120219
624 UMA_HISTOGRAM_COUNTS("SB2.UpdateRequestSize", update_list_data_.size()); 624 UMA_HISTOGRAM_COUNTS("SB2.UpdateRequestSize", update_list_data_.size());
625 625
626 GURL update_url = UpdateUrl(); 626 GURL update_url = UpdateUrl();
627 request_.reset(net::URLFetcher::Create( 627 request_.reset(net::URLFetcher::Create(
628 url_fetcher_id_++, update_url, net::URLFetcher::POST, this)); 628 url_fetcher_id_++, update_url, net::URLFetcher::POST, this));
629 request_->SetLoadFlags(net::LOAD_DISABLE_CACHE); 629 request_->SetLoadFlags(net::LOAD_DISABLE_CACHE);
630 request_->SetRequestContext(request_context_getter_); 630 request_->SetRequestContext(request_context_getter_.get());
631 request_->SetUploadData("text/plain", update_list_data_); 631 request_->SetUploadData("text/plain", update_list_data_);
632 request_->Start(); 632 request_->Start();
633 633
634 // Begin the update request timeout. 634 // Begin the update request timeout.
635 timeout_timer_.Start(FROM_HERE, TimeDelta::FromSeconds(kSbMaxUpdateWaitSec), 635 timeout_timer_.Start(FROM_HERE, TimeDelta::FromSeconds(kSbMaxUpdateWaitSec),
636 this, 636 this,
637 &SafeBrowsingProtocolManager::UpdateResponseTimeout); 637 &SafeBrowsingProtocolManager::UpdateResponseTimeout);
638 } 638 }
639 639
640 // If we haven't heard back from the server with an update response, this method 640 // If we haven't heard back from the server with an update response, this method
(...skipping 131 matching lines...) Expand 10 before | Expand all | Expand 10 after
772 FullHashCallback callback, bool is_download) 772 FullHashCallback callback, bool is_download)
773 : callback(callback), 773 : callback(callback),
774 is_download(is_download) { 774 is_download(is_download) {
775 } 775 }
776 776
777 SafeBrowsingProtocolManager::FullHashDetails::~FullHashDetails() { 777 SafeBrowsingProtocolManager::FullHashDetails::~FullHashDetails() {
778 } 778 }
779 779
780 SafeBrowsingProtocolManagerDelegate::~SafeBrowsingProtocolManagerDelegate() { 780 SafeBrowsingProtocolManagerDelegate::~SafeBrowsingProtocolManagerDelegate() {
781 } 781 }
OLDNEW
« no previous file with comments | « chrome/browser/safe_browsing/ping_manager.cc ('k') | chrome/browser/safe_browsing/protocol_manager_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698