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

Unified Diff: components/safe_browsing_db/database_manager_unittest.cc

Issue 1944433002: Make V4GetHashProtocolManager::RegisterFactory safe. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Re-enable the right tests. Created 4 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: components/safe_browsing_db/database_manager_unittest.cc
diff --git a/components/safe_browsing_db/database_manager_unittest.cc b/components/safe_browsing_db/database_manager_unittest.cc
index 8abd111fb9ab8a3a02b488be19a57e7d13339f09..db8fd9cf20db3505ef686b1051cfead35ceb0831 100644
--- a/components/safe_browsing_db/database_manager_unittest.cc
+++ b/components/safe_browsing_db/database_manager_unittest.cc
@@ -10,6 +10,7 @@
#include <vector>
#include "base/macros.h"
+#include "base/memory/ptr_util.h"
#include "base/memory/ref_counted.h"
#include "base/message_loop/message_loop.h"
#include "base/run_loop.h"
@@ -117,8 +118,8 @@ class TestClient : public SafeBrowsingDatabaseManager::Client {
class SafeBrowsingDatabaseManagerTest : public testing::Test {
protected:
void SetUp() override {
- TestV4GetHashProtocolManagerFactory get_hash_pm_factory;
- V4GetHashProtocolManager::RegisterFactory(&get_hash_pm_factory);
+ V4GetHashProtocolManager::RegisterFactory(
+ base::WrapUnique(new TestV4GetHashProtocolManagerFactory()));
mattm 2016/05/02 22:36:53 The RegisterFactory idiom is already used in a bun
Reilly Grant (use Gerrit) 2016/05/02 22:55:27 I agree in principle but this is the only place in
kcarattini 2016/05/03 01:16:32 I'm not sure I follow why passing a unique_ptr is
Reilly Grant (use Gerrit) 2016/05/03 01:18:21 It prevents you from passing a pointer to a local
db_manager_ = new TestSafeBrowsingDatabaseManager();
db_manager_->StartOnIOThread(NULL, V4ProtocolConfig());
@@ -127,6 +128,7 @@ class SafeBrowsingDatabaseManagerTest : public testing::Test {
void TearDown() override {
base::RunLoop().RunUntilIdle();
db_manager_->StopOnIOThread(false);
+ V4GetHashProtocolManager::RegisterFactory(nullptr);
}
scoped_refptr<SafeBrowsingDatabaseManager> db_manager_;

Powered by Google App Engine
This is Rietveld 408576698