We started redesigning GpuMemoryBuffer interface to handle multiple buffers [0].
[chromium-blink-merge.git] / sync / internal_api / public / test / fake_sync_manager.h
blobedad9b906f52f97efe2e3728d4dda4af4640e16d
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/null_sync_context_proxy.h"
14 #include "sync/internal_api/public/test/test_user_share.h"
16 class GURL;
18 namespace base {
19 class SequencedTaskRunner;
22 namespace syncer {
24 class FakeSyncEncryptionHandler;
26 class FakeSyncManager : public SyncManager {
27 public:
28 // |initial_sync_ended_types|: The set of types that have initial_sync_ended
29 // set to true. This value will be used by InitialSyncEndedTypes() until the
30 // next configuration is performed.
32 // |progress_marker_types|: The set of types that have valid progress
33 // markers. This will be used by GetTypesWithEmptyProgressMarkerToken() until
34 // the next configuration is performed.
36 // |configure_fail_types|: The set of types that will fail
37 // configuration. Once ConfigureSyncer is called, the
38 // |initial_sync_ended_types_| and |progress_marker_types_| will be updated
39 // to include those types that didn't fail.
40 FakeSyncManager(ModelTypeSet initial_sync_ended_types,
41 ModelTypeSet progress_marker_types,
42 ModelTypeSet configure_fail_types);
43 ~FakeSyncManager() override;
45 // Returns those types that have been cleaned (purged from the directory)
46 // since the last call to GetAndResetCleanedTypes(), or since startup if never
47 // called.
48 ModelTypeSet GetAndResetCleanedTypes();
50 // Returns those types that have been downloaded since the last call to
51 // GetAndResetDownloadedTypes(), or since startup if never called.
52 ModelTypeSet GetAndResetDownloadedTypes();
54 // Returns those types that have been marked as enabled since the
55 // last call to GetAndResetEnabledTypes(), or since startup if never
56 // called.
57 ModelTypeSet GetAndResetEnabledTypes();
59 // Returns the types that have most recently received a refresh request.
60 ModelTypeSet GetLastRefreshRequestTypes();
62 // Returns the most recent configuration reason since the last call to
63 // GetAndResetConfigureReason, or since startup if never called.
64 ConfigureReason GetAndResetConfigureReason();
66 // Posts a method to invalidate the given IDs on the sync thread.
67 void OnIncomingInvalidation(
68 syncer::ModelType type,
69 scoped_ptr<InvalidationInterface> interface) override;
71 // Posts a method to update the invalidator state on the sync thread.
72 void SetInvalidatorEnabled(bool invalidator_enabled) override;
74 // Block until the sync thread has finished processing any pending messages.
75 void WaitForSyncThread();
77 // SyncManager implementation.
78 // Note: we treat whatever message loop this is called from as the sync
79 // loop for purposes of callbacks.
80 void Init(InitArgs* args) override;
81 ModelTypeSet InitialSyncEndedTypes() override;
82 ModelTypeSet GetTypesWithEmptyProgressMarkerToken(
83 ModelTypeSet types) override;
84 bool PurgePartiallySyncedTypes() override;
85 void UpdateCredentials(const SyncCredentials& credentials) override;
86 void StartSyncingNormally(const ModelSafeRoutingInfo& routing_info) override;
87 void ConfigureSyncer(ConfigureReason reason,
88 ModelTypeSet to_download,
89 ModelTypeSet to_purge,
90 ModelTypeSet to_journal,
91 ModelTypeSet to_unapply,
92 const ModelSafeRoutingInfo& new_routing_info,
93 const base::Closure& ready_task,
94 const base::Closure& retry_task) override;
95 void AddObserver(Observer* observer) override;
96 void RemoveObserver(Observer* observer) override;
97 SyncStatus GetDetailedStatus() const override;
98 void SaveChanges() override;
99 void ShutdownOnSyncThread(ShutdownReason reason) override;
100 UserShare* GetUserShare() override;
101 syncer::SyncContextProxy* GetSyncContextProxy() override;
102 const std::string cache_guid() override;
103 bool ReceivedExperiment(Experiments* experiments) override;
104 bool HasUnsyncedItems() override;
105 SyncEncryptionHandler* GetEncryptionHandler() override;
106 ScopedVector<syncer::ProtocolEvent> GetBufferedProtocolEvents() override;
107 scoped_ptr<base::ListValue> GetAllNodesForType(
108 syncer::ModelType type) override;
109 void RefreshTypes(ModelTypeSet types) override;
110 void RegisterDirectoryTypeDebugInfoObserver(
111 syncer::TypeDebugInfoObserver* observer) override;
112 void UnregisterDirectoryTypeDebugInfoObserver(
113 syncer::TypeDebugInfoObserver* observer) override;
114 bool HasDirectoryTypeDebugInfoObserver(
115 syncer::TypeDebugInfoObserver* observer) override;
116 void RequestEmitDebugInfo() override;
118 private:
119 scoped_refptr<base::SequencedTaskRunner> sync_task_runner_;
121 ObserverList<SyncManager::Observer> observers_;
123 // Faked directory state.
124 ModelTypeSet initial_sync_ended_types_;
125 ModelTypeSet progress_marker_types_;
127 // Test specific state.
128 // The types that should fail configuration attempts. These types will not
129 // have their progress markers or initial_sync_ended bits set.
130 ModelTypeSet configure_fail_types_;
131 // The set of types that have been cleaned up.
132 ModelTypeSet cleaned_types_;
133 // The set of types that have been downloaded.
134 ModelTypeSet downloaded_types_;
135 // The set of types that have been enabled.
136 ModelTypeSet enabled_types_;
138 // The types for which a refresh was most recently requested.
139 ModelTypeSet last_refresh_request_types_;
141 // The most recent configure reason.
142 ConfigureReason last_configure_reason_;
144 scoped_ptr<FakeSyncEncryptionHandler> fake_encryption_handler_;
146 TestUserShare test_user_share_;
148 NullSyncContextProxy null_sync_context_proxy_;
150 DISALLOW_COPY_AND_ASSIGN(FakeSyncManager);
153 } // namespace syncer
155 #endif // SYNC_INTERNAL_API_PUBLIC_TEST_FAKE_SYNC_MANAGER_H_