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

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

Issue 6025005: Consolidate some safe-browsing histograms. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: tweaking Created 9 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 | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2010 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 107 matching lines...) Expand 10 before | Expand all | Expand 10 after
118 // The first update must happen between 1-5 minutes of start up. 118 // The first update must happen between 1-5 minutes of start up.
119 next_update_sec_ = base::RandInt(60, kSbTimerStartIntervalSec); 119 next_update_sec_ = base::RandInt(60, kSbTimerStartIntervalSec);
120 120
121 chrome::VersionInfo version_info; 121 chrome::VersionInfo version_info;
122 if (!version_info.is_valid() || version_info.Version().empty()) 122 if (!version_info.is_valid() || version_info.Version().empty())
123 version_ = "0.1"; 123 version_ = "0.1";
124 else 124 else
125 version_ = version_info.Version(); 125 version_ = version_info.Version();
126 } 126 }
127 127
128 // static
129 void SafeBrowsingProtocolManager::RecordGetHashResult(ResultType result_type) {
130 UMA_HISTOGRAM_ENUMERATION("SB2.GetHashResult", result_type,
131 GET_HASH_RESULT_MAX);
132 }
133
128 SafeBrowsingProtocolManager::~SafeBrowsingProtocolManager() { 134 SafeBrowsingProtocolManager::~SafeBrowsingProtocolManager() {
129 // Delete in-progress SafeBrowsing requests. 135 // Delete in-progress SafeBrowsing requests.
130 STLDeleteContainerPairFirstPointers(hash_requests_.begin(), 136 STLDeleteContainerPairFirstPointers(hash_requests_.begin(),
131 hash_requests_.end()); 137 hash_requests_.end());
132 hash_requests_.clear(); 138 hash_requests_.clear();
133 139
134 // Delete in-progress safebrowsing reports (hits and details). 140 // Delete in-progress safebrowsing reports (hits and details).
135 STLDeleteContainerPointers(safebrowsing_reports_.begin(), 141 STLDeleteContainerPointers(safebrowsing_reports_.begin(),
136 safebrowsing_reports_.end()); 142 safebrowsing_reports_.end());
137 safebrowsing_reports_.clear(); 143 safebrowsing_reports_.clear();
(...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after
218 if (it != hash_requests_.end()) { 224 if (it != hash_requests_.end()) {
219 // GetHash response. 225 // GetHash response.
220 fetcher.reset(it->first); 226 fetcher.reset(it->first);
221 SafeBrowsingService::SafeBrowsingCheck* check = it->second; 227 SafeBrowsingService::SafeBrowsingCheck* check = it->second;
222 std::vector<SBFullHashResult> full_hashes; 228 std::vector<SBFullHashResult> full_hashes;
223 bool can_cache = false; 229 bool can_cache = false;
224 if (response_code == 200 || response_code == 204) { 230 if (response_code == 200 || response_code == 204) {
225 // For tracking our GetHash false positive (204) rate, compared to real 231 // For tracking our GetHash false positive (204) rate, compared to real
226 // (200) responses. 232 // (200) responses.
227 if (response_code == 200) 233 if (response_code == 200)
228 UMA_HISTOGRAM_COUNTS("SB2.GetHash200", 1); 234 RecordGetHashResult(GET_HASH_STATUS_200);
229 else 235 else
230 UMA_HISTOGRAM_COUNTS("SB2.GetHash204", 1); 236 RecordGetHashResult(GET_HASH_STATUS_204);
231 can_cache = true; 237 can_cache = true;
232 gethash_error_count_ = 0; 238 gethash_error_count_ = 0;
233 gethash_back_off_mult_ = 1; 239 gethash_back_off_mult_ = 1;
234 bool re_key = false; 240 bool re_key = false;
235 SafeBrowsingProtocolParser parser; 241 SafeBrowsingProtocolParser parser;
236 parsed_ok = parser.ParseGetHash(data.data(), 242 parsed_ok = parser.ParseGetHash(data.data(),
237 static_cast<int>(data.length()), 243 static_cast<int>(data.length()),
238 client_key_, 244 client_key_,
239 &re_key, 245 &re_key,
240 &full_hashes); 246 &full_hashes);
(...skipping 545 matching lines...) Expand 10 before | Expand all | Expand 10 after
786 if (!additional_query_.empty()) { 792 if (!additional_query_.empty()) {
787 if (next_url.find("?") != std::string::npos) { 793 if (next_url.find("?") != std::string::npos) {
788 next_url.append("&"); 794 next_url.append("&");
789 } else { 795 } else {
790 next_url.append("?"); 796 next_url.append("?");
791 } 797 }
792 next_url.append(additional_query_); 798 next_url.append(additional_query_);
793 } 799 }
794 return GURL(next_url); 800 return GURL(next_url);
795 } 801 }
OLDNEW
« no previous file with comments | « chrome/browser/safe_browsing/protocol_manager.h ('k') | chrome/browser/safe_browsing/safe_browsing_service.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698