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 #import "ios/chrome/browser/ui/history/history_service_facade.h" | 5 #import "ios/chrome/browser/ui/history/history_service_facade.h" |
6 | 6 |
7 #include <stddef.h> | 7 #include <stddef.h> |
8 | 8 |
9 #include "base/bind.h" | 9 #include "base/bind.h" |
10 #include "base/bind_helpers.h" | 10 #include "base/bind_helpers.h" |
(...skipping 19 matching lines...) Expand all Loading... |
30 #include "ios/chrome/browser/browser_state/chrome_browser_state.h" | 30 #include "ios/chrome/browser/browser_state/chrome_browser_state.h" |
31 #include "ios/chrome/browser/history/history_service_factory.h" | 31 #include "ios/chrome/browser/history/history_service_factory.h" |
32 #include "ios/chrome/browser/history/history_utils.h" | 32 #include "ios/chrome/browser/history/history_utils.h" |
33 #include "ios/chrome/browser/history/web_history_service_factory.h" | 33 #include "ios/chrome/browser/history/web_history_service_factory.h" |
34 #include "ios/chrome/browser/pref_names.h" | 34 #include "ios/chrome/browser/pref_names.h" |
35 #include "ios/chrome/browser/sync/ios_chrome_profile_sync_service_factory.h" | 35 #include "ios/chrome/browser/sync/ios_chrome_profile_sync_service_factory.h" |
36 #include "ios/chrome/browser/ui/history/history_entry.h" | 36 #include "ios/chrome/browser/ui/history/history_entry.h" |
37 #include "ios/chrome/browser/ui/history/history_service_facade_delegate.h" | 37 #include "ios/chrome/browser/ui/history/history_service_facade_delegate.h" |
38 #include "ios/chrome/browser/ui/history/history_util.h" | 38 #include "ios/chrome/browser/ui/history/history_util.h" |
39 | 39 |
| 40 #if !defined(__has_feature) || !__has_feature(objc_arc) |
| 41 #error "This file requires ARC support." |
| 42 #endif |
| 43 |
40 // The amount of time to wait for a response from the WebHistoryService. | 44 // The amount of time to wait for a response from the WebHistoryService. |
41 static const int kWebHistoryTimeoutSeconds = 3; | 45 static const int kWebHistoryTimeoutSeconds = 3; |
42 | 46 |
43 namespace { | 47 namespace { |
44 | 48 |
45 // Buckets for UMA histograms. | 49 // Buckets for UMA histograms. |
46 enum WebHistoryQueryBuckets { | 50 enum WebHistoryQueryBuckets { |
47 WEB_HISTORY_QUERY_FAILED = 0, | 51 WEB_HISTORY_QUERY_FAILED = 0, |
48 WEB_HISTORY_QUERY_SUCCEEDED, | 52 WEB_HISTORY_QUERY_SUCCEEDED, |
49 WEB_HISTORY_QUERY_TIMED_OUT, | 53 WEB_HISTORY_QUERY_TIMED_OUT, |
(...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
121 history::HistoryService* history_service = | 125 history::HistoryService* history_service = |
122 ios::HistoryServiceFactory::GetForBrowserState( | 126 ios::HistoryServiceFactory::GetForBrowserState( |
123 browser_state, ServiceAccessType::EXPLICIT_ACCESS); | 127 browser_state, ServiceAccessType::EXPLICIT_ACCESS); |
124 if (history_service) | 128 if (history_service) |
125 history_service_observer_.Add(history_service); | 129 history_service_observer_.Add(history_service); |
126 } | 130 } |
127 | 131 |
128 HistoryServiceFacade::~HistoryServiceFacade() { | 132 HistoryServiceFacade::~HistoryServiceFacade() { |
129 query_task_tracker_.TryCancelAll(); | 133 query_task_tracker_.TryCancelAll(); |
130 web_history_request_.reset(); | 134 web_history_request_.reset(); |
131 delegate_.reset(); | 135 delegate_ = nil; |
132 } | 136 } |
133 | 137 |
134 void HistoryServiceFacade::QueryHistory(const base::string16& search_text, | 138 void HistoryServiceFacade::QueryHistory(const base::string16& search_text, |
135 const history::QueryOptions& options) { | 139 const history::QueryOptions& options) { |
136 // Anything in-flight is invalid. | 140 // Anything in-flight is invalid. |
137 query_task_tracker_.TryCancelAll(); | 141 query_task_tracker_.TryCancelAll(); |
138 web_history_request_.reset(); | 142 web_history_request_.reset(); |
139 | 143 |
140 // Reset results. | 144 // Reset results. |
141 query_results_.clear(); | 145 query_results_.clear(); |
(...skipping 314 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
456 const history::URLRows& deleted_rows, | 460 const history::URLRows& deleted_rows, |
457 const std::set<GURL>& favicon_urls) { | 461 const std::set<GURL>& favicon_urls) { |
458 if (all_history || DeletionsDiffer(deleted_rows, urls_to_be_deleted_)) { | 462 if (all_history || DeletionsDiffer(deleted_rows, urls_to_be_deleted_)) { |
459 if ([delegate_ | 463 if ([delegate_ |
460 respondsToSelector: | 464 respondsToSelector: |
461 @selector(historyServiceFacadeDidObserveHistoryDeletion:)]) { | 465 @selector(historyServiceFacadeDidObserveHistoryDeletion:)]) { |
462 [delegate_ historyServiceFacadeDidObserveHistoryDeletion:this]; | 466 [delegate_ historyServiceFacadeDidObserveHistoryDeletion:this]; |
463 } | 467 } |
464 } | 468 } |
465 } | 469 } |
OLD | NEW |