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

Unified Diff: components/safe_browsing/base_safe_browsing_service.cc

Issue 2605213002: componentize SafeBrowsingService (Closed)
Patch Set: Removing some methods from base class and addressing comments 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
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..884c552fbf414e9f0d0ad68407feccdf06122dfe
--- /dev/null
+++ b/components/safe_browsing/base_safe_browsing_service.cc
@@ -0,0 +1,82 @@
+// Copyright (c) 2012 The Chromium Authors. All rights reserved.
Jialiu Lin 2017/01/04 01:36:34 2017
Nate Fischer 2017/01/04 01:45:59 done
+// 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
+ return;
+}
+
+void BaseSafeBrowsingService::ShutDown() {
+ return;
+}
+
+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() {
+#if defined(SAFE_BROWSING_DB_REMOTE)
Jialiu Lin 2017/01/04 01:36:34 Maybe add a comment here to tell others if they ne
Nate Fischer 2017/01/04 01:45:59 Done
+ 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);
+ return;
Jialiu Lin 2017/01/04 01:36:34 don't need this return.
Nate Fischer 2017/01/04 01:45:59 Done. Should I also remove the explicit returns in
Jialiu Lin 2017/01/04 01:51:28 Yes, sounds good.
+}
+
+} // namespace safe_browsing

Powered by Google App Engine
This is Rietveld 408576698