| OLD | NEW |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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 #ifndef COMPONENTS_PASSWORD_MANAGER_CORE_BROWSER_PASSWORD_STORE_DEFAULT_H_ | 5 #ifndef COMPONENTS_PASSWORD_MANAGER_CORE_BROWSER_PASSWORD_STORE_DEFAULT_H_ |
| 6 #define COMPONENTS_PASSWORD_MANAGER_CORE_BROWSER_PASSWORD_STORE_DEFAULT_H_ | 6 #define COMPONENTS_PASSWORD_MANAGER_CORE_BROWSER_PASSWORD_STORE_DEFAULT_H_ |
| 7 | 7 |
| 8 #include <memory> | 8 #include <memory> |
| 9 #include <string> | 9 #include <string> |
| 10 #include <vector> | 10 #include <vector> |
| (...skipping 16 matching lines...) Expand all Loading... |
| 27 PasswordStoreDefault( | 27 PasswordStoreDefault( |
| 28 scoped_refptr<base::SingleThreadTaskRunner> main_thread_runner, | 28 scoped_refptr<base::SingleThreadTaskRunner> main_thread_runner, |
| 29 scoped_refptr<base::SingleThreadTaskRunner> db_thread_runner, | 29 scoped_refptr<base::SingleThreadTaskRunner> db_thread_runner, |
| 30 std::unique_ptr<LoginDatabase> login_db); | 30 std::unique_ptr<LoginDatabase> login_db); |
| 31 | 31 |
| 32 bool Init(const syncer::SyncableService::StartSyncFlare& flare, | 32 bool Init(const syncer::SyncableService::StartSyncFlare& flare, |
| 33 PrefService* prefs) override; | 33 PrefService* prefs) override; |
| 34 | 34 |
| 35 void ShutdownOnUIThread() override; | 35 void ShutdownOnUIThread() override; |
| 36 | 36 |
| 37 // To be used only for testing. | 37 // To be used only for testing or in subclasses. |
| 38 LoginDatabase* login_db() const { return login_db_.get(); } | 38 LoginDatabase* login_db() const { return login_db_.get(); } |
| 39 | 39 |
| 40 protected: | 40 protected: |
| 41 ~PasswordStoreDefault() override; | 41 ~PasswordStoreDefault() override; |
| 42 | 42 |
| 43 // Opens |login_db_| on the DB thread. | 43 // Opens |login_db_| on the DB thread. |
| 44 void InitOnDBThread(); | 44 void InitOnDBThread(); |
| 45 | 45 |
| 46 // Implements PasswordStore interface. | 46 // Implements PasswordStore interface. |
| 47 void ReportMetricsImpl(const std::string& sync_username, | 47 void ReportMetricsImpl(const std::string& sync_username, |
| (...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 79 void AddSiteStatsImpl(const InteractionsStats& stats) override; | 79 void AddSiteStatsImpl(const InteractionsStats& stats) override; |
| 80 void RemoveSiteStatsImpl(const GURL& origin_domain) override; | 80 void RemoveSiteStatsImpl(const GURL& origin_domain) override; |
| 81 std::vector<InteractionsStats> GetAllSiteStatsImpl() override; | 81 std::vector<InteractionsStats> GetAllSiteStatsImpl() override; |
| 82 std::vector<InteractionsStats> GetSiteStatsImpl( | 82 std::vector<InteractionsStats> GetSiteStatsImpl( |
| 83 const GURL& origin_domain) override; | 83 const GURL& origin_domain) override; |
| 84 | 84 |
| 85 inline bool DeleteAndRecreateDatabaseFile() { | 85 inline bool DeleteAndRecreateDatabaseFile() { |
| 86 return login_db_->DeleteAndRecreateDatabaseFile(); | 86 return login_db_->DeleteAndRecreateDatabaseFile(); |
| 87 } | 87 } |
| 88 | 88 |
| 89 void set_login_db(std::unique_ptr<password_manager::LoginDatabase> login_db) { | |
| 90 login_db_.swap(login_db); | |
| 91 } | |
| 92 | |
| 93 private: | 89 private: |
| 94 // Resets |login_db_| on the background thread. | 90 // Resets |login_db_| on the background thread. |
| 95 void ResetLoginDB(); | 91 void ResetLoginDB(); |
| 96 | 92 |
| 97 // The login SQL database. The LoginDatabase instance is received via the | 93 // The login SQL database. The LoginDatabase instance is received via the |
| 98 // in an uninitialized state, so as to allow injecting mocks, then Init() is | 94 // in an uninitialized state, so as to allow injecting mocks, then Init() is |
| 99 // called on the DB thread in a deferred manner. If opening the DB fails, | 95 // called on the DB thread in a deferred manner. If opening the DB fails, |
| 100 // |login_db_| will be reset and stay NULL for the lifetime of |this|. | 96 // |login_db_| will be reset and stay NULL for the lifetime of |this|. |
| 101 std::unique_ptr<LoginDatabase> login_db_; | 97 std::unique_ptr<LoginDatabase> login_db_; |
| 102 | 98 |
| 103 DISALLOW_COPY_AND_ASSIGN(PasswordStoreDefault); | 99 DISALLOW_COPY_AND_ASSIGN(PasswordStoreDefault); |
| 104 }; | 100 }; |
| 105 | 101 |
| 106 } // namespace password_manager | 102 } // namespace password_manager |
| 107 | 103 |
| 108 #endif // COMPONENTS_PASSWORD_MANAGER_CORE_BROWSER_PASSWORD_STORE_DEFAULT_H_ | 104 #endif // COMPONENTS_PASSWORD_MANAGER_CORE_BROWSER_PASSWORD_STORE_DEFAULT_H_ |
| OLD | NEW |