| OLD | NEW |
| 1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 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 "components/browsing_data/core/counters/browsing_data_counter.h" | 5 #include "components/browsing_data/core/counters/browsing_data_counter.h" |
| 6 | 6 |
| 7 #include <utility> | 7 #include <utility> |
| 8 | 8 |
| 9 #include "base/memory/ptr_util.h" | 9 #include "base/memory/ptr_util.h" |
| 10 #include "components/browsing_data/core/browsing_data_utils.h" | 10 #include "components/browsing_data/core/browsing_data_utils.h" |
| (...skipping 22 matching lines...) Expand all Loading... |
| 33 } | 33 } |
| 34 | 34 |
| 35 void BrowsingDataCounter::OnInitialized() {} | 35 void BrowsingDataCounter::OnInitialized() {} |
| 36 | 36 |
| 37 base::Time BrowsingDataCounter::GetPeriodStart() { | 37 base::Time BrowsingDataCounter::GetPeriodStart() { |
| 38 return CalculateBeginDeleteTime(static_cast<TimePeriod>(*period_)); | 38 return CalculateBeginDeleteTime(static_cast<TimePeriod>(*period_)); |
| 39 } | 39 } |
| 40 | 40 |
| 41 void BrowsingDataCounter::Restart() { | 41 void BrowsingDataCounter::Restart() { |
| 42 DCHECK(initialized_); | 42 DCHECK(initialized_); |
| 43 | |
| 44 // If this data type was unchecked for deletion, we do not need to count it. | |
| 45 if (!pref_service_->GetBoolean(GetPrefName())) | |
| 46 return; | |
| 47 | |
| 48 callback_.Run(base::MakeUnique<Result>(this)); | 43 callback_.Run(base::MakeUnique<Result>(this)); |
| 49 | |
| 50 Count(); | 44 Count(); |
| 51 } | 45 } |
| 52 | 46 |
| 53 void BrowsingDataCounter::ReportResult(ResultInt value) { | 47 void BrowsingDataCounter::ReportResult(ResultInt value) { |
| 54 DCHECK(initialized_); | 48 DCHECK(initialized_); |
| 55 callback_.Run(base::MakeUnique<FinishedResult>(this, value)); | 49 callback_.Run(base::MakeUnique<FinishedResult>(this, value)); |
| 56 } | 50 } |
| 57 | 51 |
| 58 void BrowsingDataCounter::ReportResult(std::unique_ptr<Result> result) { | 52 void BrowsingDataCounter::ReportResult(std::unique_ptr<Result> result) { |
| 59 DCHECK(initialized_); | 53 DCHECK(initialized_); |
| (...skipping 27 matching lines...) Expand all Loading... |
| 87 bool BrowsingDataCounter::FinishedResult::Finished() const { | 81 bool BrowsingDataCounter::FinishedResult::Finished() const { |
| 88 return true; | 82 return true; |
| 89 } | 83 } |
| 90 | 84 |
| 91 BrowsingDataCounter::ResultInt BrowsingDataCounter::FinishedResult::Value() | 85 BrowsingDataCounter::ResultInt BrowsingDataCounter::FinishedResult::Value() |
| 92 const { | 86 const { |
| 93 return value_; | 87 return value_; |
| 94 } | 88 } |
| 95 | 89 |
| 96 } // namespace browsing_data | 90 } // namespace browsing_data |
| OLD | NEW |