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

Unified Diff: components/autofill/core/browser/webdata/autofill_data_type_controller_unittest.cc

Issue 1460723004: [Sync] Remove the last datatype-specific deps from sync_driver. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Delete outdated comment. Created 5 years 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/autofill/core/browser/webdata/autofill_data_type_controller_unittest.cc
diff --git a/components/autofill/core/browser/webdata/autofill_data_type_controller_unittest.cc b/components/autofill/core/browser/webdata/autofill_data_type_controller_unittest.cc
index 1c76872f2563297c653ec56f8baad84abbaa584d..c14c7e3500e996453deaae3bb70f3baa0bae1cce 100644
--- a/components/autofill/core/browser/webdata/autofill_data_type_controller_unittest.cc
+++ b/components/autofill/core/browser/webdata/autofill_data_type_controller_unittest.cc
@@ -62,8 +62,12 @@ class FakeWebDataService : public AutofillWebDataService {
StartSyncableService();
is_database_loaded_ = true;
- if (!db_loaded_callback_.is_null())
+ if (!db_loaded_callback_.is_null()) {
db_loaded_callback_.Run();
+ // Clear the callback here or the WDS and DTC will have refs to each other
+ // and create a memory leak.
+ db_loaded_callback_ = base::Callback<void(void)>();
+ }
}
bool IsDatabaseLoaded() override { return is_database_loaded_; }
@@ -102,8 +106,7 @@ class FakeWebDataService : public AutofillWebDataService {
DISALLOW_COPY_AND_ASSIGN(FakeWebDataService);
};
-class SyncAutofillDataTypeControllerTest : public testing::Test,
- public sync_driver::FakeSyncClient {
+class SyncAutofillDataTypeControllerTest : public testing::Test {
public:
SyncAutofillDataTypeControllerTest()
: db_thread_("DB_Thread"),
@@ -111,18 +114,13 @@ class SyncAutofillDataTypeControllerTest : public testing::Test,
weak_ptr_factory_(this) {}
~SyncAutofillDataTypeControllerTest() override {}
- // FakeSyncClient overrides.
- scoped_refptr<autofill::AutofillWebDataService> GetWebDataService() override {
- return web_data_service_;
- }
-
void SetUp() override {
db_thread_.Start();
web_data_service_ = new FakeWebDataService(
base::ThreadTaskRunnerHandle::Get(), db_thread_.task_runner());
autofill_dtc_ = new AutofillDataTypeController(
base::ThreadTaskRunnerHandle::Get(), db_thread_.task_runner(),
- base::Bind(&base::DoNothing), this);
+ base::Bind(&base::DoNothing), &sync_client_, web_data_service_);
}
void TearDown() override {
@@ -159,6 +157,7 @@ class SyncAutofillDataTypeControllerTest : public testing::Test,
protected:
base::MessageLoop message_loop_;
base::Thread db_thread_;
+ sync_driver::FakeSyncClient sync_client_;
scoped_refptr<AutofillDataTypeController> autofill_dtc_;
scoped_refptr<FakeWebDataService> web_data_service_;

Powered by Google App Engine
This is Rietveld 408576698