OLD | NEW |
1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 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 "chrome/browser/history/browsing_history_service.h" | 5 #include "chrome/browser/history/browsing_history_service.h" |
6 | 6 |
7 #include <stddef.h> | 7 #include <stddef.h> |
8 | 8 |
9 #include <algorithm> | 9 #include <algorithm> |
10 #include <map> | 10 #include <map> |
(...skipping 134 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
145 if (sync_service) | 145 if (sync_service) |
146 sync_service_observer_.Add(sync_service); | 146 sync_service_observer_.Add(sync_service); |
147 } | 147 } |
148 } | 148 } |
149 | 149 |
150 BrowsingHistoryService::~BrowsingHistoryService() { | 150 BrowsingHistoryService::~BrowsingHistoryService() { |
151 query_task_tracker_.TryCancelAll(); | 151 query_task_tracker_.TryCancelAll(); |
152 web_history_request_.reset(); | 152 web_history_request_.reset(); |
153 } | 153 } |
154 | 154 |
155 void BrowsingHistoryService::OnStateChanged() { | 155 void BrowsingHistoryService::OnStateChanged(syncer::SyncService* sync) { |
156 // If the history sync was enabled, start observing WebHistoryService. | 156 // If the history sync was enabled, start observing WebHistoryService. |
157 // This method should not be called after we already added the observer. | 157 // This method should not be called after we already added the observer. |
158 history::WebHistoryService* web_history = | 158 history::WebHistoryService* web_history = |
159 WebHistoryServiceFactory::GetForProfile(profile_); | 159 WebHistoryServiceFactory::GetForProfile(profile_); |
160 if (web_history) { | 160 if (web_history) { |
161 DCHECK(!web_history_service_observer_.IsObserving(web_history)); | 161 DCHECK(!web_history_service_observer_.IsObserving(web_history)); |
162 web_history_service_observer_.Add(web_history); | 162 web_history_service_observer_.Add(web_history); |
163 sync_service_observer_.RemoveAll(); | 163 sync_service_observer_.RemoveAll(); |
164 } | 164 } |
165 } | 165 } |
(...skipping 407 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
573 if (all_history || DeletionsDiffer(deleted_rows, urls_to_be_deleted_)) | 573 if (all_history || DeletionsDiffer(deleted_rows, urls_to_be_deleted_)) |
574 handler_->HistoryDeleted(); | 574 handler_->HistoryDeleted(); |
575 } | 575 } |
576 | 576 |
577 void BrowsingHistoryService::OnWebHistoryDeleted() { | 577 void BrowsingHistoryService::OnWebHistoryDeleted() { |
578 // TODO(calamity): Only ignore web history deletions when they are actually | 578 // TODO(calamity): Only ignore web history deletions when they are actually |
579 // initiated by us, rather than ignoring them whenever we are deleting. | 579 // initiated by us, rather than ignoring them whenever we are deleting. |
580 if (!has_pending_delete_request_) | 580 if (!has_pending_delete_request_) |
581 handler_->HistoryDeleted(); | 581 handler_->HistoryDeleted(); |
582 } | 582 } |
OLD | NEW |