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