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

Unified Diff: chrome/browser/safe_browsing/protocol_manager.cc

Issue 11419041: Add tests for redirect responses from SafeBrowsingProtocolManager. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Reintroduce newline Created 8 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 side-by-side diff with in-line comments
Download patch
Index: chrome/browser/safe_browsing/protocol_manager.cc
diff --git a/chrome/browser/safe_browsing/protocol_manager.cc b/chrome/browser/safe_browsing/protocol_manager.cc
index 960b4fdb94ba5abcae00629c8f4fb969b7c5f08b..cd86df11fd7437db9724c1e0430e30f21c57d162 100644
--- a/chrome/browser/safe_browsing/protocol_manager.cc
+++ b/chrome/browser/safe_browsing/protocol_manager.cc
@@ -250,8 +250,11 @@ void SafeBrowsingProtocolManager::OnURLFetchComplete(
switch (request_type_) {
case CHUNK_REQUEST:
- if (parsed_ok)
+ if (parsed_ok) {
chunk_request_urls_.pop_front();
+ if (chunk_request_urls_.empty() && !chunk_pending_to_write_)
+ UpdateFinished(true);
+ }
break;
case UPDATE_REQUEST:
if (chunk_request_urls_.empty() && parsed_ok) {
@@ -283,9 +286,10 @@ void SafeBrowsingProtocolManager::OnURLFetchComplete(
// Schedule a new update request if we've finished retrieving all the chunks
// from the previous update. We treat the update request and the chunk URLs it
// contains as an atomic unit as far as back off is concerned.
- if (chunk_request_urls_.empty() &&
- (request_type_ == CHUNK_REQUEST || request_type_ == UPDATE_REQUEST))
+ if (chunk_request_urls_.empty() && !chunk_pending_to_write_ &&
mattm 2012/11/16 21:48:46 so if we hit this case, does something else schedu
cbentzel 2012/11/16 21:52:35 This is handled in OnAddChunksComplete. The test
+ (request_type_ == CHUNK_REQUEST || request_type_ == UPDATE_REQUEST)) {
ScheduleNextUpdate(must_back_off);
+ }
// Get the next chunk if available.
IssueChunkRequest();
@@ -372,7 +376,10 @@ bool SafeBrowsingProtocolManager::HandleServiceResponse(const GURL& url,
// Chunks to add to storage. Pass ownership of |chunks|.
if (!chunks->empty()) {
chunk_pending_to_write_ = true;
- delegate_->AddChunks(chunk_url.list_name, chunks.release());
+ delegate_->AddChunks(
+ chunk_url.list_name, chunks.release(),
+ base::Bind(&SafeBrowsingProtocolManager::OnAddChunksComplete,
+ base::Unretained(this)));
}
break;
@@ -545,7 +552,7 @@ void SafeBrowsingProtocolManager::UpdateResponseTimeout() {
ScheduleNextUpdate(true);
}
-void SafeBrowsingProtocolManager::OnChunkInserted() {
+void SafeBrowsingProtocolManager::OnAddChunksComplete() {
DCHECK(CalledOnValidThread());
chunk_pending_to_write_ = false;
« 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