Chromium Code Reviews| 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 Result(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(const BrowsingDataCounter* source) | |
| 74 : source_(source) { | |
| 75 } | |
| 76 | |
| 77 BrowsingDataCounter::Result::~Result() { | |
| 78 } | |
| 79 | |
| 80 bool BrowsingDataCounter::Result::finished() const { | |
| 81 return false; | |
| 82 } | |
| 83 | |
| 84 const BrowsingDataCounter::ResultInt | |
| 85 BrowsingDataCounter::Result::value() const { | |
| 86 return 0; | |
|
Bernhard Bauer
2015/11/03 10:11:19
You could add a NOTREACHED(), or -- depending on h
msramek
2015/11/03 10:55:45
Yes, I wanted to move it to the subclass (if you l
| |
| 87 } | |
| 88 | |
| 89 // BrowsingDataCounter::FinishedResult ----------------------------------------- | |
| 90 | |
| 91 BrowsingDataCounter::FinishedResult::FinishedResult( | |
| 92 const BrowsingDataCounter* source, ResultInt value) | |
| 93 : Result(source), | |
| 94 value_(value) { | |
| 95 } | |
| 96 | |
| 97 BrowsingDataCounter::FinishedResult::~FinishedResult() { | |
| 98 } | |
| 99 | |
| 100 bool BrowsingDataCounter::FinishedResult::finished() const { | |
| 101 return true; | |
| 102 } | |
| 103 | |
| 104 const BrowsingDataCounter::ResultInt | |
| 105 BrowsingDataCounter::FinishedResult::value() const { | |
| 106 return value_; | |
| 107 } | |
| OLD | NEW |