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 #include "components/password_manager/core/browser/login_database.h" | 5 #include "components/password_manager/core/browser/login_database.h" |
6 | 6 |
7 #include <algorithm> | 7 #include <algorithm> |
8 #include <limits> | 8 #include <limits> |
9 | 9 |
10 #include "base/bind.h" | 10 #include "base/bind.h" |
11 #include "base/files/file_path.h" | 11 #include "base/files/file_path.h" |
12 #include "base/logging.h" | 12 #include "base/logging.h" |
13 #include "base/metrics/histogram.h" | 13 #include "base/metrics/histogram.h" |
14 #include "base/pickle.h" | 14 #include "base/pickle.h" |
15 #include "base/profiler/scoped_tracker.h" | |
16 #include "base/strings/string_util.h" | 15 #include "base/strings/string_util.h" |
17 #include "base/strings/stringprintf.h" | 16 #include "base/strings/stringprintf.h" |
18 #include "base/time/time.h" | 17 #include "base/time/time.h" |
19 #include "components/autofill/core/common/password_form.h" | 18 #include "components/autofill/core/common/password_form.h" |
20 #include "components/password_manager/core/browser/password_manager_client.h" | 19 #include "components/password_manager/core/browser/password_manager_client.h" |
21 #include "google_apis/gaia/gaia_auth_util.h" | 20 #include "google_apis/gaia/gaia_auth_util.h" |
22 #include "google_apis/gaia/gaia_urls.h" | 21 #include "google_apis/gaia/gaia_urls.h" |
23 #include "sql/connection.h" | 22 #include "sql/connection.h" |
24 #include "sql/statement.h" | 23 #include "sql/statement.h" |
25 #include "sql/transaction.h" | 24 #include "sql/transaction.h" |
(...skipping 134 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
160 LoginDatabase::~LoginDatabase() { | 159 LoginDatabase::~LoginDatabase() { |
161 } | 160 } |
162 | 161 |
163 bool LoginDatabase::Init() { | 162 bool LoginDatabase::Init() { |
164 // Set pragmas for a small, private database (based on WebDatabase). | 163 // Set pragmas for a small, private database (based on WebDatabase). |
165 db_.set_page_size(2048); | 164 db_.set_page_size(2048); |
166 db_.set_cache_size(32); | 165 db_.set_cache_size(32); |
167 db_.set_exclusive_locking(); | 166 db_.set_exclusive_locking(); |
168 db_.set_restrict_to_user(); | 167 db_.set_restrict_to_user(); |
169 | 168 |
170 { | 169 if (!db_.Open(db_path_)) { |
171 // TODO(vadimt): Remove ScopedTracker below once crbug.com/138903 is fixed. | 170 LOG(WARNING) << "Unable to open the password store database."; |
172 tracked_objects::ScopedTracker tracking_profile( | 171 return false; |
173 FROM_HERE_WITH_EXPLICIT_FUNCTION("138903 LoginDatabase::Init db init")); | |
174 | |
175 if (!db_.Open(db_path_)) { | |
176 LOG(WARNING) << "Unable to open the password store database."; | |
177 return false; | |
178 } | |
179 } | 172 } |
180 | 173 |
181 sql::Transaction transaction(&db_); | 174 sql::Transaction transaction(&db_); |
182 transaction.Begin(); | 175 transaction.Begin(); |
183 | 176 |
184 // Check the database version. | 177 // Check the database version. |
185 if (!meta_table_.Init(&db_, kCurrentVersionNumber, | 178 if (!meta_table_.Init(&db_, kCurrentVersionNumber, |
186 kCompatibleVersionNumber)) { | 179 kCompatibleVersionNumber)) { |
187 db_.Close(); | 180 db_.Close(); |
188 return false; | 181 return false; |
(...skipping 697 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
886 | 879 |
887 bool LoginDatabase::DeleteAndRecreateDatabaseFile() { | 880 bool LoginDatabase::DeleteAndRecreateDatabaseFile() { |
888 DCHECK(db_.is_open()); | 881 DCHECK(db_.is_open()); |
889 meta_table_.Reset(); | 882 meta_table_.Reset(); |
890 db_.Close(); | 883 db_.Close(); |
891 sql::Connection::Delete(db_path_); | 884 sql::Connection::Delete(db_path_); |
892 return Init(); | 885 return Init(); |
893 } | 886 } |
894 | 887 |
895 } // namespace password_manager | 888 } // namespace password_manager |
OLD | NEW |