summaryrefslogtreecommitdiffstats
path: root/chrome/browser/safe_browsing/protocol_manager.cc
diff options
context:
space:
mode:
authorlzheng@chromium.org <lzheng@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-12-13 23:46:19 +0000
committerlzheng@chromium.org <lzheng@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-12-13 23:46:19 +0000
commitbef12f40253f48b56a69e59746f52214727080de (patch)
tree224a0fcc0d6e7ec72c5b28ff2c381e0be729aed0 /chrome/browser/safe_browsing/protocol_manager.cc
parentc35a309c6faaaf6002fb8bb553a69e759c5ad1d3 (diff)
downloadchromium_src-bef12f40253f48b56a69e59746f52214727080de.zip
chromium_src-bef12f40253f48b56a69e59746f52214727080de.tar.gz
chromium_src-bef12f40253f48b56a69e59746f52214727080de.tar.bz2
Add a browser test for safebrowsing service.
BUG=none TEST=safe_browsing_service_browsertest Review URL: http://codereview.chromium.org/5544008 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@69072 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/browser/safe_browsing/protocol_manager.cc')
-rw-r--r--chrome/browser/safe_browsing/protocol_manager.cc52
1 files changed, 48 insertions, 4 deletions
diff --git a/chrome/browser/safe_browsing/protocol_manager.cc b/chrome/browser/safe_browsing/protocol_manager.cc
index 16e4d28..8e29489 100644
--- a/chrome/browser/safe_browsing/protocol_manager.cc
+++ b/chrome/browser/safe_browsing/protocol_manager.cc
@@ -37,9 +37,53 @@ static const int kSbMaxUpdateWaitSec = 10;
// Maximum back off multiplier.
static const int kSbMaxBackOff = 8;
+// The default SBProtocolManagerFactory.
+class SBProtocolManagerFactoryImpl : public SBProtocolManagerFactory {
+ public:
+ SBProtocolManagerFactoryImpl() { }
+ virtual ~SBProtocolManagerFactoryImpl() { }
+ virtual SafeBrowsingProtocolManager* CreateProtocolManager(
+ SafeBrowsingService* sb_service,
+ const std::string& client_name,
+ const std::string& client_key,
+ const std::string& wrapped_key,
+ URLRequestContextGetter* request_context_getter,
+ const std::string& info_url_prefix,
+ const std::string& mackey_url_prefix,
+ bool disable_auto_update) {
+ return new SafeBrowsingProtocolManager(
+ sb_service, client_name, client_key, wrapped_key,
+ request_context_getter, info_url_prefix, mackey_url_prefix,
+ disable_auto_update);
+ }
+ private:
+ DISALLOW_COPY_AND_ASSIGN(SBProtocolManagerFactoryImpl);
+};
// SafeBrowsingProtocolManager implementation ----------------------------------
+// static
+SBProtocolManagerFactory* SafeBrowsingProtocolManager::factory_ = NULL;
+
+// static
+SafeBrowsingProtocolManager* SafeBrowsingProtocolManager::Create(
+ SafeBrowsingService* sb_service,
+ const std::string& client_name,
+ const std::string& client_key,
+ const std::string& wrapped_key,
+ URLRequestContextGetter* request_context_getter,
+ const std::string& info_url_prefix,
+ const std::string& mackey_url_prefix,
+ bool disable_auto_update) {
+ DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO));
+ if (!factory_)
+ factory_ = new SBProtocolManagerFactoryImpl();
+ return factory_->CreateProtocolManager(sb_service, client_name, client_key,
+ wrapped_key, request_context_getter,
+ info_url_prefix, mackey_url_prefix,
+ disable_auto_update);
+}
+
SafeBrowsingProtocolManager::SafeBrowsingProtocolManager(
SafeBrowsingService* sb_service,
const std::string& client_name,
@@ -206,11 +250,11 @@ void SafeBrowsingProtocolManager::OnURLFetchComplete(
} else {
HandleGetHashError(Time::Now());
if (status.status() == URLRequestStatus::FAILED) {
- VLOG(1) << "SafeBrowsing GetHash request for: " << source->url()
- << " failed with os error: " << status.os_error();
+ VLOG(1) << "SafeBrowsing GetHash request for: " << source->url()
+ << " failed with os error: " << status.os_error();
} else {
- VLOG(1) << "SafeBrowsing GetHash request for: " << source->url()
- << " failed with error: " << response_code;
+ VLOG(1) << "SafeBrowsing GetHash request for: " << source->url()
+ << " failed with error: " << response_code;
}
}