OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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/sync_rollback_manager_base.h" | 5 #include "sync/internal_api/sync_rollback_manager_base.h" |
6 | 6 |
7 #include "sync/internal_api/public/base/model_type.h" | 7 #include "sync/internal_api/public/base/model_type.h" |
8 #include "sync/internal_api/public/internal_components_factory.h" | 8 #include "sync/internal_api/public/internal_components_factory.h" |
9 #include "sync/internal_api/public/read_node.h" | 9 #include "sync/internal_api/public/read_node.h" |
10 #include "sync/internal_api/public/read_transaction.h" | 10 #include "sync/internal_api/public/read_transaction.h" |
11 #include "sync/internal_api/public/util/syncer_error.h" | |
12 #include "sync/internal_api/public/write_transaction.h" | 11 #include "sync/internal_api/public/write_transaction.h" |
13 #include "sync/syncable/directory_backing_store.h" | 12 #include "sync/syncable/directory_backing_store.h" |
14 #include "sync/syncable/mutable_entry.h" | 13 #include "sync/syncable/mutable_entry.h" |
15 | 14 |
16 namespace { | 15 namespace { |
17 | 16 |
18 // Permanent bookmark folders as defined in bookmark_model_associator.cc. | 17 // Permanent bookmark folders as defined in bookmark_model_associator.cc. |
19 const char kBookmarkBarTag[] = "bookmark_bar"; | 18 const char kBookmarkBarTag[] = "bookmark_bar"; |
20 const char kMobileBookmarksTag[] = "synced_bookmarks"; | 19 const char kMobileBookmarksTag[] = "synced_bookmarks"; |
21 const char kOtherBookmarksTag[] = "other_bookmarks"; | 20 const char kOtherBookmarksTag[] = "other_bookmarks"; |
22 | 21 |
| 22 class DummyEntryptionHandler : public syncer::SyncEncryptionHandler { |
| 23 virtual void AddObserver(Observer* observer) OVERRIDE {} |
| 24 virtual void RemoveObserver(Observer* observer) OVERRIDE {} |
| 25 virtual void Init() OVERRIDE {} |
| 26 virtual void SetEncryptionPassphrase(const std::string& passphrase, |
| 27 bool is_explicit) OVERRIDE {} |
| 28 virtual void SetDecryptionPassphrase(const std::string& passphrase) |
| 29 OVERRIDE {} |
| 30 virtual void EnableEncryptEverything() OVERRIDE {} |
| 31 virtual bool EncryptEverythingEnabled() const OVERRIDE { |
| 32 return false; |
| 33 } |
| 34 virtual syncer::PassphraseType GetPassphraseType() const OVERRIDE { |
| 35 return syncer::KEYSTORE_PASSPHRASE; |
| 36 } |
| 37 }; |
| 38 |
23 } // anonymous namespace | 39 } // anonymous namespace |
24 | 40 |
25 namespace syncer { | 41 namespace syncer { |
26 | 42 |
27 SyncRollbackManagerBase::SyncRollbackManagerBase() | 43 SyncRollbackManagerBase::SyncRollbackManagerBase() |
28 : report_unrecoverable_error_function_(NULL), | 44 : report_unrecoverable_error_function_(NULL), |
29 weak_ptr_factory_(this) { | 45 weak_ptr_factory_(this), |
| 46 dummy_handler_(new DummyEntryptionHandler) { |
30 } | 47 } |
31 | 48 |
32 SyncRollbackManagerBase::~SyncRollbackManagerBase() { | 49 SyncRollbackManagerBase::~SyncRollbackManagerBase() { |
33 } | 50 } |
34 | 51 |
35 void SyncRollbackManagerBase::Init( | 52 void SyncRollbackManagerBase::Init( |
36 const base::FilePath& database_location, | 53 const base::FilePath& database_location, |
37 const WeakHandle<JsEventHandler>& event_handler, | 54 const WeakHandle<JsEventHandler>& event_handler, |
38 const std::string& sync_server_and_path, | 55 const std::string& sync_server_and_path, |
39 int sync_server_port, | 56 int sync_server_port, |
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
78 return types; | 95 return types; |
79 } | 96 } |
80 | 97 |
81 bool SyncRollbackManagerBase::PurgePartiallySyncedTypes() { | 98 bool SyncRollbackManagerBase::PurgePartiallySyncedTypes() { |
82 NOTREACHED(); | 99 NOTREACHED(); |
83 return true; | 100 return true; |
84 } | 101 } |
85 | 102 |
86 void SyncRollbackManagerBase::UpdateCredentials( | 103 void SyncRollbackManagerBase::UpdateCredentials( |
87 const SyncCredentials& credentials) { | 104 const SyncCredentials& credentials) { |
88 NOTREACHED(); | |
89 } | 105 } |
90 | 106 |
91 void SyncRollbackManagerBase::StartSyncingNormally( | 107 void SyncRollbackManagerBase::StartSyncingNormally( |
92 const ModelSafeRoutingInfo& routing_info){ | 108 const ModelSafeRoutingInfo& routing_info){ |
93 } | 109 } |
94 | 110 |
95 void SyncRollbackManagerBase::ConfigureSyncer( | 111 void SyncRollbackManagerBase::ConfigureSyncer( |
96 ConfigureReason reason, | 112 ConfigureReason reason, |
97 ModelTypeSet to_download, | 113 ModelTypeSet to_download, |
98 ModelTypeSet to_purge, | 114 ModelTypeSet to_purge, |
99 ModelTypeSet to_journal, | 115 ModelTypeSet to_journal, |
100 ModelTypeSet to_unapply, | 116 ModelTypeSet to_unapply, |
101 const ModelSafeRoutingInfo& new_routing_info, | 117 const ModelSafeRoutingInfo& new_routing_info, |
102 const base::Closure& ready_task, | 118 const base::Closure& ready_task, |
103 const base::Closure& retry_task) { | 119 const base::Closure& retry_task) { |
104 DCHECK(to_purge.Empty()); | |
105 DCHECK(to_journal.Empty()); | |
106 DCHECK(to_unapply.Empty()); | |
107 for (ModelTypeSet::Iterator type = to_download.First(); | 120 for (ModelTypeSet::Iterator type = to_download.First(); |
108 type.Good(); type.Inc()) { | 121 type.Good(); type.Inc()) { |
109 if (InitTypeRootNode(type.Get())) { | 122 if (InitTypeRootNode(type.Get())) { |
110 if (type.Get() == BOOKMARKS) { | 123 if (type.Get() == BOOKMARKS) { |
111 InitBookmarkFolder(kBookmarkBarTag); | 124 InitBookmarkFolder(kBookmarkBarTag); |
112 InitBookmarkFolder(kMobileBookmarksTag); | 125 InitBookmarkFolder(kMobileBookmarksTag); |
113 InitBookmarkFolder(kOtherBookmarksTag); | 126 InitBookmarkFolder(kOtherBookmarksTag); |
114 } | 127 } |
115 } | 128 } |
116 } | 129 } |
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
162 } | 175 } |
163 | 176 |
164 bool SyncRollbackManagerBase::HasUnsyncedItems() { | 177 bool SyncRollbackManagerBase::HasUnsyncedItems() { |
165 ReadTransaction trans(FROM_HERE, &share_); | 178 ReadTransaction trans(FROM_HERE, &share_); |
166 syncable::Directory::Metahandles unsynced; | 179 syncable::Directory::Metahandles unsynced; |
167 share_.directory->GetUnsyncedMetaHandles(trans.GetWrappedTrans(), &unsynced); | 180 share_.directory->GetUnsyncedMetaHandles(trans.GetWrappedTrans(), &unsynced); |
168 return !unsynced.empty(); | 181 return !unsynced.empty(); |
169 } | 182 } |
170 | 183 |
171 SyncEncryptionHandler* SyncRollbackManagerBase::GetEncryptionHandler() { | 184 SyncEncryptionHandler* SyncRollbackManagerBase::GetEncryptionHandler() { |
172 return NULL; | 185 return dummy_handler_.get(); |
173 } | 186 } |
174 | 187 |
175 void SyncRollbackManagerBase::RefreshTypes(ModelTypeSet types) { | 188 void SyncRollbackManagerBase::RefreshTypes(ModelTypeSet types) { |
176 | 189 |
177 } | 190 } |
178 | 191 |
179 void SyncRollbackManagerBase::HandleTransactionCompleteChangeEvent( | 192 void SyncRollbackManagerBase::HandleTransactionCompleteChangeEvent( |
180 ModelTypeSet models_with_changes) { | 193 ModelTypeSet models_with_changes) { |
181 } | 194 } |
182 | 195 |
(...skipping 130 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
313 entry.PutNonUniqueName(folder); | 326 entry.PutNonUniqueName(folder); |
314 entry.PutIsDel(false); | 327 entry.PutIsDel(false); |
315 entry.PutIsDir(true); | 328 entry.PutIsDir(true); |
316 | 329 |
317 sync_pb::EntitySpecifics specifics; | 330 sync_pb::EntitySpecifics specifics; |
318 AddDefaultFieldValue(BOOKMARKS, &specifics); | 331 AddDefaultFieldValue(BOOKMARKS, &specifics); |
319 entry.PutSpecifics(specifics); | 332 entry.PutSpecifics(specifics); |
320 } | 333 } |
321 | 334 |
322 } // namespace syncer | 335 } // namespace syncer |
OLD | NEW |