Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright 2012 The Chromium Authors. All rights reserved. | 1 // Copyright 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 "chrome/browser/sync/glue/session_model_associator.h" | 5 #include "chrome/browser/sync/glue/session_model_associator.h" |
| 6 | 6 |
| 7 #include <algorithm> | 7 #include <algorithm> |
| 8 #include <set> | 8 #include <set> |
| 9 #include <utility> | 9 #include <utility> |
| 10 | 10 |
| (...skipping 595 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 606 syncer::SyncError error; | 606 syncer::SyncError error; |
| 607 | 607 |
| 608 // Ensure that we disassociated properly, otherwise memory might leak. | 608 // Ensure that we disassociated properly, otherwise memory might leak. |
| 609 DCHECK(synced_session_tracker_.Empty()); | 609 DCHECK(synced_session_tracker_.Empty()); |
| 610 DCHECK_EQ(0U, tab_pool_.capacity()); | 610 DCHECK_EQ(0U, tab_pool_.capacity()); |
| 611 | 611 |
| 612 local_session_syncid_ = syncer::kInvalidId; | 612 local_session_syncid_ = syncer::kInvalidId; |
| 613 | 613 |
| 614 scoped_ptr<DeviceInfo> local_device_info(sync_service_->GetLocalDeviceInfo()); | 614 scoped_ptr<DeviceInfo> local_device_info(sync_service_->GetLocalDeviceInfo()); |
| 615 | 615 |
| 616 #if defined(OS_ANDROID) | |
| 617 std::string transaction_tag; | |
| 618 #endif | |
| 616 // Read any available foreign sessions and load any session data we may have. | 619 // Read any available foreign sessions and load any session data we may have. |
| 617 // If we don't have any local session data in the db, create a header node. | 620 // If we don't have any local session data in the db, create a header node. |
| 618 { | 621 { |
| 619 syncer::WriteTransaction trans(FROM_HERE, sync_service_->GetUserShare()); | 622 syncer::WriteTransaction trans(FROM_HERE, sync_service_->GetUserShare()); |
| 620 | 623 |
| 621 syncer::ReadNode root(&trans); | 624 syncer::ReadNode root(&trans); |
| 622 if (root.InitByTagLookup(syncer::ModelTypeToRootTag(model_type())) != | 625 if (root.InitByTagLookup(syncer::ModelTypeToRootTag(model_type())) != |
| 623 syncer::BaseNode::INIT_OK) { | 626 syncer::BaseNode::INIT_OK) { |
| 624 return error_handler_->CreateAndUploadError( | 627 return error_handler_->CreateAndUploadError( |
| 625 FROM_HERE, | 628 FROM_HERE, |
| (...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 665 sync_pb::SessionSpecifics base_specifics; | 668 sync_pb::SessionSpecifics base_specifics; |
| 666 base_specifics.set_session_tag(current_machine_tag_); | 669 base_specifics.set_session_tag(current_machine_tag_); |
| 667 sync_pb::SessionHeader* header_s = base_specifics.mutable_header(); | 670 sync_pb::SessionHeader* header_s = base_specifics.mutable_header(); |
| 668 header_s->set_client_name(current_session_name_); | 671 header_s->set_client_name(current_session_name_); |
| 669 header_s->set_device_type(DeviceInfo::GetLocalDeviceType()); | 672 header_s->set_device_type(DeviceInfo::GetLocalDeviceType()); |
| 670 write_node.SetSessionSpecifics(base_specifics); | 673 write_node.SetSessionSpecifics(base_specifics); |
| 671 | 674 |
| 672 local_session_syncid_ = write_node.GetId(); | 675 local_session_syncid_ = write_node.GetId(); |
| 673 } | 676 } |
| 674 #if defined(OS_ANDROID) | 677 #if defined(OS_ANDROID) |
| 675 std::string transaction_tag = GetMachineTagFromTransaction(&trans); | 678 transaction_tag = GetMachineTagFromTransaction(&trans); |
| 676 if (current_machine_tag_.compare(transaction_tag) != 0) | |
| 677 DeleteForeignSession(transaction_tag); | |
| 678 #endif | 679 #endif |
| 679 } | 680 } |
| 681 #if defined(OS_ANDROID) | |
| 682 if (current_machine_tag_.compare(transaction_tag) != 0) | |
|
Yaron
2013/02/13 21:01:47
While I'm not excited about add a comment about im
| |
| 683 DeleteForeignSession(transaction_tag); | |
| 684 #endif | |
| 680 | 685 |
| 681 // Check if anything has changed on the client side. | 686 // Check if anything has changed on the client side. |
| 682 if (!UpdateSyncModelDataFromClient(&error)) { | 687 if (!UpdateSyncModelDataFromClient(&error)) { |
| 683 DCHECK(error.IsSet()); | 688 DCHECK(error.IsSet()); |
| 684 return error; | 689 return error; |
| 685 } | 690 } |
| 686 | 691 |
| 687 DVLOG(1) << "Session models associated."; | 692 DVLOG(1) << "Session models associated."; |
| 688 DCHECK(!error.IsSet()); | 693 DCHECK(!error.IsSet()); |
| 689 return error; | 694 return error; |
| (...skipping 555 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1245 | 1250 |
| 1246 bool SessionModelAssociator::CryptoReadyIfNecessary() { | 1251 bool SessionModelAssociator::CryptoReadyIfNecessary() { |
| 1247 // We only access the cryptographer while holding a transaction. | 1252 // We only access the cryptographer while holding a transaction. |
| 1248 syncer::ReadTransaction trans(FROM_HERE, sync_service_->GetUserShare()); | 1253 syncer::ReadTransaction trans(FROM_HERE, sync_service_->GetUserShare()); |
| 1249 const syncer::ModelTypeSet encrypted_types = trans.GetEncryptedTypes(); | 1254 const syncer::ModelTypeSet encrypted_types = trans.GetEncryptedTypes(); |
| 1250 return !encrypted_types.Has(SESSIONS) || | 1255 return !encrypted_types.Has(SESSIONS) || |
| 1251 sync_service_->IsCryptographerReady(&trans); | 1256 sync_service_->IsCryptographerReady(&trans); |
| 1252 } | 1257 } |
| 1253 | 1258 |
| 1254 } // namespace browser_sync | 1259 } // namespace browser_sync |
| OLD | NEW |