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

Side by Side Diff: components/password_manager/core/browser/login_database.cc

Issue 663813003: [Password Manager] Update SQL database version in response to rollback (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git/+/master
Patch Set: Created 6 years, 2 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
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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/strings/string_util.h" 15 #include "base/strings/string_util.h"
16 #include "base/time/time.h" 16 #include "base/time/time.h"
17 #include "components/autofill/core/common/password_form.h" 17 #include "components/autofill/core/common/password_form.h"
18 #include "google_apis/gaia/gaia_auth_util.h" 18 #include "google_apis/gaia/gaia_auth_util.h"
19 #include "google_apis/gaia/gaia_urls.h" 19 #include "google_apis/gaia/gaia_urls.h"
20 #include "sql/connection.h" 20 #include "sql/connection.h"
21 #include "sql/statement.h" 21 #include "sql/statement.h"
22 #include "sql/transaction.h" 22 #include "sql/transaction.h"
23 23
24 using autofill::PasswordForm; 24 using autofill::PasswordForm;
25 25
26 namespace password_manager { 26 namespace password_manager {
27 27
28 static const int kCurrentVersionNumber = 7; 28 static const int kCurrentVersionNumber = 8;
29 static const int kCompatibleVersionNumber = 1; 29 static const int kCompatibleVersionNumber = 1;
30 30
31 Pickle SerializeVector(const std::vector<base::string16>& vec) { 31 Pickle SerializeVector(const std::vector<base::string16>& vec) {
32 Pickle p; 32 Pickle p;
33 for (size_t i = 0; i < vec.size(); ++i) { 33 for (size_t i = 0; i < vec.size(); ++i) {
34 p.WriteString16(vec[i]); 34 p.WriteString16(vec[i]);
35 } 35 }
36 return p; 36 return p;
37 } 37 }
38 38
(...skipping 178 matching lines...) Expand 10 before | Expand all | Expand 10 after
217 case 6: 217 case 6:
218 if (!db_.Execute("ALTER TABLE logins ADD COLUMN display_name VARCHAR") || 218 if (!db_.Execute("ALTER TABLE logins ADD COLUMN display_name VARCHAR") ||
219 !db_.Execute("ALTER TABLE logins ADD COLUMN avatar_url VARCHAR") || 219 !db_.Execute("ALTER TABLE logins ADD COLUMN avatar_url VARCHAR") ||
220 !db_.Execute("ALTER TABLE logins " 220 !db_.Execute("ALTER TABLE logins "
221 "ADD COLUMN federation_url VARCHAR") || 221 "ADD COLUMN federation_url VARCHAR") ||
222 !db_.Execute("ALTER TABLE logins ADD COLUMN is_zero_click INTEGER")) { 222 !db_.Execute("ALTER TABLE logins ADD COLUMN is_zero_click INTEGER")) {
223 return false; 223 return false;
224 } 224 }
225 meta_table_.SetVersionNumber(7); 225 meta_table_.SetVersionNumber(7);
226 // Fall through. 226 // Fall through.
227 case 7:
228 // Keep version 8 around even though no changes are made. See
229 // crbug.com/423716 for context.
230 meta_table_.SetVersionNumber(8);
231 // Fall through.
227 // TODO(gcasto): Remove use_additional_auth by copying table. 232 // TODO(gcasto): Remove use_additional_auth by copying table.
228 // https://www.sqlite.org/lang_altertable.html 233 // https://www.sqlite.org/lang_altertable.html
229 case kCurrentVersionNumber: 234 case kCurrentVersionNumber:
230 // Already up to date 235 // Already up to date
231 return true; 236 return true;
232 default: 237 default:
233 NOTREACHED(); 238 NOTREACHED();
234 return false; 239 return false;
235 } 240 }
236 } 241 }
(...skipping 522 matching lines...) Expand 10 before | Expand all | Expand 10 after
759 764
760 bool LoginDatabase::DeleteAndRecreateDatabaseFile() { 765 bool LoginDatabase::DeleteAndRecreateDatabaseFile() {
761 DCHECK(db_.is_open()); 766 DCHECK(db_.is_open());
762 meta_table_.Reset(); 767 meta_table_.Reset();
763 db_.Close(); 768 db_.Close();
764 sql::Connection::Delete(db_path_); 769 sql::Connection::Delete(db_path_);
765 return Init(db_path_); 770 return Init(db_path_);
766 } 771 }
767 772
768 } // namespace password_manager 773 } // namespace password_manager
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698