| 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" |
| 15 #include "base/strings/string_util.h" | 16 #include "base/strings/string_util.h" |
| 16 #include "base/strings/stringprintf.h" | 17 #include "base/strings/stringprintf.h" |
| 17 #include "base/time/time.h" | 18 #include "base/time/time.h" |
| 18 #include "components/autofill/core/common/password_form.h" | 19 #include "components/autofill/core/common/password_form.h" |
| 19 #include "components/password_manager/core/browser/password_manager_client.h" | 20 #include "components/password_manager/core/browser/password_manager_client.h" |
| 20 #include "google_apis/gaia/gaia_auth_util.h" | 21 #include "google_apis/gaia/gaia_auth_util.h" |
| 21 #include "google_apis/gaia/gaia_urls.h" | 22 #include "google_apis/gaia/gaia_urls.h" |
| 22 #include "sql/connection.h" | 23 #include "sql/connection.h" |
| 23 #include "sql/statement.h" | 24 #include "sql/statement.h" |
| 24 #include "sql/transaction.h" | 25 #include "sql/transaction.h" |
| (...skipping 124 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 149 LoginDatabase::~LoginDatabase() { | 150 LoginDatabase::~LoginDatabase() { |
| 150 } | 151 } |
| 151 | 152 |
| 152 bool LoginDatabase::Init(const base::FilePath& db_path) { | 153 bool LoginDatabase::Init(const base::FilePath& db_path) { |
| 153 // Set pragmas for a small, private database (based on WebDatabase). | 154 // Set pragmas for a small, private database (based on WebDatabase). |
| 154 db_.set_page_size(2048); | 155 db_.set_page_size(2048); |
| 155 db_.set_cache_size(32); | 156 db_.set_cache_size(32); |
| 156 db_.set_exclusive_locking(); | 157 db_.set_exclusive_locking(); |
| 157 db_.set_restrict_to_user(); | 158 db_.set_restrict_to_user(); |
| 158 | 159 |
| 159 if (!db_.Open(db_path)) { | 160 { |
| 160 LOG(WARNING) << "Unable to open the password store database."; | 161 // TODO(vadimt): Remove ScopedTracker below once crbug.com/138903 is fixed. |
| 161 return false; | 162 tracked_objects::ScopedTracker tracking_profile( |
| 163 FROM_HERE_WITH_EXPLICIT_FUNCTION("138903 LoginDatabase::Init db init")); |
| 164 |
| 165 if (!db_.Open(db_path)) { |
| 166 LOG(WARNING) << "Unable to open the password store database."; |
| 167 return false; |
| 168 } |
| 162 } | 169 } |
| 163 | 170 |
| 164 sql::Transaction transaction(&db_); | 171 sql::Transaction transaction(&db_); |
| 165 transaction.Begin(); | 172 transaction.Begin(); |
| 166 | 173 |
| 167 // Check the database version. | 174 // Check the database version. |
| 168 if (!meta_table_.Init(&db_, kCurrentVersionNumber, | 175 if (!meta_table_.Init(&db_, kCurrentVersionNumber, |
| 169 kCompatibleVersionNumber)) { | 176 kCompatibleVersionNumber)) { |
| 170 db_.Close(); | 177 db_.Close(); |
| 171 return false; | 178 return false; |
| (...skipping 664 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 836 | 843 |
| 837 bool LoginDatabase::DeleteAndRecreateDatabaseFile() { | 844 bool LoginDatabase::DeleteAndRecreateDatabaseFile() { |
| 838 DCHECK(db_.is_open()); | 845 DCHECK(db_.is_open()); |
| 839 meta_table_.Reset(); | 846 meta_table_.Reset(); |
| 840 db_.Close(); | 847 db_.Close(); |
| 841 sql::Connection::Delete(db_path_); | 848 sql::Connection::Delete(db_path_); |
| 842 return Init(db_path_); | 849 return Init(db_path_); |
| 843 } | 850 } |
| 844 | 851 |
| 845 } // namespace password_manager | 852 } // namespace password_manager |
| OLD | NEW |