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 <limits> | 5 #include <limits> |
6 #include <set> | 6 #include <set> |
7 #include <string> | 7 #include <string> |
8 | 8 |
9 #include "chrome/browser/history/text_database.h" | 9 #include "chrome/browser/history/text_database.h" |
10 | 10 |
(...skipping 183 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
194 // full-text-search, which is not what we want when retrieving this data). | 194 // full-text-search, which is not what we want when retrieving this data). |
195 if (!db_.DoesTableExist("info")) { | 195 if (!db_.DoesTableExist("info")) { |
196 // Note that there is no point in creating an index over time. Since | 196 // Note that there is no point in creating an index over time. Since |
197 // we must always query the entire FTS table (it can not efficiently do | 197 // we must always query the entire FTS table (it can not efficiently do |
198 // subsets), we will always end up doing that first, and joining the info | 198 // subsets), we will always end up doing that first, and joining the info |
199 // table off of that. | 199 // table off of that. |
200 if (!db_.Execute("CREATE TABLE info(time INTEGER NOT NULL)")) | 200 if (!db_.Execute("CREATE TABLE info(time INTEGER NOT NULL)")) |
201 return false; | 201 return false; |
202 } | 202 } |
203 | 203 |
204 // Create the index. This will fail when the index already exists, so we just | 204 // Create the index. |
205 // ignore the error. | 205 return db_.Execute("CREATE INDEX IF NOT EXISTS info_time ON info(time)"); |
206 db_.Execute("CREATE INDEX info_time ON info(time)"); | |
207 return true; | |
208 } | 206 } |
209 | 207 |
210 bool TextDatabase::AddPageData(base::Time time, | 208 bool TextDatabase::AddPageData(base::Time time, |
211 const std::string& url, | 209 const std::string& url, |
212 const std::string& title, | 210 const std::string& title, |
213 const std::string& contents) { | 211 const std::string& contents) { |
214 sql::Transaction committer(&db_); | 212 sql::Transaction committer(&db_); |
215 if (!committer.Begin()) | 213 if (!committer.Begin()) |
216 return false; | 214 return false; |
217 | 215 |
(...skipping 162 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
380 } else { | 378 } else { |
381 // Since we got the results in order, we know the last item is the last | 379 // Since we got the results in order, we know the last item is the last |
382 // time we considered. | 380 // time we considered. |
383 *first_time_searched = results->back().time; | 381 *first_time_searched = results->back().time; |
384 } | 382 } |
385 | 383 |
386 statement.Reset(); | 384 statement.Reset(); |
387 } | 385 } |
388 | 386 |
389 } // namespace history | 387 } // namespace history |
OLD | NEW |