sync_backend_host_mock.h revision effb81e5f8246d0db0270817048dc992db66e9fb
1// Copyright 2013 The Chromium Authors. All rights reserved. 2// Use of this source code is governed by a BSD-style license that can be 3// found in the LICENSE file. 4 5#ifndef CHROME_BROWSER_SYNC_GLUE_SYNC_BACKEND_HOST_MOCK_H_ 6#define CHROME_BROWSER_SYNC_GLUE_SYNC_BACKEND_HOST_MOCK_H_ 7 8#include <string> 9 10#include "base/callback.h" 11#include "base/compiler_specific.h" 12#include "chrome/browser/sync/glue/sync_backend_host.h" 13#include "sync/internal_api/public/util/weak_handle.h" 14 15namespace browser_sync { 16 17// A mock of the SyncBackendHost. 18// 19// This class implements the bare minimum required for the ProfileSyncService to 20// get through initialization. It often returns NULL pointers or nonesense 21// values; it is not intended to be used in tests that depend on SyncBackendHost 22// behavior. 23class SyncBackendHostMock : public SyncBackendHost { 24 public: 25 SyncBackendHostMock(); 26 virtual ~SyncBackendHostMock(); 27 28 virtual void Initialize( 29 SyncFrontend* frontend, 30 scoped_ptr<base::Thread> sync_thread, 31 const syncer::WeakHandle<syncer::JsEventHandler>& event_handler, 32 const GURL& service_url, 33 const syncer::SyncCredentials& credentials, 34 bool delete_sync_data_folder, 35 scoped_ptr<syncer::SyncManagerFactory> sync_manager_factory, 36 scoped_ptr<syncer::UnrecoverableErrorHandler> unrecoverable_error_handler, 37 syncer::ReportUnrecoverableErrorFunction 38 report_unrecoverable_error_function, 39 syncer::NetworkResources* network_resources) OVERRIDE; 40 41 virtual void UpdateCredentials( 42 const syncer::SyncCredentials& credentials) OVERRIDE; 43 44 virtual void StartSyncingWithServer() OVERRIDE; 45 46 virtual void SetEncryptionPassphrase( 47 const std::string& passphrase, 48 bool is_explicit) OVERRIDE; 49 50 virtual bool SetDecryptionPassphrase( 51 const std::string& passphrase) OVERRIDE; 52 53 virtual void StopSyncingForShutdown() OVERRIDE; 54 55 virtual scoped_ptr<base::Thread> Shutdown(ShutdownOption option) OVERRIDE; 56 57 virtual void UnregisterInvalidationIds() OVERRIDE; 58 59 virtual void ConfigureDataTypes( 60 syncer::ConfigureReason reason, 61 const DataTypeConfigStateMap& config_state_map, 62 const base::Callback<void(syncer::ModelTypeSet, 63 syncer::ModelTypeSet)>& ready_task, 64 const base::Callback<void()>& retry_callback) OVERRIDE; 65 66 virtual void EnableEncryptEverything() OVERRIDE; 67 68 virtual void ActivateDataType( 69 syncer::ModelType type, syncer::ModelSafeGroup group, 70 ChangeProcessor* change_processor) OVERRIDE; 71 virtual void DeactivateDataType(syncer::ModelType type) OVERRIDE; 72 73 virtual syncer::UserShare* GetUserShare() const OVERRIDE; 74 75 virtual Status GetDetailedStatus() OVERRIDE; 76 77 virtual syncer::sessions::SyncSessionSnapshot 78 GetLastSessionSnapshot() const OVERRIDE; 79 80 virtual bool HasUnsyncedItems() const OVERRIDE; 81 82 virtual bool IsNigoriEnabled() const OVERRIDE; 83 84 virtual syncer::PassphraseType GetPassphraseType() const OVERRIDE; 85 86 virtual base::Time GetExplicitPassphraseTime() const OVERRIDE; 87 88 virtual bool IsCryptographerReady( 89 const syncer::BaseTransaction* trans) const OVERRIDE; 90 91 virtual void GetModelSafeRoutingInfo( 92 syncer::ModelSafeRoutingInfo* out) const OVERRIDE; 93 94 virtual SyncedDeviceTracker* GetSyncedDeviceTracker() const OVERRIDE; 95 96 virtual void SetForwardProtocolEvents(bool enabled) OVERRIDE; 97 98 virtual base::MessageLoop* GetSyncLoopForTesting() OVERRIDE; 99 100 void set_fail_initial_download(bool should_fail); 101 102 private: 103 bool fail_initial_download_; 104}; 105 106} // namespace browser_sync 107 108#endif // CHROME_BROWSER_SYNC_GLUE_SYNC_BACKEND_HOST_MOCK_H_ 109