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

Side by Side Diff: chrome/browser/password_manager/password_store.h

Issue 152683002: Passwords: Remove references to BrowserThread from PasswordStore. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Rebase. Created 6 years, 10 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 | Annotate | Revision Log
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 #ifndef CHROME_BROWSER_PASSWORD_MANAGER_PASSWORD_STORE_H_ 5 #ifndef CHROME_BROWSER_PASSWORD_MANAGER_PASSWORD_STORE_H_
6 #define CHROME_BROWSER_PASSWORD_MANAGER_PASSWORD_STORE_H_ 6 #define CHROME_BROWSER_PASSWORD_MANAGER_PASSWORD_STORE_H_
7 7
8 #include <vector> 8 #include <vector>
9 9
10 #include "base/callback.h" 10 #include "base/callback.h"
11 #include "base/gtest_prod_util.h"
11 #include "base/memory/ref_counted.h" 12 #include "base/memory/ref_counted.h"
12 #include "base/memory/scoped_ptr.h" 13 #include "base/memory/scoped_ptr.h"
13 #include "base/observer_list.h" 14 #include "base/observer_list.h"
14 #include "base/threading/thread.h" 15 #include "base/threading/thread.h"
15 #include "base/threading/thread_checker.h" 16 #include "base/threading/thread_checker.h"
16 #include "base/time/time.h" 17 #include "base/time/time.h"
17 #include "chrome/browser/common/cancelable_request.h" 18 #include "chrome/browser/common/cancelable_request.h"
18 #include "components/browser_context_keyed_service/refcounted_browser_context_ke yed_service.h" 19 #include "components/browser_context_keyed_service/refcounted_browser_context_ke yed_service.h"
19 20
20 class PasswordStore; 21 class PasswordStore;
(...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after
96 // PasswordStore::SetObserver. 97 // PasswordStore::SetObserver.
97 class Observer { 98 class Observer {
98 public: 99 public:
99 // Notifies the observer that password data changed in some way. 100 // Notifies the observer that password data changed in some way.
100 virtual void OnLoginsChanged() = 0; 101 virtual void OnLoginsChanged() = 0;
101 102
102 protected: 103 protected:
103 virtual ~Observer() {} 104 virtual ~Observer() {}
104 }; 105 };
105 106
106 PasswordStore(); 107 PasswordStore(
108 scoped_refptr<base::SingleThreadTaskRunner> main_thread_runner,
109 scoped_refptr<base::SingleThreadTaskRunner> db_thread_runner);
107 110
108 // Reimplement this to add custom initialization. Always call this too. 111 // Reimplement this to add custom initialization. Always call this too.
109 virtual bool Init(); 112 virtual bool Init();
110 113
111 // Adds the given PasswordForm to the secure password store asynchronously. 114 // Adds the given PasswordForm to the secure password store asynchronously.
112 virtual void AddLogin(const autofill::PasswordForm& form); 115 virtual void AddLogin(const autofill::PasswordForm& form);
113 116
114 // Updates the matching PasswordForm in the secure password store (async). 117 // Updates the matching PasswordForm in the secure password store (async).
115 void UpdateLogin(const autofill::PasswordForm& form); 118 void UpdateLogin(const autofill::PasswordForm& form);
116 119
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after
162 friend class browser_sync::PasswordDataTypeController; 165 friend class browser_sync::PasswordDataTypeController;
163 friend class browser_sync::PasswordModelAssociator; 166 friend class browser_sync::PasswordModelAssociator;
164 friend class browser_sync::PasswordModelWorker; 167 friend class browser_sync::PasswordModelWorker;
165 friend class PasswordSyncableService; 168 friend class PasswordSyncableService;
166 friend void passwords_helper::AddLogin(PasswordStore*, 169 friend void passwords_helper::AddLogin(PasswordStore*,
167 const autofill::PasswordForm&); 170 const autofill::PasswordForm&);
168 friend void passwords_helper::RemoveLogin(PasswordStore*, 171 friend void passwords_helper::RemoveLogin(PasswordStore*,
169 const autofill::PasswordForm&); 172 const autofill::PasswordForm&);
170 friend void passwords_helper::UpdateLogin(PasswordStore*, 173 friend void passwords_helper::UpdateLogin(PasswordStore*,
171 const autofill::PasswordForm&); 174 const autofill::PasswordForm&);
175 FRIEND_TEST_ALL_PREFIXES(PasswordStoreTest, IgnoreOldWwwGoogleLogins);
172 176
173 virtual ~PasswordStore(); 177 virtual ~PasswordStore();
174 178
175 // Schedules the given |task| to be run on the PasswordStore's TaskRunner. 179 // Schedules the given |task| to be run on the PasswordStore's TaskRunner.
176 bool ScheduleTask(const base::Closure& task); 180 bool ScheduleTask(const base::Closure& task);
177 181
178 // Get the TaskRunner to use for PasswordStore tasks. 182 // Get the TaskRunner to use for PasswordStore background tasks.
179 // By default, a SingleThreadTaskRunner on the DB thread is used, but 183 // By default, a SingleThreadTaskRunner on the DB thread is used, but
180 // subclasses can override. 184 // subclasses can override.
181 virtual scoped_refptr<base::SequencedTaskRunner> GetTaskRunner(); 185 virtual scoped_refptr<base::SequencedTaskRunner> GetBackgroundTaskRunner();
182 186
183 // These will be run in PasswordStore's own thread. 187 // These will be run in PasswordStore's own thread.
184 // Synchronous implementation that reports usage metrics. 188 // Synchronous implementation that reports usage metrics.
185 virtual void ReportMetricsImpl() = 0; 189 virtual void ReportMetricsImpl() = 0;
186 // Synchronous implementation to add the given login. 190 // Synchronous implementation to add the given login.
187 virtual void AddLoginImpl(const autofill::PasswordForm& form) = 0; 191 virtual void AddLoginImpl(const autofill::PasswordForm& form) = 0;
188 // Synchronous implementation to update the given login. 192 // Synchronous implementation to update the given login.
189 virtual void UpdateLoginImpl(const autofill::PasswordForm& form) = 0; 193 virtual void UpdateLoginImpl(const autofill::PasswordForm& form) = 0;
190 // Synchronous implementation to remove the given login. 194 // Synchronous implementation to remove the given login.
191 virtual void RemoveLoginImpl(const autofill::PasswordForm& form) = 0; 195 virtual void RemoveLoginImpl(const autofill::PasswordForm& form) = 0;
(...skipping 26 matching lines...) Expand all
218 virtual bool FillBlacklistLogins( 222 virtual bool FillBlacklistLogins(
219 std::vector<autofill::PasswordForm*>* forms) = 0; 223 std::vector<autofill::PasswordForm*>* forms) = 0;
220 224
221 // Dispatches the result to the PasswordStoreConsumer on the original caller's 225 // Dispatches the result to the PasswordStoreConsumer on the original caller's
222 // thread so the callback can be executed there. This should be the UI thread. 226 // thread so the callback can be executed there. This should be the UI thread.
223 virtual void ForwardLoginsResult(GetLoginsRequest* request); 227 virtual void ForwardLoginsResult(GetLoginsRequest* request);
224 228
225 // Log UMA stats for number of bulk deletions. 229 // Log UMA stats for number of bulk deletions.
226 void LogStatsForBulkDeletion(int num_deletions); 230 void LogStatsForBulkDeletion(int num_deletions);
227 231
232 // TaskRunner for tasks that run on the main thread (usually the UI thread).
233 scoped_refptr<base::SingleThreadTaskRunner> main_thread_runner_;
234
235 // TaskRunner for the DB thread. By default, this is the task runner used for
236 // background tasks -- see |GetBackgroundTaskRunner|.
237 scoped_refptr<base::SingleThreadTaskRunner> db_thread_runner_;
238
228 private: 239 private:
229 // Schedule the given |func| to be run in the PasswordStore's own thread with 240 // Schedule the given |func| to be run in the PasswordStore's own thread with
230 // responses delivered to |consumer| on the current thread. 241 // responses delivered to |consumer| on the current thread.
231 template<typename BackendFunc> 242 template<typename BackendFunc>
232 void Schedule(BackendFunc func, PasswordStoreConsumer* consumer); 243 void Schedule(BackendFunc func, PasswordStoreConsumer* consumer);
233 244
234 // Wrapper method called on the destination thread (DB for non-mac) that 245 // Wrapper method called on the destination thread (DB for non-mac) that
235 // invokes |task| and then calls back into the source thread to notify 246 // invokes |task| and then calls back into the source thread to notify
236 // observers that the password store may have been modified via 247 // observers that the password store may have been modified via
237 // NotifyLoginsChanged(). Note that there is no guarantee that the called 248 // NotifyLoginsChanged(). Note that there is no guarantee that the called
(...skipping 19 matching lines...) Expand all
257 PasswordStore::GetLoginsRequest* request, 268 PasswordStore::GetLoginsRequest* request,
258 const std::vector<autofill::PasswordForm*>& matched_forms); 269 const std::vector<autofill::PasswordForm*>& matched_forms);
259 270
260 // The observers. 271 // The observers.
261 ObserverList<Observer> observers_; 272 ObserverList<Observer> observers_;
262 273
263 DISALLOW_COPY_AND_ASSIGN(PasswordStore); 274 DISALLOW_COPY_AND_ASSIGN(PasswordStore);
264 }; 275 };
265 276
266 #endif // CHROME_BROWSER_PASSWORD_MANAGER_PASSWORD_STORE_H_ 277 #endif // CHROME_BROWSER_PASSWORD_MANAGER_PASSWORD_STORE_H_
OLDNEW
« no previous file with comments | « chrome/browser/password_manager/mock_password_store.cc ('k') | chrome/browser/password_manager/password_store.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698