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 "components/history/core/browser/visit_database.h" | 5 #include "components/history/core/browser/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 581 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
592 if (!GetDB().DoesColumnExist("visits", "visit_duration")) { | 592 if (!GetDB().DoesColumnExist("visits", "visit_duration")) { |
593 // Old versions don't have the visit_duration column, we modify the table | 593 // Old versions don't have the visit_duration column, we modify the table |
594 // to add that field. | 594 // to add that field. |
595 if (!GetDB().Execute("ALTER TABLE visits " | 595 if (!GetDB().Execute("ALTER TABLE visits " |
596 "ADD COLUMN visit_duration INTEGER DEFAULT 0 NOT NULL")) | 596 "ADD COLUMN visit_duration INTEGER DEFAULT 0 NOT NULL")) |
597 return false; | 597 return false; |
598 } | 598 } |
599 return true; | 599 return true; |
600 } | 600 } |
601 | 601 |
602 void VisitDatabase::GetBriefVisitInfoOfMostRecentVisits( | |
603 int max_visits, | |
604 std::vector<BriefVisitInfo>* result_vector) { | |
605 result_vector->clear(); | |
606 | |
607 sql::Statement statement(GetDB().GetUniqueStatement( | |
608 "SELECT url,visit_time,transition FROM visits " | |
609 "ORDER BY id DESC LIMIT ?")); | |
610 | |
611 statement.BindInt64(0, max_visits); | |
612 | |
613 if (!statement.is_valid()) | |
614 return; | |
615 | |
616 while (statement.Step()) { | |
617 BriefVisitInfo info; | |
618 info.url_id = statement.ColumnInt64(0); | |
619 info.time = base::Time::FromInternalValue(statement.ColumnInt64(1)); | |
620 info.transition = ui::PageTransitionFromInt(statement.ColumnInt(2)); | |
621 result_vector->push_back(info); | |
622 } | |
623 } | |
624 | |
625 } // namespace history | 602 } // namespace history |
OLD | NEW |