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

Side by Side Diff: sync/internal_api/test/fake_sync_manager.cc

Issue 10824161: [Sync] Avoid unregistering object IDs on shutdown (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 #include "sync/internal_api/public/test/fake_sync_manager.h" 5 #include "sync/internal_api/public/test/fake_sync_manager.h"
6 6
7 #include <cstddef> 7 #include <cstddef>
8 8
9 #include "base/bind.h" 9 #include "base/bind.h"
10 #include "base/location.h" 10 #include "base/location.h"
11 #include "base/logging.h" 11 #include "base/logging.h"
12 #include "base/run_loop.h"
12 #include "base/sequenced_task_runner.h" 13 #include "base/sequenced_task_runner.h"
13 #include "base/single_thread_task_runner.h" 14 #include "base/single_thread_task_runner.h"
14 #include "base/thread_task_runner_handle.h" 15 #include "base/thread_task_runner_handle.h"
15 #include "sync/internal_api/public/http_post_provider_factory.h" 16 #include "sync/internal_api/public/http_post_provider_factory.h"
16 #include "sync/internal_api/public/internal_components_factory.h" 17 #include "sync/internal_api/public/internal_components_factory.h"
17 #include "sync/internal_api/public/util/weak_handle.h" 18 #include "sync/internal_api/public/util/weak_handle.h"
18 #include "sync/notifier/notifications_disabled_reason.h" 19 #include "sync/notifier/notifications_disabled_reason.h"
19 #include "sync/notifier/object_id_payload_map.h" 20 #include "sync/notifier/object_id_payload_map.h"
20 #include "sync/notifier/sync_notifier.h" 21 #include "sync/notifier/sync_notifier.h"
21 22
22 namespace syncer { 23 namespace syncer {
23 24
24 FakeSyncManager::FakeSyncManager() {} 25 FakeSyncManager::FakeSyncManager(ModelTypeSet initial_sync_ended_types,
26 ModelTypeSet progress_marker_types,
27 ModelTypeSet configure_fail_types) :
28 initial_sync_ended_types_(initial_sync_ended_types),
29 progress_marker_types_(progress_marker_types),
30 configure_fail_types_(configure_fail_types) {}
25 31
26 FakeSyncManager::~FakeSyncManager() {} 32 FakeSyncManager::~FakeSyncManager() {}
27 33
28 void FakeSyncManager::set_initial_sync_ended_types(ModelTypeSet types) {
29 initial_sync_ended_types_ = types;
30 }
31
32 void FakeSyncManager::set_progress_marker_types(ModelTypeSet types) {
33 progress_marker_types_ = types;
34 }
35
36 void FakeSyncManager::set_configure_fail_types(ModelTypeSet types) {
37 configure_fail_types_ = types;
38 }
39
40 ModelTypeSet FakeSyncManager::GetAndResetCleanedTypes() { 34 ModelTypeSet FakeSyncManager::GetAndResetCleanedTypes() {
41 ModelTypeSet cleaned_types = cleaned_types_; 35 ModelTypeSet cleaned_types = cleaned_types_;
42 cleaned_types_.Clear(); 36 cleaned_types_.Clear();
43 return cleaned_types; 37 return cleaned_types;
44 } 38 }
45 39
46 ModelTypeSet FakeSyncManager::GetAndResetDownloadedTypes() { 40 ModelTypeSet FakeSyncManager::GetAndResetDownloadedTypes() {
47 ModelTypeSet downloaded_types = downloaded_types_; 41 ModelTypeSet downloaded_types = downloaded_types_;
48 downloaded_types_.Clear(); 42 downloaded_types_.Clear();
49 return downloaded_types; 43 return downloaded_types;
(...skipping 28 matching lines...) Expand all
78 void FakeSyncManager::DisableNotifications( 72 void FakeSyncManager::DisableNotifications(
79 NotificationsDisabledReason reason) { 73 NotificationsDisabledReason reason) {
80 if (!sync_task_runner_->PostTask( 74 if (!sync_task_runner_->PostTask(
81 FROM_HERE, 75 FROM_HERE,
82 base::Bind(&FakeSyncManager::DisableNotificationsOnSyncThread, 76 base::Bind(&FakeSyncManager::DisableNotificationsOnSyncThread,
83 base::Unretained(this), reason))) { 77 base::Unretained(this), reason))) {
84 NOTREACHED(); 78 NOTREACHED();
85 } 79 }
86 } 80 }
87 81
82 namespace {
83
84 void DoNothing() {}
85
86 } // namespace
87
88 void FakeSyncManager::WaitForSyncThread() {
msw 2012/08/03 23:30:46 What is this doing? Add a comment as to why this i
akalin 2012/08/07 07:25:19 Done.
89 base::RunLoop run_loop;
90 if (!sync_task_runner_->PostTaskAndReply(
91 FROM_HERE,
92 base::Bind(&DoNothing),
93 run_loop.QuitClosure())) {
94 NOTREACHED();
95 }
96 run_loop.Run();
97 }
98
88 bool FakeSyncManager::Init( 99 bool FakeSyncManager::Init(
89 const FilePath& database_location, 100 const FilePath& database_location,
90 const WeakHandle<JsEventHandler>& event_handler, 101 const WeakHandle<JsEventHandler>& event_handler,
91 const std::string& sync_server_and_path, 102 const std::string& sync_server_and_path,
92 int sync_server_port, 103 int sync_server_port,
93 bool use_ssl, 104 bool use_ssl,
94 const scoped_refptr<base::TaskRunner>& blocking_task_runner, 105 const scoped_refptr<base::TaskRunner>& blocking_task_runner,
95 scoped_ptr<HttpPostProviderFactory> post_factory, 106 scoped_ptr<HttpPostProviderFactory> post_factory,
96 const std::vector<ModelSafeWorker*>& workers, 107 const std::vector<ModelSafeWorker*>& workers,
97 ExtensionsActivityMonitor* extensions_activity_monitor, 108 ExtensionsActivityMonitor* extensions_activity_monitor,
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after
143 } 154 }
144 155
145 void FakeSyncManager::UpdateCredentials(const SyncCredentials& credentials) { 156 void FakeSyncManager::UpdateCredentials(const SyncCredentials& credentials) {
146 NOTIMPLEMENTED(); 157 NOTIMPLEMENTED();
147 } 158 }
148 159
149 void FakeSyncManager::UpdateEnabledTypes(const ModelTypeSet& types) { 160 void FakeSyncManager::UpdateEnabledTypes(const ModelTypeSet& types) {
150 enabled_types_ = types; 161 enabled_types_ = types;
151 } 162 }
152 163
164 void FakeSyncManager::SetInvalidationHandler(
165 const std::string& handler_name, SyncNotifierObserver* handler) {
msw 2012/08/03 23:30:46 one param per line
akalin 2012/08/07 07:25:19 Done.
166 notifier_helper_.SetHandler(handler_name, handler);
167 }
168
153 void FakeSyncManager::UpdateRegisteredInvalidationIds( 169 void FakeSyncManager::UpdateRegisteredInvalidationIds(
154 SyncNotifierObserver* handler, const ObjectIdSet& ids) { 170 const std::string& handler_name, const ObjectIdSet& ids) {
msw 2012/08/03 23:30:46 one param per line
akalin 2012/08/07 07:25:19 Done.
155 notifier_helper_.UpdateRegisteredIds(handler, ids); 171 notifier_helper_.UpdateRegisteredIds(handler_name, ids);
156 } 172 }
157 173
158 void FakeSyncManager::StartSyncingNormally( 174 void FakeSyncManager::StartSyncingNormally(
159 const ModelSafeRoutingInfo& routing_info) { 175 const ModelSafeRoutingInfo& routing_info) {
160 // Do nothing. 176 // Do nothing.
161 } 177 }
162 178
163 void FakeSyncManager::SetEncryptionPassphrase(const std::string& passphrase, 179 void FakeSyncManager::SetEncryptionPassphrase(const std::string& passphrase,
164 bool is_explicit) { 180 bool is_explicit) {
165 NOTIMPLEMENTED(); 181 NOTIMPLEMENTED();
(...skipping 107 matching lines...) Expand 10 before | Expand all | Expand 10 after
273 notifier_helper_.EmitOnNotificationsEnabled(); 289 notifier_helper_.EmitOnNotificationsEnabled();
274 } 290 }
275 291
276 void FakeSyncManager::DisableNotificationsOnSyncThread( 292 void FakeSyncManager::DisableNotificationsOnSyncThread(
277 NotificationsDisabledReason reason) { 293 NotificationsDisabledReason reason) {
278 DCHECK(sync_task_runner_->RunsTasksOnCurrentThread()); 294 DCHECK(sync_task_runner_->RunsTasksOnCurrentThread());
279 notifier_helper_.EmitOnNotificationsDisabled(reason); 295 notifier_helper_.EmitOnNotificationsDisabled(reason);
280 } 296 }
281 297
282 } // namespace syncer 298 } // namespace syncer
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698