OLD | NEW |
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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 "chrome/browser/history/shortcuts_database.h" | 5 #include "chrome/browser/history/shortcuts_database.h" |
6 | 6 |
7 #include <map> | 7 #include <map> |
8 #include <string> | 8 #include <string> |
9 #include <vector> | 9 #include <vector> |
10 | 10 |
(...skipping 150 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
161 db_.CommitTransaction(); | 161 db_.CommitTransaction(); |
162 return success; | 162 return success; |
163 } | 163 } |
164 | 164 |
165 bool ShortcutsDatabase::DeleteShortcutsWithUrl( | 165 bool ShortcutsDatabase::DeleteShortcutsWithUrl( |
166 const std::string& shortcut_url_spec) { | 166 const std::string& shortcut_url_spec) { |
167 return DeleteShortcut("url", shortcut_url_spec, db_); | 167 return DeleteShortcut("url", shortcut_url_spec, db_); |
168 } | 168 } |
169 | 169 |
170 bool ShortcutsDatabase::DeleteAllShortcuts() { | 170 bool ShortcutsDatabase::DeleteAllShortcuts() { |
171 sql::Statement s(db_.GetCachedStatement(SQL_FROM_HERE, | 171 if (!db_.Execute("DELETE FROM " kShortcutsDBName)) |
172 "DROP TABLE " kShortcutsDBName)); | |
173 if (!s) { | |
174 NOTREACHED() << "Statement prepare failed"; | |
175 return false; | 172 return false; |
176 } | |
177 | 173 |
178 if (!s.Run()) | 174 ignore_result(db_.Execute("VACUUM")); |
179 return false; | |
180 EnsureTable(); | |
181 db_.Execute("VACUUM"); | |
182 return true; | 175 return true; |
183 } | 176 } |
184 | 177 |
185 // Loads all of the shortcuts. | 178 // Loads all of the shortcuts. |
186 bool ShortcutsDatabase::LoadShortcuts( | 179 bool ShortcutsDatabase::LoadShortcuts( |
187 std::map<std::string, shortcuts_provider::Shortcut>* shortcuts) { | 180 std::map<std::string, shortcuts_provider::Shortcut>* shortcuts) { |
188 DCHECK(shortcuts); | 181 DCHECK(shortcuts); |
189 sql::Statement s(db_.GetCachedStatement(SQL_FROM_HERE, | 182 sql::Statement s(db_.GetCachedStatement(SQL_FROM_HERE, |
190 "SELECT id, text, url, contents, contents_class, " | 183 "SELECT id, text, url, contents, contents_class, " |
191 "description, description_class, last_access_time, number_of_hits " | 184 "description, description_class, last_access_time, number_of_hits " |
(...skipping 24 matching lines...) Expand all Loading... |
216 "last_access_time INTEGER, " | 209 "last_access_time INTEGER, " |
217 "number_of_hits INTEGER)", kShortcutsDBName).c_str())) { | 210 "number_of_hits INTEGER)", kShortcutsDBName).c_str())) { |
218 NOTREACHED(); | 211 NOTREACHED(); |
219 return false; | 212 return false; |
220 } | 213 } |
221 } | 214 } |
222 return true; | 215 return true; |
223 } | 216 } |
224 | 217 |
225 } // namespace history | 218 } // namespace history |
OLD | NEW |