Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(18)

Side by Side Diff: chrome/browser/history/history_database.cc

Issue 12252002: Fix the History.WeeklyVisitCount and History.MonthlyVisitCount data collection. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: Created 7 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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/history_database.h" 5 #include "chrome/browser/history/history_database.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 #include <set> 8 #include <set>
9 #include <string> 9 #include <string>
10 10
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after
55 sql::Statement visit_count(db.GetUniqueStatement( 55 sql::Statement visit_count(db.GetUniqueStatement(
56 "SELECT count(*) FROM visits")); 56 "SELECT count(*) FROM visits"));
57 if (!visit_count.Step()) 57 if (!visit_count.Step())
58 return; 58 return;
59 UMA_HISTOGRAM_COUNTS("History.VisitTableCount", visit_count.ColumnInt(0)); 59 UMA_HISTOGRAM_COUNTS("History.VisitTableCount", visit_count.ColumnInt(0));
60 60
61 base::Time one_week_ago = base::Time::Now() - base::TimeDelta::FromDays(7); 61 base::Time one_week_ago = base::Time::Now() - base::TimeDelta::FromDays(7);
62 sql::Statement weekly_visit_sql(db.GetUniqueStatement( 62 sql::Statement weekly_visit_sql(db.GetUniqueStatement(
63 "SELECT count(*) FROM visits WHERE visit_time > ?")); 63 "SELECT count(*) FROM visits WHERE visit_time > ?"));
64 weekly_visit_sql.BindInt64(0, one_week_ago.ToInternalValue()); 64 weekly_visit_sql.BindInt64(0, one_week_ago.ToInternalValue());
65 int weekly_visit_count = weekly_visit_sql.ColumnInt(0); 65 int weekly_visit_count = 0;
66 if (weekly_visit_sql.Step())
67 weekly_visit_count = weekly_visit_sql.ColumnInt(0);
66 UMA_HISTOGRAM_COUNTS("History.WeeklyVisitCount", weekly_visit_count); 68 UMA_HISTOGRAM_COUNTS("History.WeeklyVisitCount", weekly_visit_count);
67 69
68 base::Time one_month_ago = base::Time::Now() - base::TimeDelta::FromDays(30); 70 base::Time one_month_ago = base::Time::Now() - base::TimeDelta::FromDays(30);
69 sql::Statement monthly_visit_sql(db.GetUniqueStatement( 71 sql::Statement monthly_visit_sql(db.GetUniqueStatement(
70 "SELECT count(*) FROM visits WHERE visit_time > ? AND visit_time <= ?")); 72 "SELECT count(*) FROM visits WHERE visit_time > ? AND visit_time <= ?"));
71 monthly_visit_sql.BindInt64(0, one_month_ago.ToInternalValue()); 73 monthly_visit_sql.BindInt64(0, one_month_ago.ToInternalValue());
72 monthly_visit_sql.BindInt64(1, one_week_ago.ToInternalValue()); 74 monthly_visit_sql.BindInt64(1, one_week_ago.ToInternalValue());
75 int older_visit_count = 0;
76 if (monthly_visit_sql.Step())
77 older_visit_count = monthly_visit_sql.ColumnInt(0);
73 UMA_HISTOGRAM_COUNTS("History.MonthlyVisitCount", 78 UMA_HISTOGRAM_COUNTS("History.MonthlyVisitCount",
74 monthly_visit_sql.ColumnInt(0) + weekly_visit_count); 79 older_visit_count + weekly_visit_count);
75 80
76 UMA_HISTOGRAM_TIMES("History.DatabaseBasicMetricsTime", 81 UMA_HISTOGRAM_TIMES("History.DatabaseBasicMetricsTime",
77 base::TimeTicks::Now() - start_time); 82 base::TimeTicks::Now() - start_time);
78 83
79 // Compute the advanced metrics even less often, pending timing data showing 84 // Compute the advanced metrics even less often, pending timing data showing
80 // that's not necessary. 85 // that's not necessary.
81 if (base::RandInt(1, 3) == 3) { 86 if (base::RandInt(1, 3) == 3) {
82 start_time = base::TimeTicks::Now(); 87 start_time = base::TimeTicks::Now();
83 88
84 // Collect all URLs visited within the last month. 89 // Collect all URLs visited within the last month.
(...skipping 351 matching lines...) Expand 10 before | Expand all | Expand 10 after
436 "WHERE id IN (SELECT id FROM segment_usage WHERE time_slot > 0);")); 441 "WHERE id IN (SELECT id FROM segment_usage WHERE time_slot > 0);"));
437 442
438 // Erase all the full text index files. These will take a while to update and 443 // Erase all the full text index files. These will take a while to update and
439 // are less important, so we just blow them away. Same with the archived 444 // are less important, so we just blow them away. Same with the archived
440 // database. 445 // database.
441 needs_version_17_migration_ = true; 446 needs_version_17_migration_ = true;
442 } 447 }
443 #endif 448 #endif
444 449
445 } // namespace history 450 } // namespace history
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698