Chromium Code Reviews| Index: chrome/browser/safe_browsing/protocol_manager.cc |
| =================================================================== |
| --- chrome/browser/safe_browsing/protocol_manager.cc (revision 68365) |
| +++ chrome/browser/safe_browsing/protocol_manager.cc (working copy) |
| @@ -38,9 +38,52 @@ |
| // Maximum back off multiplier. |
| static const int kSbMaxBackOff = 8; |
| +// The default ProtocolManagerFactory. |
| +class ProtocolManagerFactoryImpl : public ProtocolManagerFactory { |
| + public: |
| + ProtocolManagerFactoryImpl() { } |
| + virtual ~ProtocolManagerFactoryImpl() { } |
| + 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(ProtocolManagerFactoryImpl); |
| +}; |
| // SafeBrowsingProtocolManager implementation ---------------------------------- |
| +// static |
| +ProtocolManagerFactory* 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) { |
| + if (!factory_) |
|
Scott Hess - ex-Googler
2010/12/07 21:22:57
If this is thread-safe, tell me why, and maybe CHE
lzheng
2010/12/08 01:57:32
There should only be one protocol manager globally
|
| + factory_ = new ProtocolManagerFactoryImpl(); |
| + 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, |
| @@ -207,11 +250,11 @@ |
| } 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; |
| } |
| } |