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

Side by Side Diff: components/webdata/common/web_database.cc

Issue 2946373002: Add log in version 73
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
« no previous file with comments | « components/autofill/core/browser/webdata/autofill_table.cc ('k') | 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 (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 "components/webdata/common/web_database.h" 5 #include "components/webdata/common/web_database.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 8
9 #include "base/stl_util.h" 9 #include "base/stl_util.h"
10 #include "sql/transaction.h" 10 #include "sql/transaction.h"
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after
68 std::string WebDatabase::GetDiagnosticInfo(int extended_error, 68 std::string WebDatabase::GetDiagnosticInfo(int extended_error,
69 sql::Statement* statement) { 69 sql::Statement* statement) {
70 return db_.GetDiagnosticInfo(extended_error, statement); 70 return db_.GetDiagnosticInfo(extended_error, statement);
71 } 71 }
72 72
73 sql::Connection* WebDatabase::GetSQLConnection() { 73 sql::Connection* WebDatabase::GetSQLConnection() {
74 return &db_; 74 return &db_;
75 } 75 }
76 76
77 sql::InitStatus WebDatabase::Init(const base::FilePath& db_name) { 77 sql::InitStatus WebDatabase::Init(const base::FilePath& db_name) {
78
79 LOG(WARNING) << "3fengLog: in init";
78 db_.set_histogram_tag("Web"); 80 db_.set_histogram_tag("Web");
79 81
80 // We don't store that much data in the tables so use a small page size. 82 // We don't store that much data in the tables so use a small page size.
81 // This provides a large benefit for empty tables (which is very likely with 83 // This provides a large benefit for empty tables (which is very likely with
82 // the tables we create). 84 // the tables we create).
83 db_.set_page_size(2048); 85 db_.set_page_size(2048);
84 86
85 // We shouldn't have much data and what access we currently have is quite 87 // We shouldn't have much data and what access we currently have is quite
86 // infrequent. So we go with a small cache size. 88 // infrequent. So we go with a small cache size.
87 db_.set_cache_size(32); 89 db_.set_cache_size(32);
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after
142 // Some malware used to lower the version number, causing migration to 144 // Some malware used to lower the version number, causing migration to
143 // fail. Ensure the version number is at least as high as the compatible 145 // fail. Ensure the version number is at least as high as the compatible
144 // version number. 146 // version number.
145 int current_version = std::max(meta_table_.GetVersionNumber(), 147 int current_version = std::max(meta_table_.GetVersionNumber(),
146 meta_table_.GetCompatibleVersionNumber()); 148 meta_table_.GetCompatibleVersionNumber());
147 if (current_version > meta_table_.GetVersionNumber()) 149 if (current_version > meta_table_.GetVersionNumber())
148 ChangeVersion(&meta_table_, current_version, false); 150 ChangeVersion(&meta_table_, current_version, false);
149 151
150 DCHECK_GT(current_version, kDeprecatedVersionNumber); 152 DCHECK_GT(current_version, kDeprecatedVersionNumber);
151 153
154 LOG(WARNING) << "3fengLog: current_version:" <<current_version;
152 for (int next_version = current_version + 1; 155 for (int next_version = current_version + 1;
153 next_version <= kCurrentVersionNumber; 156 next_version <= kCurrentVersionNumber;
154 ++next_version) { 157 ++next_version) {
155 // Do any database-wide migrations. 158 // Do any database-wide migrations.
156 bool update_compatible_version = false; 159 bool update_compatible_version = false;
157 if (!MigrateToVersion(next_version, &update_compatible_version)) 160 if (!MigrateToVersion(next_version, &update_compatible_version))
158 return FailedMigrationTo(next_version); 161 return FailedMigrationTo(next_version);
159 162
160 ChangeVersion(&meta_table_, next_version, update_compatible_version); 163 ChangeVersion(&meta_table_, next_version, update_compatible_version);
161 164
162 // Give each table a chance to migrate to this version. 165 // Give each table a chance to migrate to this version.
163 for (TableMap::iterator it = tables_.begin(); it != tables_.end(); ++it) { 166 for (TableMap::iterator it = tables_.begin(); it != tables_.end(); ++it) {
164 // Any of the tables may set this to true, but by default it is false. 167 // Any of the tables may set this to true, but by default it is false.
165 update_compatible_version = false; 168 update_compatible_version = false;
166 if (!it->second->MigrateToVersion(next_version, 169 if (!it->second->MigrateToVersion(next_version,
167 &update_compatible_version)) { 170 &update_compatible_version)) {
168 return FailedMigrationTo(next_version); 171 return FailedMigrationTo(next_version);
169 } 172 }
170 173
171 ChangeVersion(&meta_table_, next_version, update_compatible_version); 174 ChangeVersion(&meta_table_, next_version, update_compatible_version);
172 } 175 }
173 } 176 }
177 LOG(WARNING) << "3fengLog: latest version:" <<kCurrentVersionNumber;
174 return sql::INIT_OK; 178 return sql::INIT_OK;
175 } 179 }
176 180
177 bool WebDatabase::MigrateToVersion(int version, 181 bool WebDatabase::MigrateToVersion(int version,
178 bool* update_compatible_version) { 182 bool* update_compatible_version) {
179 // Migrate if necessary. 183 // Migrate if necessary.
180 switch (version) { 184 switch (version) {
181 case 58: 185 case 58:
182 *update_compatible_version = true; 186 *update_compatible_version = true;
183 return MigrateToVersion58DropWebAppsAndIntents(); 187 return MigrateToVersion58DropWebAppsAndIntents();
184 } 188 }
185 189
186 return true; 190 return true;
187 } 191 }
188 192
189 bool WebDatabase::MigrateToVersion58DropWebAppsAndIntents() { 193 bool WebDatabase::MigrateToVersion58DropWebAppsAndIntents() {
190 sql::Transaction transaction(&db_); 194 sql::Transaction transaction(&db_);
191 return transaction.Begin() && 195 return transaction.Begin() &&
192 db_.Execute("DROP TABLE IF EXISTS web_apps") && 196 db_.Execute("DROP TABLE IF EXISTS web_apps") &&
193 db_.Execute("DROP TABLE IF EXISTS web_app_icons") && 197 db_.Execute("DROP TABLE IF EXISTS web_app_icons") &&
194 db_.Execute("DROP TABLE IF EXISTS web_intents") && 198 db_.Execute("DROP TABLE IF EXISTS web_intents") &&
195 db_.Execute("DROP TABLE IF EXISTS web_intents_defaults") && 199 db_.Execute("DROP TABLE IF EXISTS web_intents_defaults") &&
196 transaction.Commit(); 200 transaction.Commit();
197 } 201 }
OLDNEW
« no previous file with comments | « components/autofill/core/browser/webdata/autofill_table.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698