Update broken references to image assets
[chromium-blink-merge.git] / chrome / browser / browsing_data / browsing_data_counter.cc
blob7d07707efa7744455f5df8a1fe7ea9e3946a205a
1 // Copyright (c) 2015 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.
5 #include "chrome/browser/browsing_data/browsing_data_counter.h"
7 #include "base/prefs/pref_service.h"
8 #include "chrome/browser/profiles/profile.h"
10 BrowsingDataCounter::BrowsingDataCounter() {}
12 BrowsingDataCounter::~BrowsingDataCounter() {
15 void BrowsingDataCounter::Init(
16 Profile* profile,
17 const Callback& callback) {
18 DCHECK(!initialized_);
19 profile_ = profile;
20 callback_ = callback;
21 pref_.Init(
22 GetPrefName(),
23 profile_->GetPrefs(),
24 base::Bind(&BrowsingDataCounter::RestartCounting,
25 base::Unretained(this)));
27 initialized_ = true;
28 OnInitialized();
29 RestartCounting();
32 Profile* BrowsingDataCounter::GetProfile() const {
33 return profile_;
36 void BrowsingDataCounter::OnInitialized() {
39 void BrowsingDataCounter::RestartCounting() {
40 DCHECK(initialized_);
42 // If this data type was unchecked for deletion, we do not need to count it.
43 if (!profile_->GetPrefs()->GetBoolean(GetPrefName()))
44 return;
46 // If counting is already in progress, do not restart it.
47 if (counting_)
48 return;
50 callback_.Run(false, 0u);
52 counting_ = true;
53 Count();
56 void BrowsingDataCounter::ReportResult(uint32 value) {
57 DCHECK(initialized_);
58 DCHECK(counting_);
59 counting_ = false;
60 callback_.Run(true, value);