| 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 132 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 143 has_synced_visits_ = true; | 143 has_synced_visits_ = true; |
| 144 web_counting_finished_ = true; | 144 web_counting_finished_ = true; |
| 145 MergeResults(); | 145 MergeResults(); |
| 146 } | 146 } |
| 147 | 147 |
| 148 void HistoryCounter::MergeResults() { | 148 void HistoryCounter::MergeResults() { |
| 149 if (!local_counting_finished_ || !web_counting_finished_) | 149 if (!local_counting_finished_ || !web_counting_finished_) |
| 150 return; | 150 return; |
| 151 | 151 |
| 152 ReportResult( | 152 ReportResult( |
| 153 base::MakeUnique<HistoryResult>(this, local_result_, has_synced_visits_)); | 153 base::MakeUnique<SyncResult>(this, local_result_, has_synced_visits_)); |
| 154 } | 154 } |
| 155 | 155 |
| 156 HistoryCounter::HistoryResult::HistoryResult(const HistoryCounter* source, | |
| 157 ResultInt value, | |
| 158 bool has_synced_visits) | |
| 159 : FinishedResult(source, value), has_synced_visits_(has_synced_visits) {} | |
| 160 | |
| 161 HistoryCounter::HistoryResult::~HistoryResult() {} | |
| 162 | |
| 163 void HistoryCounter::OnStateChanged(syncer::SyncService* sync) { | 156 void HistoryCounter::OnStateChanged(syncer::SyncService* sync) { |
| 164 bool history_sync_enabled_new_state = !!web_history_service_callback_.Run(); | 157 bool history_sync_enabled_new_state = !!web_history_service_callback_.Run(); |
| 165 | 158 |
| 166 // If the history sync was just enabled or disabled, restart the counter | 159 // If the history sync was just enabled or disabled, restart the counter |
| 167 // so that we update the result accordingly. | 160 // so that we update the result accordingly. |
| 168 if (history_sync_enabled_ != history_sync_enabled_new_state) { | 161 if (history_sync_enabled_ != history_sync_enabled_new_state) { |
| 169 history_sync_enabled_ = history_sync_enabled_new_state; | 162 history_sync_enabled_ = history_sync_enabled_new_state; |
| 170 Restart(); | 163 Restart(); |
| 171 } | 164 } |
| 172 } | 165 } |
| 173 | 166 |
| 174 } // namespace browsing_data | 167 } // namespace browsing_data |
| OLD | NEW |