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 1102 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1113 // modified to match. | 1113 // modified to match. |
1114 bool SessionModelAssociator::ShouldSyncTab(const SyncedTabDelegate& tab) const { | 1114 bool SessionModelAssociator::ShouldSyncTab(const SyncedTabDelegate& tab) const { |
1115 DCHECK(CalledOnValidThread()); | 1115 DCHECK(CalledOnValidThread()); |
1116 if (!IsValidTab(tab)) | 1116 if (!IsValidTab(tab)) |
1117 return false; | 1117 return false; |
1118 return TabHasValidEntry(tab); | 1118 return TabHasValidEntry(tab); |
1119 } | 1119 } |
1120 | 1120 |
1121 void SessionModelAssociator::QuitLoopForSubtleTesting() { | 1121 void SessionModelAssociator::QuitLoopForSubtleTesting() { |
1122 if (waiting_for_change_) { | 1122 if (waiting_for_change_) { |
1123 DVLOG(1) << "Quitting MessageLoop for test."; | 1123 DVLOG(1) << "Quitting base::MessageLoop for test."; |
1124 waiting_for_change_ = false; | 1124 waiting_for_change_ = false; |
1125 test_weak_factory_.InvalidateWeakPtrs(); | 1125 test_weak_factory_.InvalidateWeakPtrs(); |
1126 MessageLoop::current()->Quit(); | 1126 base::MessageLoop::current()->Quit(); |
1127 } | 1127 } |
1128 } | 1128 } |
1129 | 1129 |
1130 FaviconCache* SessionModelAssociator::GetFaviconCache() { | 1130 FaviconCache* SessionModelAssociator::GetFaviconCache() { |
1131 return &favicon_cache_; | 1131 return &favicon_cache_; |
1132 } | 1132 } |
1133 | 1133 |
1134 void SessionModelAssociator::BlockUntilLocalChangeForTest( | 1134 void SessionModelAssociator::BlockUntilLocalChangeForTest( |
1135 base::TimeDelta timeout) { | 1135 base::TimeDelta timeout) { |
1136 if (test_weak_factory_.HasWeakPtrs()) | 1136 if (test_weak_factory_.HasWeakPtrs()) |
1137 return; | 1137 return; |
1138 waiting_for_change_ = true; | 1138 waiting_for_change_ = true; |
1139 MessageLoop::current()->PostDelayedTask( | 1139 base::MessageLoop::current()->PostDelayedTask( |
1140 FROM_HERE, | 1140 FROM_HERE, |
1141 base::Bind(&SessionModelAssociator::QuitLoopForSubtleTesting, | 1141 base::Bind(&SessionModelAssociator::QuitLoopForSubtleTesting, |
1142 test_weak_factory_.GetWeakPtr()), | 1142 test_weak_factory_.GetWeakPtr()), |
1143 timeout); | 1143 timeout); |
1144 } | 1144 } |
1145 | 1145 |
1146 bool SessionModelAssociator::CryptoReadyIfNecessary() { | 1146 bool SessionModelAssociator::CryptoReadyIfNecessary() { |
1147 // We only access the cryptographer while holding a transaction. | 1147 // We only access the cryptographer while holding a transaction. |
1148 syncer::ReadTransaction trans(FROM_HERE, sync_service_->GetUserShare()); | 1148 syncer::ReadTransaction trans(FROM_HERE, sync_service_->GetUserShare()); |
1149 const syncer::ModelTypeSet encrypted_types = trans.GetEncryptedTypes(); | 1149 const syncer::ModelTypeSet encrypted_types = trans.GetEncryptedTypes(); |
1150 return !encrypted_types.Has(SESSIONS) || | 1150 return !encrypted_types.Has(SESSIONS) || |
1151 sync_service_->IsCryptographerReady(&trans); | 1151 sync_service_->IsCryptographerReady(&trans); |
1152 } | 1152 } |
1153 | 1153 |
1154 } // namespace browser_sync | 1154 } // namespace browser_sync |
OLD | NEW |