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

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

Issue 160225: Fix the root cause of flakiness in SafeBrowsingProtocolManagerTest.TestGetHashBackOffTimes (Closed)
Patch Set: Created 11 years, 4 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 (c) 2006-2008 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2006-2008 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 "base/file_version_info.h" 7 #include "base/file_version_info.h"
8 #include "base/histogram.h" 8 #include "base/histogram.h"
9 #include "base/logging.h" 9 #include "base/logging.h"
10 #include "base/message_loop.h" 10 #include "base/message_loop.h"
(...skipping 204 matching lines...) Expand 10 before | Expand all | Expand 10 after
215 if (!parsed_ok) { 215 if (!parsed_ok) {
216 // If we fail to parse it, we must still inform the SafeBrowsingService 216 // If we fail to parse it, we must still inform the SafeBrowsingService
217 // so that it doesn't hold up the user's request indefinitely. Not sure 217 // so that it doesn't hold up the user's request indefinitely. Not sure
218 // what to do at that point though! 218 // what to do at that point though!
219 full_hashes.clear(); 219 full_hashes.clear();
220 } else { 220 } else {
221 if (re_key) 221 if (re_key)
222 HandleReKey(); 222 HandleReKey();
223 } 223 }
224 } else if (response_code >= 300) { 224 } else if (response_code >= 300) {
225 HandleGetHashError(); 225 HandleGetHashError(Time::Now());
226 SB_DLOG(INFO) << "SafeBrowsing GetHash request for: " << source->url() 226 SB_DLOG(INFO) << "SafeBrowsing GetHash request for: " << source->url()
227 << ", failed with error: " << response_code; 227 << ", failed with error: " << response_code;
228 } 228 }
229 229
230 // Call back the SafeBrowsingService with full_hashes, even if there was a 230 // Call back the SafeBrowsingService with full_hashes, even if there was a
231 // parse error or an error response code (in which case full_hashes will be 231 // parse error or an error response code (in which case full_hashes will be
232 // empty). We can't block the user regardless of the error status. 232 // empty). We can't block the user regardless of the error status.
233 sb_service_->HandleGetHashResults(check, full_hashes, can_cache); 233 sb_service_->HandleGetHashResults(check, full_hashes, can_cache);
234 234
235 hash_requests_.erase(it); 235 hash_requests_.erase(it);
(...skipping 383 matching lines...) Expand 10 before | Expand all | Expand 10 after
619 619
620 return formatted_results; 620 return formatted_results;
621 } 621 }
622 622
623 void SafeBrowsingProtocolManager::HandleReKey() { 623 void SafeBrowsingProtocolManager::HandleReKey() {
624 client_key_.clear(); 624 client_key_.clear();
625 wrapped_key_.clear(); 625 wrapped_key_.clear();
626 IssueKeyRequest(); 626 IssueKeyRequest();
627 } 627 }
628 628
629 void SafeBrowsingProtocolManager::HandleGetHashError() { 629 void SafeBrowsingProtocolManager::HandleGetHashError(const Time& now) {
630 int next = GetNextBackOffTime(&gethash_error_count_, &gethash_back_off_mult_); 630 int next = GetNextBackOffTime(&gethash_error_count_, &gethash_back_off_mult_);
631 next_gethash_time_ = Time::Now() + TimeDelta::FromSeconds(next); 631 next_gethash_time_ = now + TimeDelta::FromSeconds(next);
632 } 632 }
633 633
634 void SafeBrowsingProtocolManager::UpdateFinished(bool success) { 634 void SafeBrowsingProtocolManager::UpdateFinished(bool success) {
635 UMA_HISTOGRAM_COUNTS("SB2.UpdateSize", update_size_); 635 UMA_HISTOGRAM_COUNTS("SB2.UpdateSize", update_size_);
636 update_size_ = 0; 636 update_size_ = 0;
637 sb_service_->UpdateFinished(success); 637 sb_service_->UpdateFinished(success);
638 } 638 }
OLDNEW
« no previous file with comments | « chrome/browser/safe_browsing/protocol_manager.h ('k') | chrome/browser/safe_browsing/protocol_manager_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698