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

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

Issue 8373021: Convert URLFetcher::Delegates to use an interface in content/public/common. Also remove the old U... (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: sync and remove unncessary forward declares Created 9 years, 2 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 side-by-side diff with in-line comments
Download patch
Index: chrome/browser/safe_browsing/protocol_manager.cc
===================================================================
--- chrome/browser/safe_browsing/protocol_manager.cc (revision 106929)
+++ chrome/browser/safe_browsing/protocol_manager.cc (working copy)
@@ -21,6 +21,7 @@
#include "chrome/common/chrome_version_info.h"
#include "chrome/common/env_vars.h"
#include "content/browser/browser_thread.h"
+#include "content/common/net/url_fetcher.h"
#include "net/base/escape.h"
#include "net/base/load_flags.h"
#include "net/url_request/url_request_context_getter.h"
@@ -195,7 +196,7 @@
IssueUpdateRequest();
}
-// URLFetcher::Delegate implementation -----------------------------------------
+// content::URLFetcherDelegate implementation ----------------------------------
// All SafeBrowsing request responses are handled here.
// TODO(paulg): Clarify with the SafeBrowsing team whether a failed parse of a
@@ -205,13 +206,7 @@
// drop it. This isn't so bad because the next UPDATE_REQUEST we
// do will report all the chunks we have. If that chunk is still
// required, the SafeBrowsing servers will tell us to get it again.
-void SafeBrowsingProtocolManager::OnURLFetchComplete(
- const URLFetcher* source,
- const GURL& url,
- const net::URLRequestStatus& status,
- int response_code,
- const net::ResponseCookies& cookies,
- const std::string& data) {
+void SafeBrowsingProtocolManager::OnURLFetchComplete(const URLFetcher* source) {
scoped_ptr<const URLFetcher> fetcher;
bool parsed_ok = true;
bool must_back_off = false; // Reduce SafeBrowsing service query frequency.
@@ -234,10 +229,10 @@
SafeBrowsingService::SafeBrowsingCheck* check = it->second;
std::vector<SBFullHashResult> full_hashes;
bool can_cache = false;
- if (response_code == 200 || response_code == 204) {
+ if (source->response_code() == 200 || source->response_code() == 204) {
// For tracking our GetHash false positive (204) rate, compared to real
// (200) responses.
- if (response_code == 200)
+ if (source->response_code() == 200)
RecordGetHashResult(check->is_download, GET_HASH_STATUS_200);
else
RecordGetHashResult(check->is_download, GET_HASH_STATUS_204);
@@ -246,11 +241,14 @@
gethash_back_off_mult_ = 1;
bool re_key = false;
SafeBrowsingProtocolParser parser;
- parsed_ok = parser.ParseGetHash(data.data(),
- static_cast<int>(data.length()),
- client_key_,
- &re_key,
- &full_hashes);
+ std::string data;
+ source->GetResponseAsString(&data);
+ parsed_ok = parser.ParseGetHash(
+ data.data(),
+ static_cast<int>(data.length()),
+ client_key_,
+ &re_key,
+ &full_hashes);
if (!parsed_ok) {
// If we fail to parse it, we must still inform the SafeBrowsingService
// so that it doesn't hold up the user's request indefinitely. Not sure
@@ -262,12 +260,12 @@
}
} else {
HandleGetHashError(Time::Now());
- if (status.status() == net::URLRequestStatus::FAILED) {
+ if (source->status().status() == net::URLRequestStatus::FAILED) {
VLOG(1) << "SafeBrowsing GetHash request for: " << source->url()
- << " failed with error: " << status.error();
+ << " failed with error: " << source->status().error();
} else {
VLOG(1) << "SafeBrowsing GetHash request for: " << source->url()
- << " failed with error: " << response_code;
+ << " failed with error: " << source->response_code();
}
}
@@ -292,11 +290,12 @@
update_timer_.Stop();
}
- if (response_code == 200) {
+ if (source->response_code() == 200) {
// We have data from the SafeBrowsing service.
- parsed_ok = HandleServiceResponse(source->url(),
- data.data(),
- static_cast<int>(data.length()));
+ std::string data;
+ source->GetResponseAsString(&data);
+ parsed_ok = HandleServiceResponse(
+ source->url(), data.data(), static_cast<int>(data.length()));
if (!parsed_ok) {
VLOG(1) << "SafeBrowsing request for: " << source->url()
<< " failed parse.";
@@ -336,12 +335,12 @@
if (request_type_ == CHUNK_REQUEST)
chunk_request_urls_.clear();
UpdateFinished(false);
- if (status.status() == net::URLRequestStatus::FAILED) {
+ if (source->status().status() == net::URLRequestStatus::FAILED) {
VLOG(1) << "SafeBrowsing request for: " << source->url()
- << " failed with error: " << status.error();
+ << " failed with error: " << source->status().error();
} else {
VLOG(1) << "SafeBrowsing request for: " << source->url()
- << " failed with error: " << response_code;
+ << " failed with error: " << source->response_code();
}
}
}

Powered by Google App Engine
This is Rietveld 408576698