| 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 "components/browsing_data/core/counters/history_counter.h" | 5 #include "components/browsing_data/core/counters/history_counter.h" |
| 6 | 6 |
| 7 #include <limits.h> | 7 #include <limits.h> |
| 8 #include <stdint.h> | 8 #include <stdint.h> |
| 9 | 9 |
| 10 #include "base/memory/ptr_util.h" | 10 #include "base/memory/ptr_util.h" |
| (...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 48 const char* HistoryCounter::GetPrefName() const { | 48 const char* HistoryCounter::GetPrefName() const { |
| 49 return GetTab() == ClearBrowsingDataTab::BASIC | 49 return GetTab() == ClearBrowsingDataTab::BASIC |
| 50 ? browsing_data::prefs::kDeleteBrowsingHistoryBasic | 50 ? browsing_data::prefs::kDeleteBrowsingHistoryBasic |
| 51 : browsing_data::prefs::kDeleteBrowsingHistory; | 51 : browsing_data::prefs::kDeleteBrowsingHistory; |
| 52 } | 52 } |
| 53 | 53 |
| 54 void HistoryCounter::Count() { | 54 void HistoryCounter::Count() { |
| 55 // Reset the state. | 55 // Reset the state. |
| 56 cancelable_task_tracker_.TryCancelAll(); | 56 cancelable_task_tracker_.TryCancelAll(); |
| 57 web_history_request_.reset(); | 57 web_history_request_.reset(); |
| 58 weak_ptr_factory_.InvalidateWeakPtrs(); |
| 59 |
| 58 has_synced_visits_ = false; | 60 has_synced_visits_ = false; |
| 59 | 61 |
| 60 // Count the locally stored items. | 62 // Count the locally stored items. |
| 61 local_counting_finished_ = false; | 63 local_counting_finished_ = false; |
| 62 | 64 |
| 63 history_service_->GetHistoryCount( | 65 history_service_->GetHistoryCount( |
| 64 GetPeriodStart(), base::Time::Max(), | 66 GetPeriodStart(), base::Time::Max(), |
| 65 base::Bind(&HistoryCounter::OnGetLocalHistoryCount, | 67 base::Bind(&HistoryCounter::OnGetLocalHistoryCount, |
| 66 weak_ptr_factory_.GetWeakPtr()), | 68 weak_ptr_factory_.GetWeakPtr()), |
| 67 &cancelable_task_tracker_); | 69 &cancelable_task_tracker_); |
| (...skipping 97 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 165 | 167 |
| 166 // If the history sync was just enabled or disabled, restart the counter | 168 // If the history sync was just enabled or disabled, restart the counter |
| 167 // so that we update the result accordingly. | 169 // so that we update the result accordingly. |
| 168 if (history_sync_enabled_ != history_sync_enabled_new_state) { | 170 if (history_sync_enabled_ != history_sync_enabled_new_state) { |
| 169 history_sync_enabled_ = history_sync_enabled_new_state; | 171 history_sync_enabled_ = history_sync_enabled_new_state; |
| 170 Restart(); | 172 Restart(); |
| 171 } | 173 } |
| 172 } | 174 } |
| 173 | 175 |
| 174 } // namespace browsing_data | 176 } // namespace browsing_data |
| OLD | NEW |