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 518 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
529 } | 529 } |
530 | 530 |
531 if (!statement.Succeeded()) | 531 if (!statement.Succeeded()) |
532 return false; | 532 return false; |
533 | 533 |
534 *first_visit = base::Time::FromInternalValue(statement.ColumnInt64(0)); | 534 *first_visit = base::Time::FromInternalValue(statement.ColumnInt64(0)); |
535 *count = statement.ColumnInt(1); | 535 *count = statement.ColumnInt(1); |
536 return true; | 536 return true; |
537 } | 537 } |
538 | 538 |
539 int VisitDatabase::GetCountOfURLsWithVisibleVisit() { | |
lwchkg
2015/08/11 15:54:51
Please discuss the naming of this function. It sho
lwchkg
2015/08/12 17:47:30
@sdefrense and @sky: Please check the code here. T
Mike Lerman
2015/08/13 14:56:33
I think GetCountHistoryEntries extends well to thi
| |
540 sql::Statement statement(GetDB().GetCachedStatement(SQL_FROM_HERE, | |
541 "SELECT COUNT(*) FROM (" | |
542 "SELECT DISTINCT url, " | |
543 // Convert unit of timestamp from the numbers of microseconds since | |
544 // Windows Epoch to the number of seconds from Unix Epoch. | |
545 "DATE(visit_time/1000000-11644473600, 'localtime', 'unixepoch') " | |
546 "FROM visits " | |
547 "WHERE (transition & ?) != 0 " // CHAIN_END | |
548 "AND (transition & ?) NOT IN (?, ?, ?)" // NO SUBFRAME or | |
549 // KEYWORD_GENERATED | |
550 ")")); | |
551 | |
552 statement.BindInt(0, ui::PAGE_TRANSITION_CHAIN_END); | |
553 statement.BindInt(1, ui::PAGE_TRANSITION_CORE_MASK); | |
554 statement.BindInt(2, ui::PAGE_TRANSITION_AUTO_SUBFRAME); | |
555 statement.BindInt(3, ui::PAGE_TRANSITION_MANUAL_SUBFRAME); | |
556 statement.BindInt(4, ui::PAGE_TRANSITION_KEYWORD_GENERATED); | |
557 | |
558 statement.Step(); | |
559 return statement.ColumnInt(0); | |
560 } | |
561 | |
539 bool VisitDatabase::GetStartDate(base::Time* first_visit) { | 562 bool VisitDatabase::GetStartDate(base::Time* first_visit) { |
540 sql::Statement statement(GetDB().GetCachedStatement(SQL_FROM_HERE, | 563 sql::Statement statement(GetDB().GetCachedStatement(SQL_FROM_HERE, |
541 "SELECT MIN(visit_time) FROM visits WHERE visit_time != 0")); | 564 "SELECT MIN(visit_time) FROM visits WHERE visit_time != 0")); |
542 if (!statement.Step() || statement.ColumnInt64(0) == 0) { | 565 if (!statement.Step() || statement.ColumnInt64(0) == 0) { |
543 *first_visit = base::Time::Now(); | 566 *first_visit = base::Time::Now(); |
544 return false; | 567 return false; |
545 } | 568 } |
546 *first_visit = base::Time::FromInternalValue(statement.ColumnInt64(0)); | 569 *first_visit = base::Time::FromInternalValue(statement.ColumnInt64(0)); |
547 return true; | 570 return true; |
548 } | 571 } |
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
593 // Old versions don't have the visit_duration column, we modify the table | 616 // Old versions don't have the visit_duration column, we modify the table |
594 // to add that field. | 617 // to add that field. |
595 if (!GetDB().Execute("ALTER TABLE visits " | 618 if (!GetDB().Execute("ALTER TABLE visits " |
596 "ADD COLUMN visit_duration INTEGER DEFAULT 0 NOT NULL")) | 619 "ADD COLUMN visit_duration INTEGER DEFAULT 0 NOT NULL")) |
597 return false; | 620 return false; |
598 } | 621 } |
599 return true; | 622 return true; |
600 } | 623 } |
601 | 624 |
602 } // namespace history | 625 } // namespace history |
OLD | NEW |