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

Unified Diff: components/safe_browsing/base_safe_browsing_service.cc

Issue 2605213002: componentize SafeBrowsingService (Closed)
Patch Set: Remove explicit return statements Created 3 years, 12 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
« no previous file with comments | « components/safe_browsing/base_safe_browsing_service.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: components/safe_browsing/base_safe_browsing_service.cc
diff --git a/components/safe_browsing/base_safe_browsing_service.cc b/components/safe_browsing/base_safe_browsing_service.cc
new file mode 100644
index 0000000000000000000000000000000000000000..0817b18f7311d8141761b0883d35313257747be0
--- /dev/null
+++ b/components/safe_browsing/base_safe_browsing_service.cc
@@ -0,0 +1,80 @@
+// Copyright (c) 2017 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.
+
+#include "components/safe_browsing/base_safe_browsing_service.h"
+
+#include <stddef.h>
+
+#include "base/bind.h"
+#include "base/macros.h"
+#include "base/path_service.h"
+#include "components/safe_browsing/common/safebrowsing_constants.h"
+#include "components/safe_browsing_db/database_manager.h"
+#include "components/safe_browsing_db/safe_browsing_prefs.h"
+#include "content/public/browser/browser_thread.h"
+#include "content/public/browser/resource_request_info.h"
+#include "net/url_request/url_request_context.h"
+#include "net/url_request/url_request_context_getter.h"
+
+#if defined(SAFE_BROWSING_DB_REMOTE)
+#include "components/safe_browsing_db/remote_database_manager.h"
+#endif
+
+using content::BrowserThread;
+
+namespace safe_browsing {
+
+BaseSafeBrowsingService::BaseSafeBrowsingService() : enabled_(false) {}
+
+BaseSafeBrowsingService::~BaseSafeBrowsingService() {
+ // We should have already been shut down. If we're still enabled, then the
+ // database isn't going to be closed properly, which could lead to corruption.
+ DCHECK(!enabled_);
+}
+
+void BaseSafeBrowsingService::Initialize() {
+ // TODO(ntfschr): initialize ui_manager_ once CreateUIManager is componentized
+}
+
+void BaseSafeBrowsingService::ShutDown() {}
+
+scoped_refptr<net::URLRequestContextGetter>
+BaseSafeBrowsingService::url_request_context() {
+ DCHECK_CURRENTLY_ON(BrowserThread::UI);
+ return nullptr;
+}
+
+const scoped_refptr<SafeBrowsingDatabaseManager>&
+BaseSafeBrowsingService::database_manager() const {
+ return database_manager_;
+}
+
+void BaseSafeBrowsingService::OnResourceRequest(
+ const net::URLRequest* request) {
+ DCHECK_CURRENTLY_ON(BrowserThread::IO);
+}
+
+SafeBrowsingDatabaseManager* BaseSafeBrowsingService::CreateDatabaseManager() {
+// For the LocalSafeBrowsingDatabaseManager, use
+// chrome/browser/safe_browsing_service
+#if defined(SAFE_BROWSING_DB_REMOTE)
+ return new RemoteSafeBrowsingDatabaseManager();
+#else
+ return NULL;
+#endif
+}
+
+std::unique_ptr<BaseSafeBrowsingService::StateSubscription>
+BaseSafeBrowsingService::RegisterStateCallback(
+ const base::Callback<void(void)>& callback) {
+ DCHECK_CURRENTLY_ON(BrowserThread::UI);
+ return state_callback_list_.Add(callback);
+}
+
+void BaseSafeBrowsingService::ProcessResourceRequest(
+ const ResourceRequestInfo& request) {
+ DCHECK_CURRENTLY_ON(BrowserThread::UI);
+}
+
+} // namespace safe_browsing
« no previous file with comments | « components/safe_browsing/base_safe_browsing_service.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698