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

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

Issue 2931863002: Rename PasswordStoreProxyMac to PasswordStoreMac. (Closed)
Patch Set: Created 3 years, 6 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 2015 The Chromium Authors. All rights reserved. 1 // Copyright 2015 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_proxy_mac.h" 5 #include "chrome/browser/password_manager/password_store_mac.h"
6 6
7 #include "base/metrics/histogram_macros.h" 7 #include "base/metrics/histogram_macros.h"
8 #include "components/password_manager/core/common/password_manager_pref_names.h" 8 #include "components/password_manager/core/common/password_manager_pref_names.h"
9 #include "content/public/browser/browser_thread.h" 9 #include "content/public/browser/browser_thread.h"
10 10
11 using password_manager::MigrationStatus; 11 using password_manager::MigrationStatus;
12 12
13 PasswordStoreProxyMac::PasswordStoreProxyMac( 13 PasswordStoreMac::PasswordStoreMac(
14 scoped_refptr<base::SingleThreadTaskRunner> main_thread_runner, 14 scoped_refptr<base::SingleThreadTaskRunner> main_thread_runner,
15 std::unique_ptr<password_manager::LoginDatabase> login_db, 15 std::unique_ptr<password_manager::LoginDatabase> login_db,
16 PrefService* prefs) 16 PrefService* prefs)
17 : PasswordStoreDefault(main_thread_runner, nullptr, std::move(login_db)) { 17 : PasswordStoreDefault(main_thread_runner, nullptr, std::move(login_db)) {
18 migration_status_.Init(password_manager::prefs::kKeychainMigrationStatus, 18 migration_status_.Init(password_manager::prefs::kKeychainMigrationStatus,
19 prefs); 19 prefs);
20 } 20 }
21 21
22 bool PasswordStoreProxyMac::Init( 22 bool PasswordStoreMac::Init(
23 const syncer::SyncableService::StartSyncFlare& flare, 23 const syncer::SyncableService::StartSyncFlare& flare,
24 PrefService* prefs) { 24 PrefService* prefs) {
25 // Set up a background thread. 25 // Set up a background thread.
26 DCHECK_CURRENTLY_ON(content::BrowserThread::UI); 26 DCHECK_CURRENTLY_ON(content::BrowserThread::UI);
27 thread_.reset(new base::Thread("Chrome_PasswordStore_Thread")); 27 thread_.reset(new base::Thread("Chrome_PasswordStore_Thread"));
28 28
29 if (!thread_->Start()) { 29 if (!thread_->Start()) {
30 thread_.reset(); 30 thread_.reset();
31 return false; 31 return false;
32 } 32 }
33 33
34 if (PasswordStoreDefault::Init(flare, prefs)) { 34 if (PasswordStoreDefault::Init(flare, prefs)) {
35 return ScheduleTask( 35 return ScheduleTask(
36 base::Bind(&PasswordStoreProxyMac::InitOnBackgroundThread, this, 36 base::Bind(&PasswordStoreMac::InitOnBackgroundThread, this,
37 static_cast<MigrationStatus>(migration_status_.GetValue()))); 37 static_cast<MigrationStatus>(migration_status_.GetValue())));
38 } 38 }
39 39
40 return false; 40 return false;
41 } 41 }
42 42
43 void PasswordStoreProxyMac::ShutdownOnUIThread() { 43 void PasswordStoreMac::ShutdownOnUIThread() {
44 DCHECK_CURRENTLY_ON(content::BrowserThread::UI); 44 DCHECK_CURRENTLY_ON(content::BrowserThread::UI);
45 PasswordStoreDefault::ShutdownOnUIThread(); 45 PasswordStoreDefault::ShutdownOnUIThread();
46 thread_->Stop(); 46 thread_->Stop();
47 47
48 // Unsubscribe the observer, otherwise it's too late in the destructor. 48 // Unsubscribe the observer, otherwise it's too late in the destructor.
49 migration_status_.Destroy(); 49 migration_status_.Destroy();
50 } 50 }
51 51
52 scoped_refptr<base::SingleThreadTaskRunner> 52 scoped_refptr<base::SingleThreadTaskRunner>
53 PasswordStoreProxyMac::GetBackgroundTaskRunner() { 53 PasswordStoreMac::GetBackgroundTaskRunner() {
54 return thread_ ? thread_->task_runner() : nullptr; 54 return thread_ ? thread_->task_runner() : nullptr;
55 } 55 }
56 56
57 PasswordStoreProxyMac::~PasswordStoreProxyMac() = default; 57 PasswordStoreMac::~PasswordStoreMac() = default;
58 58
59 void PasswordStoreProxyMac::InitOnBackgroundThread(MigrationStatus status) { 59 void PasswordStoreMac::InitOnBackgroundThread(MigrationStatus status) {
60 DCHECK(GetBackgroundTaskRunner()->BelongsToCurrentThread()); 60 DCHECK(GetBackgroundTaskRunner()->BelongsToCurrentThread());
61 61
62 if (login_db() && (status == MigrationStatus::NOT_STARTED || 62 if (login_db() && (status == MigrationStatus::NOT_STARTED ||
63 status == MigrationStatus::FAILED_ONCE || 63 status == MigrationStatus::FAILED_ONCE ||
64 status == MigrationStatus::FAILED_TWICE)) { 64 status == MigrationStatus::FAILED_TWICE)) {
65 // Migration isn't possible due to Chrome changing the certificate. Just 65 // Migration isn't possible due to Chrome changing the certificate. Just
66 // drop the entries in the DB because they don't have passwords anyway. 66 // drop the entries in the DB because they don't have passwords anyway.
67 login_db()->RemoveLoginsCreatedBetween(base::Time(), base::Time()); 67 login_db()->RemoveLoginsCreatedBetween(base::Time(), base::Time());
68 status = MigrationStatus::MIGRATION_STOPPED; 68 status = MigrationStatus::MIGRATION_STOPPED;
69 main_thread_runner_->PostTask( 69 main_thread_runner_->PostTask(
70 FROM_HERE, 70 FROM_HERE,
71 base::Bind(&PasswordStoreProxyMac::UpdateStatusPref, this, status)); 71 base::Bind(&PasswordStoreMac::UpdateStatusPref, this, status));
72 } 72 }
73 73
74 UMA_HISTOGRAM_ENUMERATION( 74 UMA_HISTOGRAM_ENUMERATION(
75 "PasswordManager.KeychainMigration.Status", static_cast<int>(status), 75 "PasswordManager.KeychainMigration.Status", static_cast<int>(status),
76 static_cast<int>(MigrationStatus::MIGRATION_STATUS_COUNT)); 76 static_cast<int>(MigrationStatus::MIGRATION_STATUS_COUNT));
77 } 77 }
78 78
79 void PasswordStoreProxyMac::UpdateStatusPref(MigrationStatus status) { 79 void PasswordStoreMac::UpdateStatusPref(MigrationStatus status) {
80 DCHECK_CURRENTLY_ON(content::BrowserThread::UI); 80 DCHECK_CURRENTLY_ON(content::BrowserThread::UI);
81 // The method can be called after ShutdownOnUIThread(). 81 // The method can be called after ShutdownOnUIThread().
82 if (migration_status_.prefs()) 82 if (migration_status_.prefs())
83 migration_status_.SetValue(static_cast<int>(status)); 83 migration_status_.SetValue(static_cast<int>(status));
84 } 84 }
OLDNEW
« no previous file with comments | « chrome/browser/password_manager/password_store_mac.h ('k') | chrome/browser/password_manager/password_store_mac_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698