OLD | NEW |
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 "chrome/browser/history/visit_database.h" | 5 #include "chrome/browser/history/visit_database.h" |
6 | 6 |
7 #include <algorithm> | 7 #include <algorithm> |
8 #include <limits> | 8 #include <limits> |
9 #include <map> | 9 #include <map> |
10 #include <set> | 10 #include <set> |
(...skipping 540 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
551 if (!GetDB().DoesColumnExist("visits", "visit_duration")) { | 551 if (!GetDB().DoesColumnExist("visits", "visit_duration")) { |
552 // Old versions don't have the visit_duration column, we modify the table | 552 // Old versions don't have the visit_duration column, we modify the table |
553 // to add that field. | 553 // to add that field. |
554 if (!GetDB().Execute("ALTER TABLE visits " | 554 if (!GetDB().Execute("ALTER TABLE visits " |
555 "ADD COLUMN visit_duration INTEGER DEFAULT 0 NOT NULL")) | 555 "ADD COLUMN visit_duration INTEGER DEFAULT 0 NOT NULL")) |
556 return false; | 556 return false; |
557 } | 557 } |
558 return true; | 558 return true; |
559 } | 559 } |
560 | 560 |
| 561 void VisitDatabase::GetBriefVisitInfoOfMostRecentVisits( |
| 562 int max_visits, |
| 563 std::vector<BriefVisitInfo>* result_vector) { |
| 564 result_vector->clear(); |
| 565 |
| 566 sql::Statement statement(GetDB().GetUniqueStatement( |
| 567 "SELECT url,visit_time,transition FROM visits " |
| 568 "ORDER BY id DESC LIMIT ?")); |
| 569 |
| 570 statement.BindInt64(0, max_visits); |
| 571 |
| 572 if (!statement.is_valid()) |
| 573 return; |
| 574 |
| 575 while (statement.Step()) { |
| 576 BriefVisitInfo info; |
| 577 info.url_id = statement.ColumnInt64(0); |
| 578 info.time = base::Time::FromInternalValue(statement.ColumnInt64(1)); |
| 579 info.transition = content::PageTransitionFromInt(statement.ColumnInt(2)); |
| 580 result_vector->push_back(info); |
| 581 } |
| 582 } |
| 583 |
561 } // namespace history | 584 } // namespace history |
OLD | NEW |