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

Side by Side Diff: chrome/browser/browsing_data/downloads_counter.cc

Issue 2153863002: Move counters for passwords, history and autofill to components (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@separate_build_targets_in_components_bd
Patch Set: Fixed dependencies Created 4 years, 5 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
1 // Copyright 2016 The Chromium Authors. All rights reserved. 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 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/browsing_data/downloads_counter.h" 5 #include "chrome/browser/browsing_data/downloads_counter.h"
6 6
7 #include "chrome/browser/download/download_history.h" 7 #include "chrome/browser/download/download_history.h"
8 #include "chrome/browser/profiles/profile.h" 8 #include "chrome/browser/profiles/profile.h"
9 #include "components/browsing_data/core/pref_names.h" 9 #include "components/browsing_data/core/pref_names.h"
10 #include "content/public/browser/download_manager.h" 10 #include "content/public/browser/download_manager.h"
11 11
12 DownloadsCounter::DownloadsCounter(Profile* profile) 12 DownloadsCounter::DownloadsCounter(Profile* profile)
13 : BrowsingDataCounter(browsing_data::prefs::kDeleteDownloadHistory), 13 : pref_name_(browsing_data::prefs::kDeleteDownloadHistory),
14 profile_(profile) {} 14 profile_(profile) {}
15 15
16 DownloadsCounter::~DownloadsCounter() { 16 DownloadsCounter::~DownloadsCounter() {
17 } 17 }
18 18
19 const std::string& DownloadsCounter::GetPrefName() const {
20 return pref_name_;
21 }
22
19 void DownloadsCounter::Count() { 23 void DownloadsCounter::Count() {
20 content::DownloadManager* download_manager = 24 content::DownloadManager* download_manager =
21 content::BrowserContext::GetDownloadManager(profile_); 25 content::BrowserContext::GetDownloadManager(profile_);
22 std::vector<content::DownloadItem*> downloads; 26 std::vector<content::DownloadItem*> downloads;
23 download_manager->GetAllDownloads(&downloads); 27 download_manager->GetAllDownloads(&downloads);
24 base::Time begin_time = GetPeriodStart(); 28 base::Time begin_time = GetPeriodStart();
25 29
26 ReportResult(std::count_if( 30 ReportResult(std::count_if(
27 downloads.begin(), 31 downloads.begin(),
28 downloads.end(), 32 downloads.end(),
29 [begin_time](const content::DownloadItem* item) { 33 [begin_time](const content::DownloadItem* item) {
30 return item->GetStartTime() >= begin_time && 34 return item->GetStartTime() >= begin_time &&
31 DownloadHistory::IsPersisted(item); 35 DownloadHistory::IsPersisted(item);
32 })); 36 }));
33 } 37 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698