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 219 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
230 sync_pb::SessionWindow_BrowserType_TYPE_POPUP); | 230 sync_pb::SessionWindow_BrowserType_TYPE_POPUP); |
231 } | 231 } |
232 | 232 |
233 // Store the order of tabs. | 233 // Store the order of tabs. |
234 bool found_tabs = false; | 234 bool found_tabs = false; |
235 for (int j = 0; j < (*i)->GetTabCount(); ++j) { | 235 for (int j = 0; j < (*i)->GetTabCount(); ++j) { |
236 SessionID::id_type tab_id = (*i)->GetTabIdAt(j); | 236 SessionID::id_type tab_id = (*i)->GetTabIdAt(j); |
237 | 237 |
238 if (reload_tabs) { | 238 if (reload_tabs) { |
239 SyncedTabDelegate* tab = (*i)->GetTabAt(j); | 239 SyncedTabDelegate* tab = (*i)->GetTabAt(j); |
240 // It's possible for GetTabAt to return a null tab if it's not in | 240 // It's possible for GetTabAt to return a null tab or a tab which has |
241 // memory. We can assume this means the tab already existed but hasn't | 241 // no web contents. We can assume this means the tab already existed |
242 // changed, so no need to reassociate. | 242 // but hasn't changed, so no need to reassociate. |
243 if (tab && !AssociateTab(*tab, error)) { | 243 if (tab && tab->HasWebContents() && !AssociateTab(*tab, error)) { |
Yaron
2013/05/21 18:32:07
I believe the existence-check for tab was purely f
shashi
2013/05/21 23:11:21
Done.
| |
244 // Association failed. Either we need to re-associate, or this is an | 244 // Association failed. Either we need to re-associate, or this is an |
245 // unrecoverable error. | 245 // unrecoverable error. |
246 return false; | 246 return false; |
247 } | 247 } |
248 } | 248 } |
249 | 249 |
250 // If the tab is valid, it would have been added to the tracker either | 250 // If the tab is valid, it would have been added to the tracker either |
251 // by the above AssociateTab call (at association time), or by the | 251 // by the above AssociateTab call (at association time), or by the |
252 // change processor calling AssociateTab for all modified tabs. | 252 // change processor calling AssociateTab for all modified tabs. |
253 // Therefore, we can key whether this window has valid tabs based on | 253 // Therefore, we can key whether this window has valid tabs based on |
(...skipping 907 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1161 | 1161 |
1162 bool SessionModelAssociator::CryptoReadyIfNecessary() { | 1162 bool SessionModelAssociator::CryptoReadyIfNecessary() { |
1163 // We only access the cryptographer while holding a transaction. | 1163 // We only access the cryptographer while holding a transaction. |
1164 syncer::ReadTransaction trans(FROM_HERE, sync_service_->GetUserShare()); | 1164 syncer::ReadTransaction trans(FROM_HERE, sync_service_->GetUserShare()); |
1165 const syncer::ModelTypeSet encrypted_types = trans.GetEncryptedTypes(); | 1165 const syncer::ModelTypeSet encrypted_types = trans.GetEncryptedTypes(); |
1166 return !encrypted_types.Has(SESSIONS) || | 1166 return !encrypted_types.Has(SESSIONS) || |
1167 sync_service_->IsCryptographerReady(&trans); | 1167 sync_service_->IsCryptographerReady(&trans); |
1168 } | 1168 } |
1169 | 1169 |
1170 } // namespace browser_sync | 1170 } // namespace browser_sync |
OLD | NEW |