Chromium Code Reviews| 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/history_database.h" | 5 #include "components/history/core/browser/history_database.h" |
| 6 | 6 |
| 7 #include <stdint.h> | 7 #include <stdint.h> |
| 8 | 8 |
| 9 #include <algorithm> | 9 #include <algorithm> |
| 10 #include <set> | 10 #include <set> |
| (...skipping 175 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 186 UMA_HISTOGRAM_COUNTS_10000("History.WeeklyHostCount", | 186 UMA_HISTOGRAM_COUNTS_10000("History.WeeklyHostCount", |
| 187 static_cast<int>(week_hosts.size())); | 187 static_cast<int>(week_hosts.size())); |
| 188 UMA_HISTOGRAM_COUNTS("History.MonthlyURLCount", month_url_count); | 188 UMA_HISTOGRAM_COUNTS("History.MonthlyURLCount", month_url_count); |
| 189 UMA_HISTOGRAM_COUNTS_10000("History.MonthlyHostCount", | 189 UMA_HISTOGRAM_COUNTS_10000("History.MonthlyHostCount", |
| 190 static_cast<int>(month_hosts.size())); | 190 static_cast<int>(month_hosts.size())); |
| 191 UMA_HISTOGRAM_TIMES("History.DatabaseAdvancedMetricsTime", | 191 UMA_HISTOGRAM_TIMES("History.DatabaseAdvancedMetricsTime", |
| 192 base::TimeTicks::Now() - start_time); | 192 base::TimeTicks::Now() - start_time); |
| 193 } | 193 } |
| 194 } | 194 } |
| 195 | 195 |
| 196 TopHostsList HistoryDatabase::TopHosts(size_t num_hosts) { | 196 TopHostsList HistoryDatabase::TopHosts(size_t num_hosts) { |
|
sky
2016/08/31 16:29:47
I'm not familiar with this function. I believe you
| |
| 197 base::Time one_month_ago = | 197 base::Time one_month_ago = |
| 198 std::max(base::Time::Now() - base::TimeDelta::FromDays(30), base::Time()); | 198 std::max(base::Time::Now() - base::TimeDelta::FromDays(30), base::Time()); |
| 199 | 199 |
| 200 sql::Statement url_sql(db_.GetUniqueStatement( | 200 sql::Statement url_sql(db_.GetUniqueStatement( |
| 201 "SELECT url, visit_count FROM urls WHERE last_visit_time > ?")); | 201 "SELECT u.url, u.visit_count " |
| 202 "FROM urls u JOIN visits v ON u.id = v.url " | |
| 203 "WHERE last_visit_time > ? " | |
| 204 "AND (v.transition & ?) != 0 " // CHAIN_END | |
| 205 "AND (transition & ?) NOT IN (?, ?, ?)")); // NO SUBFRAME or | |
| 206 // KEYWORD_GENERATED | |
| 207 | |
| 202 url_sql.BindInt64(0, one_month_ago.ToInternalValue()); | 208 url_sql.BindInt64(0, one_month_ago.ToInternalValue()); |
| 209 url_sql.BindInt(1, ui::PAGE_TRANSITION_CHAIN_END); | |
| 210 url_sql.BindInt(2, ui::PAGE_TRANSITION_CORE_MASK); | |
| 211 url_sql.BindInt(3, ui::PAGE_TRANSITION_AUTO_SUBFRAME); | |
| 212 url_sql.BindInt(4, ui::PAGE_TRANSITION_MANUAL_SUBFRAME); | |
| 213 url_sql.BindInt(5, ui::PAGE_TRANSITION_KEYWORD_GENERATED); | |
| 203 | 214 |
| 204 // Collect a map from host to visit count. | 215 // Collect a map from host to visit count. |
| 205 base::hash_map<std::string, int> host_count; | 216 base::hash_map<std::string, int> host_count; |
| 206 while (url_sql.Step()) { | 217 while (url_sql.Step()) { |
| 207 GURL url(url_sql.ColumnString(0)); | 218 GURL url(url_sql.ColumnString(0)); |
| 208 if (!(url.is_valid() && (url.SchemeIsHTTPOrHTTPS() || url.SchemeIs("ftp")))) | 219 if (!(url.is_valid() && (url.SchemeIsHTTPOrHTTPS() || url.SchemeIs("ftp")))) |
| 209 continue; | 220 continue; |
| 210 | 221 |
| 211 int64_t visit_count = url_sql.ColumnInt64(1); | 222 int64_t visit_count = url_sql.ColumnInt64(1); |
| 212 host_count[HostForTopHosts(url)] += visit_count; | 223 host_count[HostForTopHosts(url)] += visit_count; |
| (...skipping 332 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 545 "SET visit_time = visit_time + 11644473600000000 " | 556 "SET visit_time = visit_time + 11644473600000000 " |
| 546 "WHERE id IN (SELECT id FROM visits WHERE visit_time > 0);")); | 557 "WHERE id IN (SELECT id FROM visits WHERE visit_time > 0);")); |
| 547 ignore_result(db_.Execute( | 558 ignore_result(db_.Execute( |
| 548 "UPDATE segment_usage " | 559 "UPDATE segment_usage " |
| 549 "SET time_slot = time_slot + 11644473600000000 " | 560 "SET time_slot = time_slot + 11644473600000000 " |
| 550 "WHERE id IN (SELECT id FROM segment_usage WHERE time_slot > 0);")); | 561 "WHERE id IN (SELECT id FROM segment_usage WHERE time_slot > 0);")); |
| 551 } | 562 } |
| 552 #endif | 563 #endif |
| 553 | 564 |
| 554 } // namespace history | 565 } // namespace history |
| OLD | NEW |