OLD | NEW |
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 #include <utility> | 7 #include <utility> |
8 | 8 |
9 #include "base/environment.h" | 9 #include "base/environment.h" |
10 #include "base/logging.h" | 10 #include "base/logging.h" |
(...skipping 148 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
159 backup_url_prefixes_[BACKUP_UPDATE_REASON_CONNECT] = | 159 backup_url_prefixes_[BACKUP_UPDATE_REASON_CONNECT] = |
160 config.backup_connect_error_url_prefix; | 160 config.backup_connect_error_url_prefix; |
161 backup_url_prefixes_[BACKUP_UPDATE_REASON_HTTP] = | 161 backup_url_prefixes_[BACKUP_UPDATE_REASON_HTTP] = |
162 config.backup_http_error_url_prefix; | 162 config.backup_http_error_url_prefix; |
163 backup_url_prefixes_[BACKUP_UPDATE_REASON_NETWORK] = | 163 backup_url_prefixes_[BACKUP_UPDATE_REASON_NETWORK] = |
164 config.backup_network_error_url_prefix; | 164 config.backup_network_error_url_prefix; |
165 | 165 |
166 // Set the backoff multiplier fuzz to a random value between 0 and 1. | 166 // Set the backoff multiplier fuzz to a random value between 0 and 1. |
167 back_off_fuzz_ = static_cast<float>(base::RandDouble()); | 167 back_off_fuzz_ = static_cast<float>(base::RandDouble()); |
168 if (version_.empty()) | 168 if (version_.empty()) |
169 version_ = SafeBrowsingProtocolManagerHelper::Version(); | 169 version_ = ProtocolManagerHelper::Version(); |
170 } | 170 } |
171 | 171 |
172 // static | 172 // static |
173 void SafeBrowsingProtocolManager::RecordGetHashResult(bool is_download, | 173 void SafeBrowsingProtocolManager::RecordGetHashResult(bool is_download, |
174 ResultType result_type) { | 174 ResultType result_type) { |
175 if (is_download) { | 175 if (is_download) { |
176 UMA_HISTOGRAM_ENUMERATION("SB2.GetHashResultDownload", result_type, | 176 UMA_HISTOGRAM_ENUMERATION("SB2.GetHashResultDownload", result_type, |
177 GET_HASH_RESULT_MAX); | 177 GET_HASH_RESULT_MAX); |
178 } else { | 178 } else { |
179 UMA_HISTOGRAM_ENUMERATION("SB2.GetHashResult", result_type, | 179 UMA_HISTOGRAM_ENUMERATION("SB2.GetHashResult", result_type, |
(...skipping 556 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
736 } | 736 } |
737 backup_update_reason_ = BACKUP_UPDATE_REASON_MAX; | 737 backup_update_reason_ = BACKUP_UPDATE_REASON_MAX; |
738 request_type_ = NO_REQUEST; | 738 request_type_ = NO_REQUEST; |
739 update_list_data_.clear(); | 739 update_list_data_.clear(); |
740 delegate_->UpdateFinished(success); | 740 delegate_->UpdateFinished(success); |
741 ScheduleNextUpdate(back_off); | 741 ScheduleNextUpdate(back_off); |
742 } | 742 } |
743 | 743 |
744 GURL SafeBrowsingProtocolManager::UpdateUrl( | 744 GURL SafeBrowsingProtocolManager::UpdateUrl( |
745 ExtendedReportingLevel reporting_level) const { | 745 ExtendedReportingLevel reporting_level) const { |
746 std::string url = SafeBrowsingProtocolManagerHelper::ComposeUrl( | 746 std::string url = ProtocolManagerHelper::ComposeUrl( |
747 url_prefix_, "downloads", client_name_, version_, additional_query_, | 747 url_prefix_, "downloads", client_name_, version_, additional_query_, |
748 reporting_level); | 748 reporting_level); |
749 return GURL(url); | 749 return GURL(url); |
750 } | 750 } |
751 | 751 |
752 GURL SafeBrowsingProtocolManager::BackupUpdateUrl( | 752 GURL SafeBrowsingProtocolManager::BackupUpdateUrl( |
753 BackupUpdateReason backup_update_reason) const { | 753 BackupUpdateReason backup_update_reason) const { |
754 DCHECK(backup_update_reason >= 0 && | 754 DCHECK(backup_update_reason >= 0 && |
755 backup_update_reason < BACKUP_UPDATE_REASON_MAX); | 755 backup_update_reason < BACKUP_UPDATE_REASON_MAX); |
756 DCHECK(!backup_url_prefixes_[backup_update_reason].empty()); | 756 DCHECK(!backup_url_prefixes_[backup_update_reason].empty()); |
757 std::string url = SafeBrowsingProtocolManagerHelper::ComposeUrl( | 757 std::string url = ProtocolManagerHelper::ComposeUrl( |
758 backup_url_prefixes_[backup_update_reason], "downloads", client_name_, | 758 backup_url_prefixes_[backup_update_reason], "downloads", client_name_, |
759 version_, additional_query_); | 759 version_, additional_query_); |
760 return GURL(url); | 760 return GURL(url); |
761 } | 761 } |
762 | 762 |
763 GURL SafeBrowsingProtocolManager::GetHashUrl( | 763 GURL SafeBrowsingProtocolManager::GetHashUrl( |
764 ExtendedReportingLevel reporting_level) const { | 764 ExtendedReportingLevel reporting_level) const { |
765 std::string url = SafeBrowsingProtocolManagerHelper::ComposeUrl( | 765 std::string url = ProtocolManagerHelper::ComposeUrl( |
766 url_prefix_, "gethash", client_name_, version_, additional_query_, | 766 url_prefix_, "gethash", client_name_, version_, additional_query_, |
767 reporting_level); | 767 reporting_level); |
768 return GURL(url); | 768 return GURL(url); |
769 } | 769 } |
770 | 770 |
771 GURL SafeBrowsingProtocolManager::NextChunkUrl(const std::string& url) const { | 771 GURL SafeBrowsingProtocolManager::NextChunkUrl(const std::string& url) const { |
772 DCHECK_CURRENTLY_ON(content::BrowserThread::IO); | 772 DCHECK_CURRENTLY_ON(content::BrowserThread::IO); |
773 std::string next_url; | 773 std::string next_url; |
774 if (!base::StartsWith(url, "http://", base::CompareCase::INSENSITIVE_ASCII) && | 774 if (!base::StartsWith(url, "http://", base::CompareCase::INSENSITIVE_ASCII) && |
775 !base::StartsWith(url, "https://", | 775 !base::StartsWith(url, "https://", |
(...skipping 28 matching lines...) Expand all Loading... |
804 : callback(callback), is_download(is_download) {} | 804 : callback(callback), is_download(is_download) {} |
805 | 805 |
806 SafeBrowsingProtocolManager::FullHashDetails::FullHashDetails( | 806 SafeBrowsingProtocolManager::FullHashDetails::FullHashDetails( |
807 const FullHashDetails& other) = default; | 807 const FullHashDetails& other) = default; |
808 | 808 |
809 SafeBrowsingProtocolManager::FullHashDetails::~FullHashDetails() {} | 809 SafeBrowsingProtocolManager::FullHashDetails::~FullHashDetails() {} |
810 | 810 |
811 SafeBrowsingProtocolManagerDelegate::~SafeBrowsingProtocolManagerDelegate() {} | 811 SafeBrowsingProtocolManagerDelegate::~SafeBrowsingProtocolManagerDelegate() {} |
812 | 812 |
813 } // namespace safe_browsing | 813 } // namespace safe_browsing |
OLD | NEW |