OLD | NEW |
---|---|
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 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 | 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 #ifndef SYNC_INTERNAL_API_PUBLIC_TEST_FAKE_SYNC_MANAGER_H_ | 5 #ifndef SYNC_INTERNAL_API_PUBLIC_TEST_FAKE_SYNC_MANAGER_H_ |
6 #define SYNC_INTERNAL_API_PUBLIC_TEST_FAKE_SYNC_MANAGER_H_ | 6 #define SYNC_INTERNAL_API_PUBLIC_TEST_FAKE_SYNC_MANAGER_H_ |
7 | 7 |
8 #include <string> | 8 #include <string> |
9 | 9 |
10 #include "base/memory/ref_counted.h" | 10 #include "base/memory/ref_counted.h" |
11 #include "base/observer_list.h" | 11 #include "base/observer_list.h" |
12 #include "sync/internal_api/public/sync_manager.h" | 12 #include "sync/internal_api/public/sync_manager.h" |
13 #include "sync/notifier/sync_notifier_helper.h" | 13 #include "sync/notifier/sync_notifier_helper.h" |
14 | 14 |
15 namespace base { | 15 namespace base { |
16 class SequencedTaskRunner; | 16 class SequencedTaskRunner; |
17 } | 17 } |
18 | 18 |
19 namespace syncer { | 19 namespace syncer { |
20 | 20 |
21 class FakeSyncManager : public SyncManager { | 21 class FakeSyncManager : public SyncManager { |
22 public: | 22 public: |
23 explicit FakeSyncManager(); | 23 // |initial_sync_ended_types|: The set of types that have |
msw
2012/08/03 23:30:46
nit: line breaks :)
akalin
2012/08/07 07:25:19
Done.
| |
24 // initial_sync_ended set to true. This value will be used by | |
25 // InitialSyncEndedTypes() until the next configuration is | |
26 // performed. | |
27 // | |
28 // |progress_marker_types|: The set of types that have valid | |
29 // progress markers. This will be used by | |
30 // GetTypesWithEmptyProgressMarkerToken() until the next | |
31 // configuration is performed. | |
32 // | |
33 // |configure_fail_types|: The set of types that will fail | |
34 // configuration. Once ConfigureSyncer is called, the | |
35 // |initial_sync_ended_types_| and |progress_marker_types_| will be | |
36 // updated to include those types that didn't fail. | |
37 FakeSyncManager(ModelTypeSet initial_sync_ended_types, | |
38 ModelTypeSet progress_marker_types, | |
39 ModelTypeSet configure_fail_types); | |
24 virtual ~FakeSyncManager(); | 40 virtual ~FakeSyncManager(); |
25 | 41 |
26 // The set of types that have initial_sync_ended set to true. This value will | |
27 // be used by InitialSyncEndedTypes() until the next configuration is | |
28 // performed. | |
29 void set_initial_sync_ended_types(ModelTypeSet types); | |
30 | |
31 // The set of types that have valid progress markers. This will be used by | |
32 // GetTypesWithEmptyProgressMarkerToken() until the next configuration is | |
33 // performed. | |
34 void set_progress_marker_types(ModelTypeSet types); | |
35 | |
36 // The set of types that will fail configuration. Once ConfigureSyncer is | |
37 // called, the |initial_sync_ended_types_| and | |
38 // |progress_marker_types_| will be updated to include those types | |
39 // that didn't fail. | |
40 void set_configure_fail_types(ModelTypeSet types); | |
41 | |
42 // Returns those types that have been cleaned (purged from the directory) | 42 // Returns those types that have been cleaned (purged from the directory) |
43 // since the last call to GetAndResetCleanedTypes(), or since startup if never | 43 // since the last call to GetAndResetCleanedTypes(), or since startup if never |
44 // called. | 44 // called. |
45 ModelTypeSet GetAndResetCleanedTypes(); | 45 ModelTypeSet GetAndResetCleanedTypes(); |
46 | 46 |
47 // Returns those types that have been downloaded since the last call to | 47 // Returns those types that have been downloaded since the last call to |
48 // GetAndResetDownloadedTypes(), or since startup if never called. | 48 // GetAndResetDownloadedTypes(), or since startup if never called. |
49 ModelTypeSet GetAndResetDownloadedTypes(); | 49 ModelTypeSet GetAndResetDownloadedTypes(); |
50 | 50 |
51 // Returns those types that have been marked as enabled since the | 51 // Returns those types that have been marked as enabled since the |
52 // last call to GetAndResetEnabledTypes(), or since startup if never | 52 // last call to GetAndResetEnabledTypes(), or since startup if never |
53 // called. | 53 // called. |
54 ModelTypeSet GetAndResetEnabledTypes(); | 54 ModelTypeSet GetAndResetEnabledTypes(); |
55 | 55 |
56 // Posts a method to invalidate the given IDs on the sync thread. | 56 // Posts a method to invalidate the given IDs on the sync thread. |
57 void Invalidate( | 57 void Invalidate( |
58 const ObjectIdPayloadMap& id_payloads, | 58 const ObjectIdPayloadMap& id_payloads, |
59 IncomingNotificationSource source); | 59 IncomingNotificationSource source); |
60 | 60 |
61 // Posts a method to enable notifications on the sync thread. | 61 // Posts a method to enable notifications on the sync thread. |
62 void EnableNotifications(); | 62 void EnableNotifications(); |
63 | 63 |
64 // Posts a method to disable notifications on the sync thread. | 64 // Posts a method to disable notifications on the sync thread. |
65 void DisableNotifications(NotificationsDisabledReason reason); | 65 void DisableNotifications(NotificationsDisabledReason reason); |
66 | 66 |
67 // Block until the sync thread has finished processing any pending | |
msw
2012/08/03 23:30:46
nit: line breaks :)
akalin
2012/08/07 07:25:19
Done.
| |
68 // messages. | |
69 void WaitForSyncThread(); | |
70 | |
67 // SyncManager implementation. | 71 // SyncManager implementation. |
68 // Note: we treat whatever message loop this is called from as the sync | 72 // Note: we treat whatever message loop this is called from as the sync |
69 // loop for purposes of callbacks. | 73 // loop for purposes of callbacks. |
70 virtual bool Init( | 74 virtual bool Init( |
71 const FilePath& database_location, | 75 const FilePath& database_location, |
72 const WeakHandle<JsEventHandler>& event_handler, | 76 const WeakHandle<JsEventHandler>& event_handler, |
73 const std::string& sync_server_and_path, | 77 const std::string& sync_server_and_path, |
74 int sync_server_port, | 78 int sync_server_port, |
75 bool use_ssl, | 79 bool use_ssl, |
76 const scoped_refptr<base::TaskRunner>& blocking_task_runner, | 80 const scoped_refptr<base::TaskRunner>& blocking_task_runner, |
(...skipping 11 matching lines...) Expand all Loading... | |
88 UnrecoverableErrorHandler* unrecoverable_error_handler, | 92 UnrecoverableErrorHandler* unrecoverable_error_handler, |
89 ReportUnrecoverableErrorFunction | 93 ReportUnrecoverableErrorFunction |
90 report_unrecoverable_error_function) OVERRIDE; | 94 report_unrecoverable_error_function) OVERRIDE; |
91 virtual void ThrowUnrecoverableError() OVERRIDE; | 95 virtual void ThrowUnrecoverableError() OVERRIDE; |
92 virtual ModelTypeSet InitialSyncEndedTypes() OVERRIDE; | 96 virtual ModelTypeSet InitialSyncEndedTypes() OVERRIDE; |
93 virtual ModelTypeSet GetTypesWithEmptyProgressMarkerToken( | 97 virtual ModelTypeSet GetTypesWithEmptyProgressMarkerToken( |
94 ModelTypeSet types) OVERRIDE; | 98 ModelTypeSet types) OVERRIDE; |
95 virtual bool PurgePartiallySyncedTypes() OVERRIDE; | 99 virtual bool PurgePartiallySyncedTypes() OVERRIDE; |
96 virtual void UpdateCredentials(const SyncCredentials& credentials) OVERRIDE; | 100 virtual void UpdateCredentials(const SyncCredentials& credentials) OVERRIDE; |
97 virtual void UpdateEnabledTypes(const ModelTypeSet& types) OVERRIDE; | 101 virtual void UpdateEnabledTypes(const ModelTypeSet& types) OVERRIDE; |
102 virtual void SetInvalidationHandler( | |
103 const std::string& handler_name, | |
104 SyncNotifierObserver* handler) OVERRIDE; | |
98 virtual void UpdateRegisteredInvalidationIds( | 105 virtual void UpdateRegisteredInvalidationIds( |
99 SyncNotifierObserver* handler, const ObjectIdSet& ids) OVERRIDE; | 106 const std::string& handler_name, const ObjectIdSet& ids) OVERRIDE; |
100 virtual void StartSyncingNormally( | 107 virtual void StartSyncingNormally( |
101 const ModelSafeRoutingInfo& routing_info) OVERRIDE; | 108 const ModelSafeRoutingInfo& routing_info) OVERRIDE; |
102 virtual void SetEncryptionPassphrase(const std::string& passphrase, | 109 virtual void SetEncryptionPassphrase(const std::string& passphrase, |
103 bool is_explicit) OVERRIDE; | 110 bool is_explicit) OVERRIDE; |
104 virtual void SetDecryptionPassphrase(const std::string& passphrase) OVERRIDE; | 111 virtual void SetDecryptionPassphrase(const std::string& passphrase) OVERRIDE; |
105 virtual void ConfigureSyncer( | 112 virtual void ConfigureSyncer( |
106 ConfigureReason reason, | 113 ConfigureReason reason, |
107 const ModelTypeSet& types_to_config, | 114 const ModelTypeSet& types_to_config, |
108 const ModelSafeRoutingInfo& new_routing_info, | 115 const ModelSafeRoutingInfo& new_routing_info, |
109 const base::Closure& ready_task, | 116 const base::Closure& ready_task, |
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
151 | 158 |
152 // Faked notifier state. | 159 // Faked notifier state. |
153 SyncNotifierHelper notifier_helper_; | 160 SyncNotifierHelper notifier_helper_; |
154 | 161 |
155 DISALLOW_COPY_AND_ASSIGN(FakeSyncManager); | 162 DISALLOW_COPY_AND_ASSIGN(FakeSyncManager); |
156 }; | 163 }; |
157 | 164 |
158 } // namespace syncer | 165 } // namespace syncer |
159 | 166 |
160 #endif // SYNC_INTERNAL_API_PUBLIC_TEST_FAKE_SYNC_MANAGER_H_ | 167 #endif // SYNC_INTERNAL_API_PUBLIC_TEST_FAKE_SYNC_MANAGER_H_ |
OLD | NEW |