103b57e008b61dfcb1fbad3aea950ae0e001748b0Torne (Richard Coles)// Copyright 2014 The Chromium Authors. All rights reserved. 203b57e008b61dfcb1fbad3aea950ae0e001748b0Torne (Richard Coles)// Use of this source code is governed by a BSD-style license that can be 303b57e008b61dfcb1fbad3aea950ae0e001748b0Torne (Richard Coles)// found in the LICENSE file. 403b57e008b61dfcb1fbad3aea950ae0e001748b0Torne (Richard Coles) 503b57e008b61dfcb1fbad3aea950ae0e001748b0Torne (Richard Coles)#ifndef COMPONENTS_SUGGESTIONS_SUGGESTIONS_UTILS_H_ 603b57e008b61dfcb1fbad3aea950ae0e001748b0Torne (Richard Coles)#define COMPONENTS_SUGGESTIONS_SUGGESTIONS_UTILS_H_ 703b57e008b61dfcb1fbad3aea950ae0e001748b0Torne (Richard Coles) 803b57e008b61dfcb1fbad3aea950ae0e001748b0Torne (Richard Coles)namespace suggestions { 903b57e008b61dfcb1fbad3aea950ae0e001748b0Torne (Richard Coles) 1003b57e008b61dfcb1fbad3aea950ae0e001748b0Torne (Richard Coles)// Establishes the different sync states that users of SuggestionsService can 1103b57e008b61dfcb1fbad3aea950ae0e001748b0Torne (Richard Coles)// specify. There are three different concepts in the sync service: initialized, 1203b57e008b61dfcb1fbad3aea950ae0e001748b0Torne (Richard Coles)// sync enabled and history sync enabled. 1303b57e008b61dfcb1fbad3aea950ae0e001748b0Torne (Richard Coles)enum SyncState { 1403b57e008b61dfcb1fbad3aea950ae0e001748b0Torne (Richard Coles) // State: Sync service is not initialized, yet not disabled. History sync 1503b57e008b61dfcb1fbad3aea950ae0e001748b0Torne (Richard Coles) // state is unknown (since not initialized). 1603b57e008b61dfcb1fbad3aea950ae0e001748b0Torne (Richard Coles) // Behavior: Does not issue a server request, but serves from cache if 1703b57e008b61dfcb1fbad3aea950ae0e001748b0Torne (Richard Coles) // available. 1803b57e008b61dfcb1fbad3aea950ae0e001748b0Torne (Richard Coles) NOT_INITIALIZED_ENABLED, 1903b57e008b61dfcb1fbad3aea950ae0e001748b0Torne (Richard Coles) 2003b57e008b61dfcb1fbad3aea950ae0e001748b0Torne (Richard Coles) // State: Sync service is initialized, sync is enabled and history sync is 2103b57e008b61dfcb1fbad3aea950ae0e001748b0Torne (Richard Coles) // enabled. 2203b57e008b61dfcb1fbad3aea950ae0e001748b0Torne (Richard Coles) // Behavior: Update suggestions from the server. Serve from cache on timeout. 2303b57e008b61dfcb1fbad3aea950ae0e001748b0Torne (Richard Coles) INITIALIZED_ENABLED_HISTORY, 2403b57e008b61dfcb1fbad3aea950ae0e001748b0Torne (Richard Coles) 2503b57e008b61dfcb1fbad3aea950ae0e001748b0Torne (Richard Coles) // State: Sync service is disabled or history sync is disabled. 2603b57e008b61dfcb1fbad3aea950ae0e001748b0Torne (Richard Coles) // Behavior: Do not issue a server request. Clear the cache. Serve empty 2703b57e008b61dfcb1fbad3aea950ae0e001748b0Torne (Richard Coles) // suggestions. 2803b57e008b61dfcb1fbad3aea950ae0e001748b0Torne (Richard Coles) SYNC_OR_HISTORY_SYNC_DISABLED, 2903b57e008b61dfcb1fbad3aea950ae0e001748b0Torne (Richard Coles)}; 3003b57e008b61dfcb1fbad3aea950ae0e001748b0Torne (Richard Coles) 3103b57e008b61dfcb1fbad3aea950ae0e001748b0Torne (Richard Coles)// Users of SuggestionsService should always use this function to get SyncState. 3203b57e008b61dfcb1fbad3aea950ae0e001748b0Torne (Richard Coles)SyncState GetSyncState(bool sync_enabled, 3303b57e008b61dfcb1fbad3aea950ae0e001748b0Torne (Richard Coles) bool sync_initialized, 3403b57e008b61dfcb1fbad3aea950ae0e001748b0Torne (Richard Coles) bool history_sync_enabled); 3503b57e008b61dfcb1fbad3aea950ae0e001748b0Torne (Richard Coles) 3603b57e008b61dfcb1fbad3aea950ae0e001748b0Torne (Richard Coles)} // namespace suggestions 3703b57e008b61dfcb1fbad3aea950ae0e001748b0Torne (Richard Coles) 3803b57e008b61dfcb1fbad3aea950ae0e001748b0Torne (Richard Coles)#endif // COMPONENTS_SUGGESTIONS_SUGGESTIONS_UTILS_H_ 39