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

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

Issue 11570009: Split PrefService into PrefService, PrefServiceSimple and PrefServiceSyncable. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: WIP, latest changes from kaiwang@ Created 8 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 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 #include "chrome/browser/password_manager/password_store_x.h" 5 #include "chrome/browser/password_manager/password_store_x.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 #include <map> 8 #include <map>
9 #include <vector> 9 #include <vector>
10 10
(...skipping 249 matching lines...) Expand 10 before | Expand all | Expand 10 after
260 DeleteAndRecreateDatabaseFile(); 260 DeleteAndRecreateDatabaseFile();
261 } 261 }
262 } 262 }
263 ssize_t result = ok ? forms.size() : -1; 263 ssize_t result = ok ? forms.size() : -1;
264 STLDeleteElements(&forms); 264 STLDeleteElements(&forms);
265 return result; 265 return result;
266 } 266 }
267 267
268 #if !defined(OS_MACOSX) && !defined(OS_CHROMEOS) && defined(OS_POSIX) 268 #if !defined(OS_MACOSX) && !defined(OS_CHROMEOS) && defined(OS_POSIX)
269 // static 269 // static
270 void PasswordStoreX::RegisterUserPrefs(PrefService* prefs) { 270 void PasswordStoreX::RegisterUserPrefs(PrefServiceSyncable* prefs) {
271 // Normally we should be on the UI thread here, but in tests we might not. 271 // Normally we should be on the UI thread here, but in tests we might not.
272 prefs->RegisterBooleanPref(prefs::kPasswordsUseLocalProfileId, 272 prefs->RegisterBooleanPref(prefs::kPasswordsUseLocalProfileId,
273 false, // default: passwords don't use local ids 273 false, // default: passwords don't use local ids
274 PrefService::UNSYNCABLE_PREF); 274 PrefServiceSyncable::UNSYNCABLE_PREF);
275 } 275 }
276 276
277 // static 277 // static
278 bool PasswordStoreX::PasswordsUseLocalProfileId(PrefService* prefs) { 278 bool PasswordStoreX::PasswordsUseLocalProfileId(PrefService* prefs) {
279 // Normally we should be on the UI thread here, but in tests we might not. 279 // Normally we should be on the UI thread here, but in tests we might not.
280 return prefs->GetBoolean(prefs::kPasswordsUseLocalProfileId); 280 return prefs->GetBoolean(prefs::kPasswordsUseLocalProfileId);
281 } 281 }
282 282
283 namespace { 283 namespace {
284 // This function is a hack to do something not entirely thread safe: the pref 284 // This function is a hack to do something not entirely thread safe: the pref
285 // service comes from the UI thread, but it's not ref counted. We keep a pointer 285 // service comes from the UI thread, but it's not ref counted. We keep a pointer
286 // to it on the DB thread, and need to invoke a method on the UI thread. This 286 // to it on the DB thread, and need to invoke a method on the UI thread. This
287 // function does that for us without requiring ref counting the pref service. 287 // function does that for us without requiring ref counting the pref service.
288 // TODO(mdm): Fix this if it becomes a problem. Given that this function will 288 // TODO(mdm): Fix this if it becomes a problem. Given that this function will
289 // be called once ever per profile, it probably will not cause a problem... 289 // be called once ever per profile, it probably will not cause a problem...
290 void UISetPasswordsUseLocalProfileId(PrefService* prefs) { 290 void UISetPasswordsUseLocalProfileId(PrefService* prefs) {
291 prefs->SetBoolean(prefs::kPasswordsUseLocalProfileId, true); 291 prefs->SetBoolean(prefs::kPasswordsUseLocalProfileId, true);
292 } 292 }
293 } // anonymous namespace 293 } // anonymous namespace
294 294
295 // static 295 // static
296 void PasswordStoreX::SetPasswordsUseLocalProfileId(PrefService* prefs) { 296 void PasswordStoreX::SetPasswordsUseLocalProfileId(PrefService* prefs) {
297 // This method should work on any thread, but we expect the DB thread. 297 // This method should work on any thread, but we expect the DB thread.
298 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::DB)); 298 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::DB));
299 BrowserThread::PostTask(BrowserThread::UI, FROM_HERE, 299 BrowserThread::PostTask(BrowserThread::UI, FROM_HERE,
300 base::Bind(&UISetPasswordsUseLocalProfileId, prefs)); 300 base::Bind(&UISetPasswordsUseLocalProfileId, prefs));
301 } 301 }
302 #endif // !defined(OS_MACOSX) && !defined(OS_CHROMEOS) && defined(OS_POSIX) 302 #endif // !defined(OS_MACOSX) && !defined(OS_CHROMEOS) && defined(OS_POSIX)
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698