Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(229)

Side by Side Diff: sync/internal_api/public/test/fake_sync_manager.h

Issue 10805002: [Sync] Enable adding notifier observers from ProfileSyncService (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Address comments Created 8 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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"
11 #include "base/observer_list.h"
10 #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"
11 14
12 #include "base/observer_list.h" 15 namespace base {
13 16 class SequencedTaskRunner;
14 class MessageLoop; 17 }
15 18
16 namespace syncer { 19 namespace syncer {
17 20
18 class FakeSyncManager : public SyncManager { 21 class FakeSyncManager : public SyncManager {
19 public: 22 public:
20 explicit FakeSyncManager(); 23 explicit FakeSyncManager();
21 virtual ~FakeSyncManager(); 24 virtual ~FakeSyncManager();
22 25
23 // The set of types that have initial_sync_ended set to true. This value will 26 // The set of types that have initial_sync_ended set to true. This value will
24 // be used by InitialSyncEndedTypes() until the next configuration is 27 // be used by InitialSyncEndedTypes() until the next configuration is
(...skipping 18 matching lines...) Expand all
43 46
44 // 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
45 // GetAndResetDownloadedTypes(), or since startup if never called. 48 // GetAndResetDownloadedTypes(), or since startup if never called.
46 ModelTypeSet GetAndResetDownloadedTypes(); 49 ModelTypeSet GetAndResetDownloadedTypes();
47 50
48 // Returns those types that have been marked as enabled since the 51 // Returns those types that have been marked as enabled since the
49 // last call to GetAndResetEnabledTypes(), or since startup if never 52 // last call to GetAndResetEnabledTypes(), or since startup if never
50 // called. 53 // called.
51 ModelTypeSet GetAndResetEnabledTypes(); 54 ModelTypeSet GetAndResetEnabledTypes();
52 55
56 // Posts a method to invalidate the given IDs on the sync thread.
57 void Invalidate(
58 const ObjectIdPayloadMap& id_payloads,
msw 2012/08/03 05:14:21 nit: consider moving this to the line above, and i
59 IncomingNotificationSource source);
60
61 // Posts a method to enable notifications on the sync thread.
62 void EnableNotifications();
63
64 // Posts a method to disable notifications on the sync thread.
65 void DisableNotifications(NotificationsDisabledReason reason);
66
53 // SyncManager implementation. 67 // SyncManager implementation.
54 // Note: we treat whatever message loop this is called from as the sync 68 // Note: we treat whatever message loop this is called from as the sync
55 // loop for purposes of callbacks. 69 // loop for purposes of callbacks.
56 virtual bool Init( 70 virtual bool Init(
57 const FilePath& database_location, 71 const FilePath& database_location,
58 const WeakHandle<JsEventHandler>& event_handler, 72 const WeakHandle<JsEventHandler>& event_handler,
59 const std::string& sync_server_and_path, 73 const std::string& sync_server_and_path,
60 int sync_server_port, 74 int sync_server_port,
61 bool use_ssl, 75 bool use_ssl,
62 const scoped_refptr<base::TaskRunner>& blocking_task_runner, 76 const scoped_refptr<base::TaskRunner>& blocking_task_runner,
(...skipping 11 matching lines...) Expand all
74 UnrecoverableErrorHandler* unrecoverable_error_handler, 88 UnrecoverableErrorHandler* unrecoverable_error_handler,
75 ReportUnrecoverableErrorFunction 89 ReportUnrecoverableErrorFunction
76 report_unrecoverable_error_function) OVERRIDE; 90 report_unrecoverable_error_function) OVERRIDE;
77 virtual void ThrowUnrecoverableError() OVERRIDE; 91 virtual void ThrowUnrecoverableError() OVERRIDE;
78 virtual ModelTypeSet InitialSyncEndedTypes() OVERRIDE; 92 virtual ModelTypeSet InitialSyncEndedTypes() OVERRIDE;
79 virtual ModelTypeSet GetTypesWithEmptyProgressMarkerToken( 93 virtual ModelTypeSet GetTypesWithEmptyProgressMarkerToken(
80 ModelTypeSet types) OVERRIDE; 94 ModelTypeSet types) OVERRIDE;
81 virtual bool PurgePartiallySyncedTypes() OVERRIDE; 95 virtual bool PurgePartiallySyncedTypes() OVERRIDE;
82 virtual void UpdateCredentials(const SyncCredentials& credentials) OVERRIDE; 96 virtual void UpdateCredentials(const SyncCredentials& credentials) OVERRIDE;
83 virtual void UpdateEnabledTypes(const ModelTypeSet& types) OVERRIDE; 97 virtual void UpdateEnabledTypes(const ModelTypeSet& types) OVERRIDE;
98 virtual void UpdateRegisteredInvalidationIds(
99 SyncNotifierObserver* handler, const ObjectIdSet& ids) OVERRIDE;
msw 2012/08/03 05:14:21 One parameter per line.
84 virtual void StartSyncingNormally( 100 virtual void StartSyncingNormally(
85 const ModelSafeRoutingInfo& routing_info) OVERRIDE; 101 const ModelSafeRoutingInfo& routing_info) OVERRIDE;
86 virtual void SetEncryptionPassphrase(const std::string& passphrase, 102 virtual void SetEncryptionPassphrase(const std::string& passphrase,
87 bool is_explicit) OVERRIDE; 103 bool is_explicit) OVERRIDE;
88 virtual void SetDecryptionPassphrase(const std::string& passphrase) OVERRIDE; 104 virtual void SetDecryptionPassphrase(const std::string& passphrase) OVERRIDE;
89 virtual void ConfigureSyncer( 105 virtual void ConfigureSyncer(
90 ConfigureReason reason, 106 ConfigureReason reason,
91 const ModelTypeSet& types_to_config, 107 const ModelTypeSet& types_to_config,
92 const ModelSafeRoutingInfo& new_routing_info, 108 const ModelSafeRoutingInfo& new_routing_info,
93 const base::Closure& ready_task, 109 const base::Closure& ready_task,
94 const base::Closure& retry_task) OVERRIDE; 110 const base::Closure& retry_task) OVERRIDE;
95 virtual void AddObserver(Observer* observer) OVERRIDE; 111 virtual void AddObserver(Observer* observer) OVERRIDE;
96 virtual void RemoveObserver(Observer* observer) OVERRIDE; 112 virtual void RemoveObserver(Observer* observer) OVERRIDE;
97 virtual SyncStatus GetDetailedStatus() const OVERRIDE; 113 virtual SyncStatus GetDetailedStatus() const OVERRIDE;
98 virtual bool IsUsingExplicitPassphrase() OVERRIDE; 114 virtual bool IsUsingExplicitPassphrase() OVERRIDE;
99 virtual bool GetKeystoreKeyBootstrapToken(std::string* token) OVERRIDE; 115 virtual bool GetKeystoreKeyBootstrapToken(std::string* token) OVERRIDE;
100 virtual void SaveChanges() OVERRIDE; 116 virtual void SaveChanges() OVERRIDE;
101 virtual void StopSyncingForShutdown(const base::Closure& callback) OVERRIDE; 117 virtual void StopSyncingForShutdown(const base::Closure& callback) OVERRIDE;
102 virtual void ShutdownOnSyncThread() OVERRIDE; 118 virtual void ShutdownOnSyncThread() OVERRIDE;
103 virtual UserShare* GetUserShare() OVERRIDE; 119 virtual UserShare* GetUserShare() OVERRIDE;
104 virtual void RefreshNigori(const std::string& chrome_version, 120 virtual void RefreshNigori(const std::string& chrome_version,
105 const base::Closure& done_callback) OVERRIDE; 121 const base::Closure& done_callback) OVERRIDE;
106 virtual void EnableEncryptEverything() OVERRIDE; 122 virtual void EnableEncryptEverything() OVERRIDE;
107 virtual bool ReceivedExperiment(Experiments* experiments) OVERRIDE; 123 virtual bool ReceivedExperiment(Experiments* experiments) OVERRIDE;
108 virtual bool HasUnsyncedItems() OVERRIDE; 124 virtual bool HasUnsyncedItems() OVERRIDE;
109 125
110 private: 126 private:
127 void InvalidateOnSyncThread(
128 const ObjectIdPayloadMap& id_payloads,
msw 2012/08/03 05:14:21 nit: same suggestion to move this up a line and in
129 IncomingNotificationSource source);
130 void EnableNotificationsOnSyncThread();
131 void DisableNotificationsOnSyncThread(NotificationsDisabledReason reason);
132
133 scoped_refptr<base::SequencedTaskRunner> sync_task_runner_;
134
111 ObserverList<SyncManager::Observer> observers_; 135 ObserverList<SyncManager::Observer> observers_;
112 136
113 // Faked directory state. 137 // Faked directory state.
114 ModelTypeSet initial_sync_ended_types_; 138 ModelTypeSet initial_sync_ended_types_;
115 ModelTypeSet progress_marker_types_; 139 ModelTypeSet progress_marker_types_;
116 140
117 // Test specific state. 141 // Test specific state.
118 // The types that should fail configuration attempts. These types will not 142 // The types that should fail configuration attempts. These types will not
119 // have their progress markers or initial_sync_ended bits set. 143 // have their progress markers or initial_sync_ended bits set.
120 ModelTypeSet configure_fail_types_; 144 ModelTypeSet configure_fail_types_;
121 // The set of types that have been cleaned up. 145 // The set of types that have been cleaned up.
122 ModelTypeSet cleaned_types_; 146 ModelTypeSet cleaned_types_;
123 // The set of types that have been downloaded. 147 // The set of types that have been downloaded.
124 ModelTypeSet downloaded_types_; 148 ModelTypeSet downloaded_types_;
125 // The set of types that have been enabled. 149 // The set of types that have been enabled.
126 ModelTypeSet enabled_types_; 150 ModelTypeSet enabled_types_;
127 151
128 // For StopSyncingForShutdown's callback. 152 // Faked notifier state.
129 MessageLoop* sync_loop_; 153 SyncNotifierHelper notifier_helper_;
130 154
131 DISALLOW_COPY_AND_ASSIGN(FakeSyncManager); 155 DISALLOW_COPY_AND_ASSIGN(FakeSyncManager);
132 }; 156 };
133 157
134 } // namespace syncer 158 } // namespace syncer
135 159
136 #endif // SYNC_INTERNAL_API_PUBLIC_TEST_FAKE_SYNC_MANAGER_H_ 160 #endif // SYNC_INTERNAL_API_PUBLIC_TEST_FAKE_SYNC_MANAGER_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698