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

Unified Diff: chrome/browser/safe_browsing/remote_database_manager.h

Issue 1110723002: Split to SafeBrowsingDatabaseManager into Local* and Remote*. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: extend test db manager to fix browser tests Created 5 years, 8 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/remote_database_manager.h
diff --git a/chrome/browser/safe_browsing/remote_database_manager.h b/chrome/browser/safe_browsing/remote_database_manager.h
new file mode 100644
index 0000000000000000000000000000000000000000..87fbae6c3e2b3a7fc0d1bf33c4dbf91cb919e884
--- /dev/null
+++ b/chrome/browser/safe_browsing/remote_database_manager.h
@@ -0,0 +1,89 @@
+// Copyright (c) 2015 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+//
+// Implementation of the SafeBrowsingDatabaseManager that sends URLs
+// via IPC to a database that chromium doesn't manage locally.
+
+#ifndef CHROME_BROWSER_SAFE_BROWSING_REMOTE_DATABASE_MANAGER_H_
+#define CHROME_BROWSER_SAFE_BROWSING_REMOTE_DATABASE_MANAGER_H_
+
+#include <hash_map>
+#include <set>
+#include <string>
+#include <vector>
+
+#include "base/memory/ref_counted.h"
+#include "chrome/browser/safe_browsing/android_safe_browsing_api_handler.h"
+#include "chrome/browser/safe_browsing/database_manager.h"
+#include "url/gurl.h"
+
+// An implementation that proxies requests to a service outside of Chromium.
+// Does not manage a local database.
+class RemoteSafeBrowsingDatabaseManager
+ : public SafeBrowsingDatabaseManager {
+ public:
+ // Need to initialize before using.
+ RemoteSafeBrowsingDatabaseManager();
+
+ //
+ // SafeBrowsingDatabaseManager implementation
+ //
+
+ bool CanCheckUrl(const GURL& url) const override;
+ bool download_protection_enabled() const override;
+ bool CheckBrowseUrl(const GURL& url, Client* client) override;
+ void CancelCheck(Client* client) override;
+ void StartOnIOThread() override;
+ void StopOnIOThread(bool shutdown) override;
+
+ // These will DCHECK fail with "not implemented".
+ // We may later add support for a subset of these.
+ bool CheckDownloadUrl(const std::vector<GURL>& url_chain,
+ Client* client) override;
+ bool CheckExtensionIDs(const std::set<std::string>& extension_ids,
+ Client* client) override;
+ bool MatchCsdWhitelistUrl(const GURL& url) override;
+ bool MatchMalwareIP(const std::string& ip_address) override;
+ bool MatchDownloadWhitelistUrl(const GURL& url) override;
+ bool MatchDownloadWhitelistString(const std::string& str) override;
+ bool MatchInclusionWhitelistUrl(const GURL& url) override;
+ bool IsMalwareKillSwitchOn() override;
+ bool IsCsdWhitelistKillSwitchOn() override;
+ SafeBrowsingProtocolManagerDelegate* GetProtocolManagerDelegate() override;
+
+ //
+ // RemoteSafeBrowsingDatabaseManager implementation
+ //
+
+ protected:
mattm 2015/05/06 02:42:46 Why are these things protected instead of private?
Nathan Parker 2015/05/06 22:27:36 Fixed.
+ ~RemoteSafeBrowsingDatabaseManager() override;
+ bool enabled_;
mattm 2015/05/06 02:42:46 members should go after all types and methods in t
Nathan Parker 2015/05/06 22:27:36 Done.
+
+ // Per-request tracker.
+ class ClientRequest : public base::RefCounted<ClientRequest> {
mattm 2015/05/06 02:42:45 I think generally inner classes will go near the t
Nathan Parker 2015/05/06 22:27:36 Done.
+ public:
+ // Passes the results to client, if it's not null.
+ void OnRequestDone(SBThreatType matched_threat_type,
+ const std::string& metadata);
+
+ Client* client;
mattm 2015/05/06 02:42:45 members of classes should have trailing _
Nathan Parker 2015/05/06 22:27:36 Done.
+ // Only valid if client is not NULL.
+ RemoteSafeBrowsingDatabaseManager* db_manager;
+ GURL url;
+
+ private:
+ friend class base::RefCounted<ClientRequest>;
+ };
+
+ // Requests currently outstanding.
+ std::vector<scoped_refptr<ClientRequest>> current_requests_;
+
+ AndroidSafeBrowsingAPIHandler api_handler_;
+
+ private:
+ friend class base::RefCountedThreadSafe<RemoteSafeBrowsingDatabaseManager>;
+ DISALLOW_COPY_AND_ASSIGN(RemoteSafeBrowsingDatabaseManager);
+}; // class RemoteSafeBrowsingDatabaseManager
+
+#endif // CHROME_BROWSER_SAFE_BROWSING_REMOTE_DATABASE_MANAGER_H_

Powered by Google App Engine
This is Rietveld 408576698