| 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 "build/build_config.h" | 5 #include "build/build_config.h" |
| 6 | 6 |
| 7 #include "chrome/browser/sync/glue/sync_backend_host.h" | 7 #include "chrome/browser/sync/glue/sync_backend_host.h" |
| 8 | 8 |
| 9 #include <algorithm> | 9 #include <algorithm> |
| 10 #include <map> | 10 #include <map> |
| (...skipping 135 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 146 void DoInitialize(const DoInitializeOptions& options); | 146 void DoInitialize(const DoInitializeOptions& options); |
| 147 | 147 |
| 148 // Called to perform credential update on behalf of | 148 // Called to perform credential update on behalf of |
| 149 // SyncBackendHost::UpdateCredentials. | 149 // SyncBackendHost::UpdateCredentials. |
| 150 void DoUpdateCredentials(const syncer::SyncCredentials& credentials); | 150 void DoUpdateCredentials(const syncer::SyncCredentials& credentials); |
| 151 | 151 |
| 152 // Called to update the given registered ids on behalf of | 152 // Called to update the given registered ids on behalf of |
| 153 // SyncBackendHost::UpdateRegisteredInvalidationIds. | 153 // SyncBackendHost::UpdateRegisteredInvalidationIds. |
| 154 void DoUpdateRegisteredInvalidationIds(const syncer::ObjectIdSet& ids); | 154 void DoUpdateRegisteredInvalidationIds(const syncer::ObjectIdSet& ids); |
| 155 | 155 |
| 156 // Called to acknowledge an invalidation on behalf of |
| 157 // SyncBackendHost::AcknowledgeInvalidation. |
| 158 void DoAcknowledgeInvalidation(const invalidation::ObjectId& id, |
| 159 const syncer::AckHandle& ack_handle); |
| 160 |
| 156 // Called to tell the syncapi to start syncing (generally after | 161 // Called to tell the syncapi to start syncing (generally after |
| 157 // initialization and authentication). | 162 // initialization and authentication). |
| 158 void DoStartSyncing(const syncer::ModelSafeRoutingInfo& routing_info); | 163 void DoStartSyncing(const syncer::ModelSafeRoutingInfo& routing_info); |
| 159 | 164 |
| 160 // Called to set the passphrase for encryption. | 165 // Called to set the passphrase for encryption. |
| 161 void DoSetEncryptionPassphrase(const std::string& passphrase, | 166 void DoSetEncryptionPassphrase(const std::string& passphrase, |
| 162 bool is_explicit); | 167 bool is_explicit); |
| 163 | 168 |
| 164 // Called to decrypt the pending keys. | 169 // Called to decrypt the pending keys. |
| 165 void DoSetDecryptionPassphrase(const std::string& passphrase); | 170 void DoSetDecryptionPassphrase(const std::string& passphrase); |
| (...skipping 304 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 470 | 475 |
| 471 void SyncBackendHost::UpdateRegisteredInvalidationIds( | 476 void SyncBackendHost::UpdateRegisteredInvalidationIds( |
| 472 const syncer::ObjectIdSet& ids) { | 477 const syncer::ObjectIdSet& ids) { |
| 473 DCHECK_EQ(MessageLoop::current(), frontend_loop_); | 478 DCHECK_EQ(MessageLoop::current(), frontend_loop_); |
| 474 DCHECK(sync_thread_.IsRunning()); | 479 DCHECK(sync_thread_.IsRunning()); |
| 475 sync_thread_.message_loop()->PostTask(FROM_HERE, | 480 sync_thread_.message_loop()->PostTask(FROM_HERE, |
| 476 base::Bind(&SyncBackendHost::Core::DoUpdateRegisteredInvalidationIds, | 481 base::Bind(&SyncBackendHost::Core::DoUpdateRegisteredInvalidationIds, |
| 477 core_.get(), ids)); | 482 core_.get(), ids)); |
| 478 } | 483 } |
| 479 | 484 |
| 485 void SyncBackendHost::AcknowledgeInvalidation( |
| 486 const invalidation::ObjectId& id, const syncer::AckHandle& ack_handle) { |
| 487 DCHECK_EQ(MessageLoop::current(), frontend_loop_); |
| 488 DCHECK(sync_thread_.IsRunning()); |
| 489 sync_thread_.message_loop()->PostTask(FROM_HERE, |
| 490 base::Bind(&SyncBackendHost::Core::DoAcknowledgeInvalidation, |
| 491 core_.get(), id, ack_handle)); |
| 492 } |
| 493 |
| 480 void SyncBackendHost::StartSyncingWithServer() { | 494 void SyncBackendHost::StartSyncingWithServer() { |
| 481 SDVLOG(1) << "SyncBackendHost::StartSyncingWithServer called."; | 495 SDVLOG(1) << "SyncBackendHost::StartSyncingWithServer called."; |
| 482 | 496 |
| 483 syncer::ModelSafeRoutingInfo routing_info; | 497 syncer::ModelSafeRoutingInfo routing_info; |
| 484 registrar_->GetModelSafeRoutingInfo(&routing_info); | 498 registrar_->GetModelSafeRoutingInfo(&routing_info); |
| 485 | 499 |
| 486 sync_thread_.message_loop()->PostTask(FROM_HERE, | 500 sync_thread_.message_loop()->PostTask(FROM_HERE, |
| 487 base::Bind(&SyncBackendHost::Core::DoStartSyncing, | 501 base::Bind(&SyncBackendHost::Core::DoStartSyncing, |
| 488 core_.get(), routing_info)); | 502 core_.get(), routing_info)); |
| 489 } | 503 } |
| (...skipping 741 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1231 // |sync_manager_| may end up being NULL here in tests (in | 1245 // |sync_manager_| may end up being NULL here in tests (in |
| 1232 // synchronous initialization mode) since this is called during | 1246 // synchronous initialization mode) since this is called during |
| 1233 // shutdown. | 1247 // shutdown. |
| 1234 // | 1248 // |
| 1235 // TODO(akalin): Fix this behavior (see http://crbug.com/140354). | 1249 // TODO(akalin): Fix this behavior (see http://crbug.com/140354). |
| 1236 if (sync_manager_.get()) { | 1250 if (sync_manager_.get()) { |
| 1237 sync_manager_->UpdateRegisteredInvalidationIds(this, ids); | 1251 sync_manager_->UpdateRegisteredInvalidationIds(this, ids); |
| 1238 } | 1252 } |
| 1239 } | 1253 } |
| 1240 | 1254 |
| 1255 void SyncBackendHost::Core::DoAcknowledgeInvalidation( |
| 1256 const invalidation::ObjectId& id, const syncer::AckHandle& ack_handle) { |
| 1257 DCHECK_EQ(MessageLoop::current(), sync_loop_); |
| 1258 // |sync_manager_| may end up being NULL here in tests (in |
| 1259 // synchronous initialization mode). |
| 1260 // |
| 1261 // TODO(akalin): Fix this behavior (see http://crbug.com/140354). |
| 1262 if (sync_manager_.get()) { |
| 1263 sync_manager_->AcknowledgeInvalidation(id, ack_handle); |
| 1264 } |
| 1265 } |
| 1266 |
| 1241 void SyncBackendHost::Core::DoStartSyncing( | 1267 void SyncBackendHost::Core::DoStartSyncing( |
| 1242 const syncer::ModelSafeRoutingInfo& routing_info) { | 1268 const syncer::ModelSafeRoutingInfo& routing_info) { |
| 1243 DCHECK_EQ(MessageLoop::current(), sync_loop_); | 1269 DCHECK_EQ(MessageLoop::current(), sync_loop_); |
| 1244 sync_manager_->StartSyncingNormally(routing_info); | 1270 sync_manager_->StartSyncingNormally(routing_info); |
| 1245 } | 1271 } |
| 1246 | 1272 |
| 1247 void SyncBackendHost::Core::DoSetEncryptionPassphrase( | 1273 void SyncBackendHost::Core::DoSetEncryptionPassphrase( |
| 1248 const std::string& passphrase, | 1274 const std::string& passphrase, |
| 1249 bool is_explicit) { | 1275 bool is_explicit) { |
| 1250 DCHECK_EQ(MessageLoop::current(), sync_loop_); | 1276 DCHECK_EQ(MessageLoop::current(), sync_loop_); |
| (...skipping 381 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1632 DVLOG(1) << "Connection status changed: " | 1658 DVLOG(1) << "Connection status changed: " |
| 1633 << syncer::ConnectionStatusToString(status); | 1659 << syncer::ConnectionStatusToString(status); |
| 1634 frontend_->OnConnectionStatusChange(status); | 1660 frontend_->OnConnectionStatusChange(status); |
| 1635 } | 1661 } |
| 1636 | 1662 |
| 1637 #undef SDVLOG | 1663 #undef SDVLOG |
| 1638 | 1664 |
| 1639 #undef SLOG | 1665 #undef SLOG |
| 1640 | 1666 |
| 1641 } // namespace browser_sync | 1667 } // namespace browser_sync |
| OLD | NEW |