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

Side by Side Diff: components/browsing_data/browsing_data_utils.cc

Issue 2084903002: Moved BrowsingDataCounter and part of BrowsingDataCounterUtils to components. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fixed deps Created 4 years, 6 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
OLDNEW
(Empty)
1 // Copyright 2016 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4
5 #include "components/browsing_data/browsing_data_utils.h"
6 #include "content/public/browser/user_metrics.h"
7
8 using base::UserMetricsAction;
msramek 2016/06/21 14:43:56 This is typically discouraged. Please inline base:
ioanap 2016/06/23 14:56:27 Noted. I removed it completely, since the method t
9
10 TimeRange Unbounded() {
11 return TimeRange(base::Time(), base::Time::Max());
12 }
13
14 TimeRange Period(TimePeriod period) {
15 switch (period) {
16 case LAST_HOUR:
17 content::RecordAction(UserMetricsAction("ClearBrowsingData_LastHour"));
18 break;
19 case LAST_DAY:
20 content::RecordAction(UserMetricsAction("ClearBrowsingData_LastDay"));
21 break;
22 case LAST_WEEK:
23 content::RecordAction(UserMetricsAction("ClearBrowsingData_LastWeek"));
24 break;
25 case FOUR_WEEKS:
26 content::RecordAction(UserMetricsAction("ClearBrowsingData_LastMonth"));
27 break;
28 case EVERYTHING:
29 content::RecordAction(UserMetricsAction("ClearBrowsingData_Everything"));
30 break;
31 }
32 return TimeRange(CalculateBeginDeleteTime(period), base::Time::Max());
33 }
34
35 base::Time CalculateBeginDeleteTime(TimePeriod time_period) {
36 base::TimeDelta diff;
37 base::Time delete_begin_time = base::Time::Now();
38 switch (time_period) {
39 case LAST_HOUR:
40 diff = base::TimeDelta::FromHours(1);
41 break;
42 case LAST_DAY:
43 diff = base::TimeDelta::FromHours(24);
44 break;
45 case LAST_WEEK:
46 diff = base::TimeDelta::FromHours(7 * 24);
47 break;
48 case FOUR_WEEKS:
49 diff = base::TimeDelta::FromHours(4 * 7 * 24);
50 break;
51 case EVERYTHING:
52 delete_begin_time = base::Time();
53 break;
54 }
55 return delete_begin_time - diff;
56 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698