| 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 // BrowsingDataCounter::FinishedResult ----------------------------------------- | 
|  | 85 | 
|  | 86 BrowsingDataCounter::FinishedResult::FinishedResult( | 
|  | 87     const BrowsingDataCounter* source, ResultInt value) | 
|  | 88     : Result(source), | 
|  | 89       value_(value) { | 
|  | 90 } | 
|  | 91 | 
|  | 92 BrowsingDataCounter::FinishedResult::~FinishedResult() { | 
|  | 93 } | 
|  | 94 | 
|  | 95 bool BrowsingDataCounter::FinishedResult::Finished() const { | 
|  | 96   return true; | 
|  | 97 } | 
|  | 98 | 
|  | 99 BrowsingDataCounter::ResultInt | 
|  | 100     BrowsingDataCounter::FinishedResult::Value() const { | 
|  | 101   return value_; | 
|  | 102 } | 
| OLD | NEW | 
|---|