| OLD | NEW |
| 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 "base/basictypes.h" | 5 #include "base/basictypes.h" |
| 6 #include "base/bind.h" | 6 #include "base/bind.h" |
| 7 #include "base/bind_helpers.h" | 7 #include "base/bind_helpers.h" |
| 8 #include "base/file_util.h" | 8 #include "base/file_util.h" |
| 9 #include "base/platform_file.h" | 9 #include "base/platform_file.h" |
| 10 #include "base/scoped_temp_dir.h" | 10 #include "base/scoped_temp_dir.h" |
| (...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 63 void Init(PasswordStore* password_store) { | 63 void Init(PasswordStore* password_store) { |
| 64 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 64 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
| 65 BrowserThread::PostTask( | 65 BrowserThread::PostTask( |
| 66 BrowserThread::DB, | 66 BrowserThread::DB, |
| 67 FROM_HERE, | 67 FROM_HERE, |
| 68 base::Bind(&DBThreadObserverHelper::AddObserverTask, | 68 base::Bind(&DBThreadObserverHelper::AddObserverTask, |
| 69 this, make_scoped_refptr(password_store))); | 69 this, make_scoped_refptr(password_store))); |
| 70 done_event_.Wait(); | 70 done_event_.Wait(); |
| 71 } | 71 } |
| 72 | 72 |
| 73 virtual ~DBThreadObserverHelper() { | |
| 74 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::DB)); | |
| 75 registrar_.RemoveAll(); | |
| 76 } | |
| 77 | |
| 78 content::NotificationObserverMock& observer() { | 73 content::NotificationObserverMock& observer() { |
| 79 return observer_; | 74 return observer_; |
| 80 } | 75 } |
| 81 | 76 |
| 82 protected: | 77 protected: |
| 83 friend class base::RefCountedThreadSafe<DBThreadObserverHelper>; | 78 friend struct BrowserThread::DeleteOnThread<BrowserThread::DB>; |
| 79 friend class base::DeleteHelper<DBThreadObserverHelper>; |
| 80 |
| 81 virtual ~DBThreadObserverHelper() { |
| 82 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::DB)); |
| 83 registrar_.RemoveAll(); |
| 84 } |
| 84 | 85 |
| 85 void AddObserverTask(PasswordStore* password_store) { | 86 void AddObserverTask(PasswordStore* password_store) { |
| 86 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::DB)); | 87 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::DB)); |
| 87 registrar_.Add(&observer_, | 88 registrar_.Add(&observer_, |
| 88 chrome::NOTIFICATION_LOGINS_CHANGED, | 89 chrome::NOTIFICATION_LOGINS_CHANGED, |
| 89 content::Source<PasswordStore>(password_store)); | 90 content::Source<PasswordStore>(password_store)); |
| 90 done_event_.Signal(); | 91 done_event_.Signal(); |
| 91 } | 92 } |
| 92 | 93 |
| 93 WaitableEvent done_event_; | 94 WaitableEvent done_event_; |
| (...skipping 443 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 537 | 538 |
| 538 INSTANTIATE_TEST_CASE_P(NoBackend, | 539 INSTANTIATE_TEST_CASE_P(NoBackend, |
| 539 PasswordStoreXTest, | 540 PasswordStoreXTest, |
| 540 testing::Values(NO_BACKEND)); | 541 testing::Values(NO_BACKEND)); |
| 541 INSTANTIATE_TEST_CASE_P(FailingBackend, | 542 INSTANTIATE_TEST_CASE_P(FailingBackend, |
| 542 PasswordStoreXTest, | 543 PasswordStoreXTest, |
| 543 testing::Values(FAILING_BACKEND)); | 544 testing::Values(FAILING_BACKEND)); |
| 544 INSTANTIATE_TEST_CASE_P(WorkingBackend, | 545 INSTANTIATE_TEST_CASE_P(WorkingBackend, |
| 545 PasswordStoreXTest, | 546 PasswordStoreXTest, |
| 546 testing::Values(WORKING_BACKEND)); | 547 testing::Values(WORKING_BACKEND)); |
| OLD | NEW |