OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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/suggestions/suggestions_service.h" | 5 #include "components/suggestions/suggestions_service.h" |
6 | 6 |
7 #include <memory> | 7 #include <memory> |
8 #include <utility> | 8 #include <utility> |
9 | 9 |
10 #include "base/feature_list.h" | 10 #include "base/feature_list.h" |
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
58 // enabled. | 58 // enabled. |
59 // Behavior: Update suggestions from the server. Serve from cache on timeout. | 59 // Behavior: Update suggestions from the server. Serve from cache on timeout. |
60 INITIALIZED_ENABLED_HISTORY, | 60 INITIALIZED_ENABLED_HISTORY, |
61 | 61 |
62 // State: Sync service is disabled or history sync is disabled. | 62 // State: Sync service is disabled or history sync is disabled. |
63 // Behavior: Do not issue a server request. Clear the cache. Serve empty | 63 // Behavior: Do not issue a server request. Clear the cache. Serve empty |
64 // suggestions. | 64 // suggestions. |
65 SYNC_OR_HISTORY_SYNC_DISABLED, | 65 SYNC_OR_HISTORY_SYNC_DISABLED, |
66 }; | 66 }; |
67 | 67 |
68 SyncState GetSyncState(sync_driver::SyncService* sync) { | 68 SyncState GetSyncState(syncer::SyncService* sync) { |
69 if (!sync || !sync->CanSyncStart()) | 69 if (!sync || !sync->CanSyncStart()) |
70 return SYNC_OR_HISTORY_SYNC_DISABLED; | 70 return SYNC_OR_HISTORY_SYNC_DISABLED; |
71 if (!sync->IsSyncActive() || !sync->ConfigurationDone()) | 71 if (!sync->IsSyncActive() || !sync->ConfigurationDone()) |
72 return NOT_INITIALIZED_ENABLED; | 72 return NOT_INITIALIZED_ENABLED; |
73 return sync->GetActiveDataTypes().Has(syncer::HISTORY_DELETE_DIRECTIVES) | 73 return sync->GetActiveDataTypes().Has(syncer::HISTORY_DELETE_DIRECTIVES) |
74 ? INITIALIZED_ENABLED_HISTORY | 74 ? INITIALIZED_ENABLED_HISTORY |
75 : SYNC_OR_HISTORY_SYNC_DISABLED; | 75 : SYNC_OR_HISTORY_SYNC_DISABLED; |
76 } | 76 } |
77 | 77 |
78 // Used to UMA log the state of the last response from the server. | 78 // Used to UMA log the state of the last response from the server. |
(...skipping 110 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
189 const SigninManagerBase* signin_manager_; | 189 const SigninManagerBase* signin_manager_; |
190 OAuth2TokenService* token_service_; | 190 OAuth2TokenService* token_service_; |
191 | 191 |
192 TokenCallback callback_; | 192 TokenCallback callback_; |
193 std::unique_ptr<OAuth2TokenService::Request> token_request_; | 193 std::unique_ptr<OAuth2TokenService::Request> token_request_; |
194 }; | 194 }; |
195 | 195 |
196 SuggestionsService::SuggestionsService( | 196 SuggestionsService::SuggestionsService( |
197 const SigninManagerBase* signin_manager, | 197 const SigninManagerBase* signin_manager, |
198 OAuth2TokenService* token_service, | 198 OAuth2TokenService* token_service, |
199 sync_driver::SyncService* sync_service, | 199 syncer::SyncService* sync_service, |
200 net::URLRequestContextGetter* url_request_context, | 200 net::URLRequestContextGetter* url_request_context, |
201 std::unique_ptr<SuggestionsStore> suggestions_store, | 201 std::unique_ptr<SuggestionsStore> suggestions_store, |
202 std::unique_ptr<ImageManager> thumbnail_manager, | 202 std::unique_ptr<ImageManager> thumbnail_manager, |
203 std::unique_ptr<BlacklistStore> blacklist_store) | 203 std::unique_ptr<BlacklistStore> blacklist_store) |
204 : sync_service_(sync_service), | 204 : sync_service_(sync_service), |
205 sync_service_observer_(this), | 205 sync_service_observer_(this), |
206 url_request_context_(url_request_context), | 206 url_request_context_(url_request_context), |
207 suggestions_store_(std::move(suggestions_store)), | 207 suggestions_store_(std::move(suggestions_store)), |
208 thumbnail_manager_(std::move(thumbnail_manager)), | 208 thumbnail_manager_(std::move(thumbnail_manager)), |
209 blacklist_store_(std::move(blacklist_store)), | 209 blacklist_store_(std::move(blacklist_store)), |
(...skipping 352 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
562 scheduling_delay_ = TimeDelta::FromSeconds(kDefaultSchedulingDelaySec); | 562 scheduling_delay_ = TimeDelta::FromSeconds(kDefaultSchedulingDelaySec); |
563 } else { | 563 } else { |
564 TimeDelta candidate_delay = | 564 TimeDelta candidate_delay = |
565 scheduling_delay_ * kSchedulingBackoffMultiplier; | 565 scheduling_delay_ * kSchedulingBackoffMultiplier; |
566 if (candidate_delay < TimeDelta::FromSeconds(kSchedulingMaxDelaySec)) | 566 if (candidate_delay < TimeDelta::FromSeconds(kSchedulingMaxDelaySec)) |
567 scheduling_delay_ = candidate_delay; | 567 scheduling_delay_ = candidate_delay; |
568 } | 568 } |
569 } | 569 } |
570 | 570 |
571 } // namespace suggestions | 571 } // namespace suggestions |
OLD | NEW |