| 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_impl.h" | 5 #include "components/suggestions/suggestions_service_impl.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 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 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(syncer::SyncService* sync) { | 68 SyncState GetSyncState(syncer::SyncService* sync) { |
| 69 if (!sync || !sync->CanSyncStart()) | 69 if (!sync || !sync->CanSyncStart() || sync->IsLocalSyncEnabled()) |
| 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. |
| 79 enum SuggestionsResponseState { | 79 enum SuggestionsResponseState { |
| (...skipping 478 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 558 scheduling_delay_ = TimeDelta::FromSeconds(kDefaultSchedulingDelaySec); | 558 scheduling_delay_ = TimeDelta::FromSeconds(kDefaultSchedulingDelaySec); |
| 559 } else { | 559 } else { |
| 560 TimeDelta candidate_delay = | 560 TimeDelta candidate_delay = |
| 561 scheduling_delay_ * kSchedulingBackoffMultiplier; | 561 scheduling_delay_ * kSchedulingBackoffMultiplier; |
| 562 if (candidate_delay < TimeDelta::FromSeconds(kSchedulingMaxDelaySec)) | 562 if (candidate_delay < TimeDelta::FromSeconds(kSchedulingMaxDelaySec)) |
| 563 scheduling_delay_ = candidate_delay; | 563 scheduling_delay_ = candidate_delay; |
| 564 } | 564 } |
| 565 } | 565 } |
| 566 | 566 |
| 567 } // namespace suggestions | 567 } // namespace suggestions |
| OLD | NEW |