Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(526)

Side by Side Diff: components/browsing_data/core/counters/history_counter.cc

Issue 2657673004: Add shutdown notification and service refs to SyncServiceObserver. (Closed)
Patch Set: Use parameter Created 3 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 140 matching lines...) Expand 10 before | Expand all | Expand 10 after
151 base::MakeUnique<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(syncer::SyncService* sync) {
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
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698