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

Side by Side Diff: chrome/browser/password_manager/password_store_win_unittest.cc

Issue 838453003: Open the LoginDatabase on the DB thread, not the UI thread. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fix nits from vabr@. Created 5 years, 11 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 unified diff | Download patch
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include <windows.h> 5 #include <windows.h>
6 6
7 #include <string> 7 #include <string>
8 #include <vector> 8 #include <vector>
9 9
10 #include "base/bind.h" 10 #include "base/bind.h"
(...skipping 98 matching lines...) Expand 10 before | Expand all | Expand 10 after
109 109
110 return true; 110 return true;
111 } 111 }
112 112
113 virtual void SetUp() { 113 virtual void SetUp() {
114 ASSERT_TRUE(db_thread_.Start()); 114 ASSERT_TRUE(db_thread_.Start());
115 ASSERT_TRUE(temp_dir_.CreateUniqueTempDir()); 115 ASSERT_TRUE(temp_dir_.CreateUniqueTempDir());
116 116
117 profile_.reset(new TestingProfile()); 117 profile_.reset(new TestingProfile());
118 118
119 login_db_.reset(new LoginDatabase());
120 ASSERT_TRUE(login_db_->Init(temp_dir_.path().Append(
121 FILE_PATH_LITERAL("login_test"))));
122 base::FilePath path = temp_dir_.path().AppendASCII("web_data_test"); 119 base::FilePath path = temp_dir_.path().AppendASCII("web_data_test");
123 wdbs_ = new WebDatabaseService(path, 120 wdbs_ = new WebDatabaseService(path,
124 BrowserThread::GetMessageLoopProxyForThread(BrowserThread::UI), 121 BrowserThread::GetMessageLoopProxyForThread(BrowserThread::UI),
125 BrowserThread::GetMessageLoopProxyForThread(BrowserThread::DB)); 122 BrowserThread::GetMessageLoopProxyForThread(BrowserThread::DB));
126 // Need to add at least one table so the database gets created. 123 // Need to add at least one table so the database gets created.
127 wdbs_->AddTable(scoped_ptr<WebDatabaseTable>(new LoginsTable())); 124 wdbs_->AddTable(scoped_ptr<WebDatabaseTable>(new LoginsTable()));
128 wdbs_->LoadDatabase(); 125 wdbs_->LoadDatabase();
129 wds_ = new PasswordWebDataService( 126 wds_ = new PasswordWebDataService(
130 wdbs_, 127 wdbs_,
131 BrowserThread::GetMessageLoopProxyForThread(BrowserThread::UI), 128 BrowserThread::GetMessageLoopProxyForThread(BrowserThread::UI),
(...skipping 11 matching lines...) Expand all
143 base::WaitableEvent done(false, false); 140 base::WaitableEvent done(false, false);
144 BrowserThread::PostTask(BrowserThread::DB, FROM_HERE, 141 BrowserThread::PostTask(BrowserThread::DB, FROM_HERE,
145 base::Bind(&base::WaitableEvent::Signal, base::Unretained(&done))); 142 base::Bind(&base::WaitableEvent::Signal, base::Unretained(&done)));
146 done.Wait(); 143 done.Wait();
147 base::MessageLoop::current()->PostTask(FROM_HERE, 144 base::MessageLoop::current()->PostTask(FROM_HERE,
148 base::MessageLoop::QuitClosure()); 145 base::MessageLoop::QuitClosure());
149 base::MessageLoop::current()->Run(); 146 base::MessageLoop::current()->Run();
150 db_thread_.Stop(); 147 db_thread_.Stop();
151 } 148 }
152 149
150 base::FilePath test_login_db_file_path() const {
151 return temp_dir_.path().Append(FILE_PATH_LITERAL("login_test"));
152 }
153
153 PasswordStoreWin* CreatePasswordStore() { 154 PasswordStoreWin* CreatePasswordStore() {
154 return new PasswordStoreWin( 155 return new PasswordStoreWin(
155 base::MessageLoopProxy::current(), 156 base::MessageLoopProxy::current(),
156 BrowserThread::GetMessageLoopProxyForThread(BrowserThread::DB), 157 BrowserThread::GetMessageLoopProxyForThread(BrowserThread::DB),
157 login_db_.release(), 158 make_scoped_ptr(new LoginDatabase(test_login_db_file_path())),
158 wds_.get()); 159 wds_.get());
159 } 160 }
160 161
161 base::MessageLoopForUI message_loop_; 162 base::MessageLoopForUI message_loop_;
162 content::TestBrowserThread ui_thread_; 163 content::TestBrowserThread ui_thread_;
163 // PasswordStore, WDS schedule work on this thread. 164 // PasswordStore, WDS schedule work on this thread.
164 content::TestBrowserThread db_thread_; 165 content::TestBrowserThread db_thread_;
165 166
166 base::ScopedTempDir temp_dir_; 167 base::ScopedTempDir temp_dir_;
167 scoped_ptr<TestingProfile> profile_; 168 scoped_ptr<TestingProfile> profile_;
168 scoped_ptr<LoginDatabase> login_db_;
169 scoped_refptr<PasswordWebDataService> wds_; 169 scoped_refptr<PasswordWebDataService> wds_;
170 scoped_refptr<WebDatabaseService> wdbs_; 170 scoped_refptr<WebDatabaseService> wdbs_;
171 scoped_refptr<PasswordStore> store_; 171 scoped_refptr<PasswordStore> store_;
172 }; 172 };
173 173
174 ACTION(STLDeleteElements0) { 174 ACTION(STLDeleteElements0) {
175 STLDeleteContainerPointers(arg0.begin(), arg0.end()); 175 STLDeleteContainerPointers(arg0.begin(), arg0.end());
176 } 176 }
177 177
178 ACTION(QuitUIMessageLoop) { 178 ACTION(QuitUIMessageLoop) {
(...skipping 251 matching lines...) Expand 10 before | Expand all | Expand 10 after
430 VectorOfForms expect_none; 430 VectorOfForms expect_none;
431 // expect that we get no results; 431 // expect that we get no results;
432 EXPECT_CALL( 432 EXPECT_CALL(
433 consumer, 433 consumer,
434 OnGetPasswordStoreResults(ContainsAllPasswordForms(expect_none))) 434 OnGetPasswordStoreResults(ContainsAllPasswordForms(expect_none)))
435 .WillOnce(DoAll(WithArg<0>(STLDeleteElements0()), QuitUIMessageLoop())); 435 .WillOnce(DoAll(WithArg<0>(STLDeleteElements0()), QuitUIMessageLoop()));
436 436
437 store_->GetAutofillableLogins(&consumer); 437 store_->GetAutofillableLogins(&consumer);
438 base::MessageLoop::current()->Run(); 438 base::MessageLoop::current()->Run();
439 } 439 }
OLDNEW
« no previous file with comments | « chrome/browser/password_manager/password_store_win.cc ('k') | chrome/browser/password_manager/password_store_x.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698