| OLD | NEW |
| 1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 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 "components/safe_browsing_db/remote_database_manager.h" | 5 #include "components/safe_browsing_db/remote_database_manager.h" |
| 6 | 6 |
| 7 #include <vector> | 7 #include <vector> |
| 8 | 8 #include "base/trace_event/trace_event.h" |
| 9 #include "base/metrics/histogram_macros.h" | 9 #include "base/metrics/histogram_macros.h" |
| 10 #include "base/strings/string_number_conversions.h" | 10 #include "base/strings/string_number_conversions.h" |
| 11 #include "base/strings/string_split.h" | 11 #include "base/strings/string_split.h" |
| 12 #include "base/timer/elapsed_timer.h" | 12 #include "base/timer/elapsed_timer.h" |
| 13 #include "components/safe_browsing_db/safe_browsing_api_handler.h" | 13 #include "components/safe_browsing_db/safe_browsing_api_handler.h" |
| 14 #include "components/safe_browsing_db/v4_get_hash_protocol_manager.h" | 14 #include "components/safe_browsing_db/v4_get_hash_protocol_manager.h" |
| 15 #include "components/variations/variations_associated_data.h" | 15 #include "components/variations/variations_associated_data.h" |
| 16 #include "content/public/browser/browser_thread.h" | 16 #include "content/public/browser/browser_thread.h" |
| 17 | 17 |
| 18 using content::BrowserThread; | 18 using content::BrowserThread; |
| (...skipping 113 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 132 int i; | 132 int i; |
| 133 if (base::StringToInt(val_str, &i) && i >= 0 && | 133 if (base::StringToInt(val_str, &i) && i >= 0 && |
| 134 i < content::RESOURCE_TYPE_LAST_TYPE) { | 134 i < content::RESOURCE_TYPE_LAST_TYPE) { |
| 135 resource_types_to_check_.insert(static_cast<content::ResourceType>(i)); | 135 resource_types_to_check_.insert(static_cast<content::ResourceType>(i)); |
| 136 } | 136 } |
| 137 } | 137 } |
| 138 } | 138 } |
| 139 } | 139 } |
| 140 | 140 |
| 141 RemoteSafeBrowsingDatabaseManager::~RemoteSafeBrowsingDatabaseManager() { | 141 RemoteSafeBrowsingDatabaseManager::~RemoteSafeBrowsingDatabaseManager() { |
| 142 TRACE_EVENT0( |
| 143 "toplevel", |
| 144 "RemoteSafeBrowsingDatabaseManager::~RemoteSafeBrowsingDatabaseManager"); |
| 145 |
| 142 DCHECK(!enabled_); | 146 DCHECK(!enabled_); |
| 143 } | 147 } |
| 144 | 148 |
| 145 bool RemoteSafeBrowsingDatabaseManager::IsSupported() const { | 149 bool RemoteSafeBrowsingDatabaseManager::IsSupported() const { |
| 146 return SafeBrowsingApiHandler::GetInstance() != nullptr; | 150 return SafeBrowsingApiHandler::GetInstance() != nullptr; |
| 147 } | 151 } |
| 148 | 152 |
| 149 safe_browsing::ThreatSource RemoteSafeBrowsingDatabaseManager::GetThreatSource() | 153 safe_browsing::ThreatSource RemoteSafeBrowsingDatabaseManager::GetThreatSource() |
| 150 const { | 154 const { |
| 151 return safe_browsing::ThreatSource::REMOTE; | 155 return safe_browsing::ThreatSource::REMOTE; |
| (...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 229 return true; | 233 return true; |
| 230 } | 234 } |
| 231 | 235 |
| 232 bool RemoteSafeBrowsingDatabaseManager::IsCsdWhitelistKillSwitchOn() { | 236 bool RemoteSafeBrowsingDatabaseManager::IsCsdWhitelistKillSwitchOn() { |
| 233 NOTREACHED(); | 237 NOTREACHED(); |
| 234 return true; | 238 return true; |
| 235 } | 239 } |
| 236 | 240 |
| 237 bool RemoteSafeBrowsingDatabaseManager::CheckBrowseUrl(const GURL& url, | 241 bool RemoteSafeBrowsingDatabaseManager::CheckBrowseUrl(const GURL& url, |
| 238 Client* client) { | 242 Client* client) { |
| 243 TRACE_EVENT0("toplevel", "RemoteSafeBrowsingDatabaseManager::CheckBrowseUrl"); |
| 239 DCHECK_CURRENTLY_ON(BrowserThread::IO); | 244 DCHECK_CURRENTLY_ON(BrowserThread::IO); |
| 240 if (!enabled_) | 245 if (!enabled_) |
| 241 return true; | 246 return true; |
| 242 | 247 |
| 243 bool can_check_url = CanCheckUrl(url); | 248 bool can_check_url = CanCheckUrl(url); |
| 244 UMA_HISTOGRAM_BOOLEAN("SB2.RemoteCall.CanCheckUrl", can_check_url); | 249 UMA_HISTOGRAM_BOOLEAN("SB2.RemoteCall.CanCheckUrl", can_check_url); |
| 245 if (!can_check_url) | 250 if (!can_check_url) |
| 246 return true; // Safe, continue right away. | 251 return true; // Safe, continue right away. |
| 247 | 252 |
| 248 scoped_ptr<ClientRequest> req(new ClientRequest(client, this, url)); | 253 scoped_ptr<ClientRequest> req(new ClientRequest(client, this, url)); |
| (...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 299 for (auto req : to_callback) { | 304 for (auto req : to_callback) { |
| 300 DVLOG(1) << "Stopping: Invoking unfinished req for URL " << req->url(); | 305 DVLOG(1) << "Stopping: Invoking unfinished req for URL " << req->url(); |
| 301 req->OnRequestDone(SB_THREAT_TYPE_SAFE, ThreatMetadata()); | 306 req->OnRequestDone(SB_THREAT_TYPE_SAFE, ThreatMetadata()); |
| 302 } | 307 } |
| 303 enabled_ = false; | 308 enabled_ = false; |
| 304 | 309 |
| 305 SafeBrowsingDatabaseManager::StopOnIOThread(shutdown); | 310 SafeBrowsingDatabaseManager::StopOnIOThread(shutdown); |
| 306 } | 311 } |
| 307 | 312 |
| 308 } // namespace safe_browsing | 313 } // namespace safe_browsing |
| OLD | NEW |