Fix import error in mac_platform_backend.py
[chromium-blink-merge.git] / sync / internal_api / public / test / fake_sync_manager.h
blob41dee19201b8a1900d2614e113430f19825e1fdc
1 // Copyright (c) 2012 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.
5 #ifndef SYNC_INTERNAL_API_PUBLIC_TEST_FAKE_SYNC_MANAGER_H_
6 #define SYNC_INTERNAL_API_PUBLIC_TEST_FAKE_SYNC_MANAGER_H_
8 #include <string>
10 #include "base/memory/ref_counted.h"
11 #include "base/observer_list.h"
12 #include "sync/internal_api/public/sync_manager.h"
13 #include "sync/internal_api/public/test/test_user_share.h"
14 #include "sync/notifier/invalidator_registrar.h"
16 namespace base {
17 class SequencedTaskRunner;
20 namespace syncer {
22 class FakeSyncEncryptionHandler;
24 class FakeSyncManager : public SyncManager {
25 public:
26 // |initial_sync_ended_types|: The set of types that have initial_sync_ended
27 // set to true. This value will be used by InitialSyncEndedTypes() until the
28 // next configuration is performed.
30 // |progress_marker_types|: The set of types that have valid progress
31 // markers. This will be used by GetTypesWithEmptyProgressMarkerToken() until
32 // the next configuration is performed.
34 // |configure_fail_types|: The set of types that will fail
35 // configuration. Once ConfigureSyncer is called, the
36 // |initial_sync_ended_types_| and |progress_marker_types_| will be updated
37 // to include those types that didn't fail.
38 FakeSyncManager(ModelTypeSet initial_sync_ended_types,
39 ModelTypeSet progress_marker_types,
40 ModelTypeSet configure_fail_types);
41 virtual ~FakeSyncManager();
43 // Returns those types that have been cleaned (purged from the directory)
44 // since the last call to GetAndResetCleanedTypes(), or since startup if never
45 // called.
46 ModelTypeSet GetAndResetCleanedTypes();
48 // Returns those types that have been downloaded since the last call to
49 // GetAndResetDownloadedTypes(), or since startup if never called.
50 ModelTypeSet GetAndResetDownloadedTypes();
52 // Returns those types that have been marked as enabled since the
53 // last call to GetAndResetEnabledTypes(), or since startup if never
54 // called.
55 ModelTypeSet GetAndResetEnabledTypes();
57 // Returns the types that have most recently received a refresh request.
58 ModelTypeSet GetLastRefreshRequestTypes();
60 // Returns the most recent configuration reason since the last call to
61 // GetAndResetConfigureReason, or since startup if never called.
62 ConfigureReason GetAndResetConfigureReason();
64 // Posts a method to invalidate the given IDs on the sync thread.
65 virtual void OnIncomingInvalidation(
66 const ObjectIdInvalidationMap& invalidation_map) OVERRIDE;
68 // Posts a method to update the invalidator state on the sync thread.
69 virtual void OnInvalidatorStateChange(InvalidatorState state) OVERRIDE;
71 // Block until the sync thread has finished processing any pending messages.
72 void WaitForSyncThread();
74 // SyncManager implementation.
75 // Note: we treat whatever message loop this is called from as the sync
76 // loop for purposes of callbacks.
77 virtual void Init(
78 const base::FilePath& database_location,
79 const WeakHandle<JsEventHandler>& event_handler,
80 const std::string& sync_server_and_path,
81 int sync_server_port,
82 bool use_ssl,
83 scoped_ptr<HttpPostProviderFactory> post_factory,
84 const std::vector<scoped_refptr<ModelSafeWorker> >& workers,
85 ExtensionsActivity* extensions_activity,
86 ChangeDelegate* change_delegate,
87 const SyncCredentials& credentials,
88 const std::string& invalidator_client_id,
89 const std::string& restored_key_for_bootstrapping,
90 const std::string& restored_keystore_key_for_bootstrapping,
91 InternalComponentsFactory* internal_components_factory,
92 Encryptor* encryptor,
93 scoped_ptr<UnrecoverableErrorHandler> unrecoverable_error_handler,
94 ReportUnrecoverableErrorFunction report_unrecoverable_error_function,
95 CancelationSignal* cancelation_signal) OVERRIDE;
96 virtual void ThrowUnrecoverableError() OVERRIDE;
97 virtual ModelTypeSet InitialSyncEndedTypes() OVERRIDE;
98 virtual ModelTypeSet GetTypesWithEmptyProgressMarkerToken(
99 ModelTypeSet types) OVERRIDE;
100 virtual bool PurgePartiallySyncedTypes() OVERRIDE;
101 virtual void UpdateCredentials(const SyncCredentials& credentials) OVERRIDE;
102 virtual void StartSyncingNormally(
103 const ModelSafeRoutingInfo& routing_info) OVERRIDE;
104 virtual void ConfigureSyncer(
105 ConfigureReason reason,
106 ModelTypeSet to_download,
107 ModelTypeSet to_purge,
108 ModelTypeSet to_journal,
109 ModelTypeSet to_unapply,
110 const ModelSafeRoutingInfo& new_routing_info,
111 const base::Closure& ready_task,
112 const base::Closure& retry_task) OVERRIDE;
113 virtual void AddObserver(Observer* observer) OVERRIDE;
114 virtual void RemoveObserver(Observer* observer) OVERRIDE;
115 virtual SyncStatus GetDetailedStatus() const OVERRIDE;
116 virtual void SaveChanges() OVERRIDE;
117 virtual void ShutdownOnSyncThread() OVERRIDE;
118 virtual UserShare* GetUserShare() OVERRIDE;
119 virtual const std::string cache_guid() OVERRIDE;
120 virtual bool ReceivedExperiment(Experiments* experiments) OVERRIDE;
121 virtual bool HasUnsyncedItems() OVERRIDE;
122 virtual SyncEncryptionHandler* GetEncryptionHandler() OVERRIDE;
123 virtual void RefreshTypes(ModelTypeSet types) OVERRIDE;
125 private:
126 scoped_refptr<base::SequencedTaskRunner> sync_task_runner_;
128 ObserverList<SyncManager::Observer> observers_;
130 // Faked directory state.
131 ModelTypeSet initial_sync_ended_types_;
132 ModelTypeSet progress_marker_types_;
134 // Test specific state.
135 // The types that should fail configuration attempts. These types will not
136 // have their progress markers or initial_sync_ended bits set.
137 ModelTypeSet configure_fail_types_;
138 // The set of types that have been cleaned up.
139 ModelTypeSet cleaned_types_;
140 // The set of types that have been downloaded.
141 ModelTypeSet downloaded_types_;
142 // The set of types that have been enabled.
143 ModelTypeSet enabled_types_;
145 // Faked invalidator state.
146 InvalidatorRegistrar registrar_;
148 // The types for which a refresh was most recently requested.
149 ModelTypeSet last_refresh_request_types_;
151 // The most recent configure reason.
152 ConfigureReason last_configure_reason_;
154 scoped_ptr<FakeSyncEncryptionHandler> fake_encryption_handler_;
156 TestUserShare test_user_share_;
158 DISALLOW_COPY_AND_ASSIGN(FakeSyncManager);
161 } // namespace syncer
163 #endif // SYNC_INTERNAL_API_PUBLIC_TEST_FAKE_SYNC_MANAGER_H_