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

Side by Side Diff: chrome/browser/history/archived_database.cc

Issue 10669033: Close ArchivedDatabase connection after transaction rollback. (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: Created 8 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 | « chrome/browser/history/archived_database.h ('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 <algorithm> 5 #include <algorithm>
6 #include <string> 6 #include <string>
7 7
8 #include "base/string_util.h" 8 #include "base/string_util.h"
9 #include "chrome/browser/history/archived_database.h" 9 #include "chrome/browser/history/archived_database.h"
10 #include "sql/transaction.h" 10 #include "sql/transaction.h"
(...skipping 24 matching lines...) Expand all
35 // anything important. 35 // anything important.
36 db_.set_cache_size(64); 36 db_.set_cache_size(64);
37 37
38 // Run the database in exclusive mode. Nobody else should be accessing the 38 // Run the database in exclusive mode. Nobody else should be accessing the
39 // database while we're running, and this will give somewhat improved perf. 39 // database while we're running, and this will give somewhat improved perf.
40 db_.set_exclusive_locking(); 40 db_.set_exclusive_locking();
41 41
42 if (!db_.Open(file_name)) 42 if (!db_.Open(file_name))
43 return false; 43 return false;
44 44
45 sql::Transaction transaction(&db_); 45 if (!DoInitTransaction()) {
46 if (!transaction.Begin()) {
47 db_.Close(); 46 db_.Close();
48 return false; 47 return false;
49 } 48 }
50 49
50 return true;
51 }
52
53 bool ArchivedDatabase::DoInitTransaction() {
brettw 2012/06/27 17:12:22 This name confused me because I read it as initial
54 sql::Transaction transaction(&db_);
55 if (!transaction.Begin())
56 return false;
57
51 // Version check. 58 // Version check.
52 if (!meta_table_.Init(&db_, kCurrentVersionNumber, 59 if (!meta_table_.Init(&db_, kCurrentVersionNumber,
53 kCompatibleVersionNumber)) { 60 kCompatibleVersionNumber))
54 db_.Close();
55 return false; 61 return false;
56 }
57 62
58 // Create the tables. 63 // Create the tables.
59 if (!CreateURLTable(false) || !InitVisitTable() || 64 if (!CreateURLTable(false) || !InitVisitTable() ||
60 !InitKeywordSearchTermsTable()) { 65 !InitKeywordSearchTermsTable())
61 db_.Close();
62 return false; 66 return false;
63 } 67
64 CreateMainURLIndex(); 68 CreateMainURLIndex();
65 CreateKeywordSearchTermsIndices(); 69 CreateKeywordSearchTermsIndices();
66 70
67 if (EnsureCurrentVersion() != sql::INIT_OK) { 71 if (EnsureCurrentVersion() != sql::INIT_OK)
68 db_.Close();
69 return false; 72 return false;
70 }
71 73
72 return transaction.Commit(); 74 return transaction.Commit();
73 } 75 }
74 76
75 void ArchivedDatabase::BeginTransaction() { 77 void ArchivedDatabase::BeginTransaction() {
76 db_.BeginTransaction(); 78 db_.BeginTransaction();
77 } 79 }
78 80
79 void ArchivedDatabase::CommitTransaction() { 81 void ArchivedDatabase::CommitTransaction() {
80 db_.CommitTransaction(); 82 db_.CommitTransaction();
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after
136 // Put future migration cases here. 138 // Put future migration cases here.
137 139
138 // When the version is too old, we just try to continue anyway, there should 140 // When the version is too old, we just try to continue anyway, there should
139 // not be a released product that makes a database too old for us to handle. 141 // not be a released product that makes a database too old for us to handle.
140 LOG_IF(WARNING, cur_version < kCurrentVersionNumber) << 142 LOG_IF(WARNING, cur_version < kCurrentVersionNumber) <<
141 "Archived database version " << cur_version << " is too old to handle."; 143 "Archived database version " << cur_version << " is too old to handle.";
142 144
143 return sql::INIT_OK; 145 return sql::INIT_OK;
144 } 146 }
145 } // namespace history 147 } // namespace history
OLDNEW
« no previous file with comments | « chrome/browser/history/archived_database.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698