| OLD | NEW |
| 1 // Copyright (c) 2015 The Chromium Authors. All rights reserved. | 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 | 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/browsing_data_counter.h" | 5 #include "chrome/browser/browsing_data/browsing_data_counter.h" |
| 6 | 6 |
| 7 #include "base/prefs/pref_service.h" | 7 #include "base/prefs/pref_service.h" |
| 8 #include "chrome/browser/profiles/profile.h" | 8 #include "chrome/browser/profiles/profile.h" |
| 9 #include "chrome/common/pref_names.h" | 9 #include "chrome/common/pref_names.h" |
| 10 | 10 |
| (...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 46 static_cast<BrowsingDataRemover::TimePeriod>(*period_)); | 46 static_cast<BrowsingDataRemover::TimePeriod>(*period_)); |
| 47 } | 47 } |
| 48 | 48 |
| 49 void BrowsingDataCounter::Restart() { | 49 void BrowsingDataCounter::Restart() { |
| 50 DCHECK(initialized_); | 50 DCHECK(initialized_); |
| 51 | 51 |
| 52 // If this data type was unchecked for deletion, we do not need to count it. | 52 // If this data type was unchecked for deletion, we do not need to count it. |
| 53 if (!profile_->GetPrefs()->GetBoolean(GetPrefName())) | 53 if (!profile_->GetPrefs()->GetBoolean(GetPrefName())) |
| 54 return; | 54 return; |
| 55 | 55 |
| 56 callback_.Run(false, 0u); | 56 callback_.Run(make_scoped_ptr(new PendingResult(this))); |
| 57 | 57 |
| 58 Count(); | 58 Count(); |
| 59 } | 59 } |
| 60 | 60 |
| 61 void BrowsingDataCounter::ReportResult(ResultInt value) { | 61 void BrowsingDataCounter::ReportResult(ResultInt value) { |
| 62 DCHECK(initialized_); | 62 DCHECK(initialized_); |
| 63 callback_.Run(true, value); | 63 callback_.Run(make_scoped_ptr(new FinishedResult(this, value))); |
| 64 } | 64 } |
| 65 |
| 66 void BrowsingDataCounter::ReportResult(scoped_ptr<Result> result) { |
| 67 DCHECK(initialized_); |
| 68 callback_.Run(result.Pass()); |
| 69 } |
| 70 |
| 71 // BrowsingDataCounter::Result ------------------------------------------------- |
| 72 |
| 73 BrowsingDataCounter::Result::Result( |
| 74 const BrowsingDataCounter* source, |
| 75 bool finished, |
| 76 ResultInt value) |
| 77 : source_(source), |
| 78 finished_(finished), |
| 79 value_(value) { |
| 80 } |
| 81 |
| 82 BrowsingDataCounter::Result::~Result() { |
| 83 } |
| 84 |
| 85 // BrowsingDataCounter::FinishedResult ----------------------------------------- |
| 86 |
| 87 BrowsingDataCounter::FinishedResult::FinishedResult( |
| 88 const BrowsingDataCounter* source, ResultInt value) |
| 89 : Result(source, true, value) { |
| 90 } |
| 91 |
| 92 BrowsingDataCounter::FinishedResult::~FinishedResult() { |
| 93 } |
| 94 |
| 95 // BrowsingDataCounter::PendingResult ------------------------------------------ |
| 96 |
| 97 BrowsingDataCounter::PendingResult::PendingResult( |
| 98 const BrowsingDataCounter* source) |
| 99 : Result(source, false, 0) { |
| 100 } |
| 101 |
| 102 BrowsingDataCounter::PendingResult::~PendingResult() { |
| 103 } |
| OLD | NEW |