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 #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 "base/message_loop.h" | 7 #include "base/message_loop.h" |
8 #include "sync/internal_api/public/http_post_provider_factory.h" | 8 #include "sync/internal_api/public/http_post_provider_factory.h" |
9 #include "sync/internal_api/public/util/weak_handle.h" | 9 #include "sync/internal_api/public/util/weak_handle.h" |
10 #include "sync/notifier/sync_notifier.h" | 10 #include "sync/notifier/sync_notifier.h" |
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
44 } | 44 } |
45 | 45 |
46 bool FakeSyncManager::Init( | 46 bool FakeSyncManager::Init( |
47 const FilePath& database_location, | 47 const FilePath& database_location, |
48 const syncer::WeakHandle<syncer::JsEventHandler>& event_handler, | 48 const syncer::WeakHandle<syncer::JsEventHandler>& event_handler, |
49 const std::string& sync_server_and_path, | 49 const std::string& sync_server_and_path, |
50 int sync_server_port, | 50 int sync_server_port, |
51 bool use_ssl, | 51 bool use_ssl, |
52 const scoped_refptr<base::TaskRunner>& blocking_task_runner, | 52 const scoped_refptr<base::TaskRunner>& blocking_task_runner, |
53 scoped_ptr<HttpPostProviderFactory> post_factory, | 53 scoped_ptr<HttpPostProviderFactory> post_factory, |
54 const syncer::ModelSafeRoutingInfo& model_safe_routing_info, | |
55 const std::vector<syncer::ModelSafeWorker*>& workers, | 54 const std::vector<syncer::ModelSafeWorker*>& workers, |
56 syncer::ExtensionsActivityMonitor* extensions_activity_monitor, | 55 syncer::ExtensionsActivityMonitor* extensions_activity_monitor, |
57 ChangeDelegate* change_delegate, | 56 ChangeDelegate* change_delegate, |
58 const SyncCredentials& credentials, | 57 const SyncCredentials& credentials, |
59 scoped_ptr<syncer::SyncNotifier> sync_notifier, | 58 scoped_ptr<syncer::SyncNotifier> sync_notifier, |
60 const std::string& restored_key_for_bootstrapping, | 59 const std::string& restored_key_for_bootstrapping, |
61 TestingMode testing_mode, | 60 TestingMode testing_mode, |
62 syncer::Encryptor* encryptor, | 61 syncer::Encryptor* encryptor, |
63 syncer::UnrecoverableErrorHandler* unrecoverable_error_handler, | 62 syncer::UnrecoverableErrorHandler* unrecoverable_error_handler, |
64 syncer::ReportUnrecoverableErrorFunction | 63 syncer::ReportUnrecoverableErrorFunction |
65 report_unrecoverable_error_function) { | 64 report_unrecoverable_error_function) { |
66 sync_loop_ = MessageLoop::current(); | 65 sync_loop_ = MessageLoop::current(); |
67 PurgePartiallySyncedTypes(); | 66 PurgePartiallySyncedTypes(); |
68 FOR_EACH_OBSERVER(SyncManager::Observer, observers_, | 67 FOR_EACH_OBSERVER(SyncManager::Observer, observers_, |
69 OnInitializationComplete( | 68 OnInitializationComplete( |
70 syncer::WeakHandle<syncer::JsBackend>(), | 69 syncer::WeakHandle<syncer::JsBackend>(), |
71 true)); | 70 true, initial_sync_ended_types_)); |
72 return true; | 71 return true; |
73 } | 72 } |
74 | 73 |
75 void FakeSyncManager::ThrowUnrecoverableError() { | 74 void FakeSyncManager::ThrowUnrecoverableError() { |
76 NOTIMPLEMENTED(); | 75 NOTIMPLEMENTED(); |
77 } | 76 } |
78 | 77 |
79 syncer::ModelTypeSet FakeSyncManager::InitialSyncEndedTypes() { | 78 syncer::ModelTypeSet FakeSyncManager::InitialSyncEndedTypes() { |
80 return initial_sync_ended_types_; | 79 return initial_sync_ended_types_; |
81 } | 80 } |
82 | 81 |
83 syncer::ModelTypeSet FakeSyncManager::GetTypesWithEmptyProgressMarkerToken( | 82 syncer::ModelTypeSet FakeSyncManager::GetTypesWithEmptyProgressMarkerToken( |
84 syncer::ModelTypeSet types) { | 83 syncer::ModelTypeSet types) { |
85 syncer::ModelTypeSet empty_types = types; | 84 syncer::ModelTypeSet empty_types = types; |
86 empty_types.RemoveAll(progress_marker_types_); | 85 empty_types.RemoveAll(progress_marker_types_); |
87 return empty_types; | 86 return empty_types; |
88 } | 87 } |
89 | 88 |
90 bool FakeSyncManager::PurgePartiallySyncedTypes() { | 89 bool FakeSyncManager::PurgePartiallySyncedTypes() { |
91 ModelTypeSet partial_types; | 90 ModelTypeSet partial_types; |
92 for (syncer::ModelTypeSet::Iterator i = progress_marker_types_.First(); | 91 for (syncer::ModelTypeSet::Iterator i = progress_marker_types_.First(); |
93 i.Good(); i.Inc()) { | 92 i.Good(); i.Inc()) { |
94 if (!initial_sync_ended_types_.Has(i.Get())) | 93 if (!initial_sync_ended_types_.Has(i.Get())) |
95 partial_types.Put(i.Get()); | 94 partial_types.Put(i.Get()); |
96 } | 95 } |
97 progress_marker_types_.RemoveAll(partial_types); | 96 progress_marker_types_.RemoveAll(partial_types); |
| 97 cleaned_types_.PutAll(partial_types); |
98 return true; | 98 return true; |
99 } | 99 } |
100 | 100 |
101 void FakeSyncManager::UpdateCredentials(const SyncCredentials& credentials) { | 101 void FakeSyncManager::UpdateCredentials(const SyncCredentials& credentials) { |
102 NOTIMPLEMENTED(); | 102 NOTIMPLEMENTED(); |
103 } | 103 } |
104 | 104 |
105 void FakeSyncManager::UpdateEnabledTypes(const syncer::ModelTypeSet& types) { | 105 void FakeSyncManager::UpdateEnabledTypes(const syncer::ModelTypeSet& types) { |
106 // Do nothing. | 106 // Do nothing. |
107 } | 107 } |
(...skipping 94 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
202 return false; | 202 return false; |
203 } | 203 } |
204 | 204 |
205 bool FakeSyncManager::HasUnsyncedItems() const { | 205 bool FakeSyncManager::HasUnsyncedItems() const { |
206 NOTIMPLEMENTED(); | 206 NOTIMPLEMENTED(); |
207 return false; | 207 return false; |
208 } | 208 } |
209 | 209 |
210 } // namespace syncer | 210 } // namespace syncer |
211 | 211 |
OLD | NEW |