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

Side by Side Diff: chrome/browser/sync/glue/session_model_associator.cc

Issue 12253010: [sync] Fix deadlock in SessionModelAssociator for Android. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Added comment explaining why we moved it out of the block Created 7 years, 10 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
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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
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
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 // We need to delete foreign sessions after giving up our
683 // syncer::WriteTransaction, since DeleteForeignSession(std::string&) uses
684 // its own syncer::WriteTransaction.
685 if (current_machine_tag_.compare(transaction_tag) != 0)
686 DeleteForeignSession(transaction_tag);
687 #endif
680 688
681 // Check if anything has changed on the client side. 689 // Check if anything has changed on the client side.
682 if (!UpdateSyncModelDataFromClient(&error)) { 690 if (!UpdateSyncModelDataFromClient(&error)) {
683 DCHECK(error.IsSet()); 691 DCHECK(error.IsSet());
684 return error; 692 return error;
685 } 693 }
686 694
687 DVLOG(1) << "Session models associated."; 695 DVLOG(1) << "Session models associated.";
688 DCHECK(!error.IsSet()); 696 DCHECK(!error.IsSet());
689 return error; 697 return error;
(...skipping 555 matching lines...) Expand 10 before | Expand all | Expand 10 after
1245 1253
1246 bool SessionModelAssociator::CryptoReadyIfNecessary() { 1254 bool SessionModelAssociator::CryptoReadyIfNecessary() {
1247 // We only access the cryptographer while holding a transaction. 1255 // We only access the cryptographer while holding a transaction.
1248 syncer::ReadTransaction trans(FROM_HERE, sync_service_->GetUserShare()); 1256 syncer::ReadTransaction trans(FROM_HERE, sync_service_->GetUserShare());
1249 const syncer::ModelTypeSet encrypted_types = trans.GetEncryptedTypes(); 1257 const syncer::ModelTypeSet encrypted_types = trans.GetEncryptedTypes();
1250 return !encrypted_types.Has(SESSIONS) || 1258 return !encrypted_types.Has(SESSIONS) ||
1251 sync_service_->IsCryptographerReady(&trans); 1259 sync_service_->IsCryptographerReady(&trans);
1252 } 1260 }
1253 1261
1254 } // namespace browser_sync 1262 } // namespace browser_sync
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698