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 "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 449 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
460 current_index - kMaxSyncNavigationCount); | 460 current_index - kMaxSyncNavigationCount); |
461 const int max_index = std::min(current_index + kMaxSyncNavigationCount, | 461 const int max_index = std::min(current_index + kMaxSyncNavigationCount, |
462 new_tab.GetEntryCount()); | 462 new_tab.GetEntryCount()); |
463 const int pending_index = new_tab.GetPendingEntryIndex(); | 463 const int pending_index = new_tab.GetPendingEntryIndex(); |
464 sync_tab->set_pinned(window.IsTabPinned(&new_tab)); | 464 sync_tab->set_pinned(window.IsTabPinned(&new_tab)); |
465 if (new_tab.HasExtensionAppId()) { | 465 if (new_tab.HasExtensionAppId()) { |
466 sync_tab->set_extension_app_id(new_tab.GetExtensionAppId()); | 466 sync_tab->set_extension_app_id(new_tab.GetExtensionAppId()); |
467 } | 467 } |
468 | 468 |
469 sync_tab->mutable_navigation()->Clear(); | 469 sync_tab->mutable_navigation()->Clear(); |
470 std::vector<SyncedTabNavigation>::const_iterator prev_nav_iter; | 470 std::vector<SyncedTabNavigation>::const_iterator prev_nav_iter = |
| 471 prev_tab->synced_tab_navigations.begin(); |
471 for (int i = min_index; i < max_index; ++i) { | 472 for (int i = min_index; i < max_index; ++i) { |
472 const NavigationEntry* entry = (i == pending_index) ? | 473 const NavigationEntry* entry = (i == pending_index) ? |
473 new_tab.GetPendingEntry() : new_tab.GetEntryAtIndex(i); | 474 new_tab.GetPendingEntry() : new_tab.GetEntryAtIndex(i); |
474 DCHECK(entry); | 475 DCHECK(entry); |
475 if (i == min_index) { | 476 if (i == min_index) { |
476 // Find the location of the first navigation within the previous list of | 477 // Find the location of the first navigation within the previous list of |
477 // navigations. We only need to do this once, as all subsequent | 478 // navigations. We only need to do this once, as all subsequent |
478 // navigations are either contiguous or completely new. | 479 // navigations are either contiguous or completely new. |
479 for (prev_nav_iter = prev_tab->synced_tab_navigations.begin(); | 480 for (;prev_nav_iter != prev_tab->synced_tab_navigations.end(); |
480 prev_nav_iter != prev_tab->synced_tab_navigations.end(); | |
481 ++prev_nav_iter) { | 481 ++prev_nav_iter) { |
482 if (prev_nav_iter->unique_id() == entry->GetUniqueID()) | 482 if (prev_nav_iter->unique_id() == entry->GetUniqueID()) |
483 break; | 483 break; |
484 } | 484 } |
485 } | 485 } |
486 if (entry->GetVirtualURL().is_valid()) { | 486 if (entry->GetVirtualURL().is_valid()) { |
487 if (i == current_index) { | 487 if (i == current_index) { |
488 *new_url = GURL(entry->GetVirtualURL().spec()); | 488 *new_url = GURL(entry->GetVirtualURL().spec()); |
489 DVLOG(1) << "Associating local tab " << new_tab.GetSessionId() | 489 DVLOG(1) << "Associating local tab " << new_tab.GetSessionId() |
490 << " with url " << new_url->spec() << " and title " | 490 << " with url " << new_url->spec() << " and title " |
(...skipping 1051 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1542 bool SessionModelAssociator::CryptoReadyIfNecessary() { | 1542 bool SessionModelAssociator::CryptoReadyIfNecessary() { |
1543 // We only access the cryptographer while holding a transaction. | 1543 // We only access the cryptographer while holding a transaction. |
1544 sync_api::ReadTransaction trans(FROM_HERE, sync_service_->GetUserShare()); | 1544 sync_api::ReadTransaction trans(FROM_HERE, sync_service_->GetUserShare()); |
1545 const syncable::ModelTypeSet encrypted_types = | 1545 const syncable::ModelTypeSet encrypted_types = |
1546 sync_api::GetEncryptedTypes(&trans); | 1546 sync_api::GetEncryptedTypes(&trans); |
1547 return !encrypted_types.Has(SESSIONS) || | 1547 return !encrypted_types.Has(SESSIONS) || |
1548 sync_service_->IsCryptographerReady(&trans); | 1548 sync_service_->IsCryptographerReady(&trans); |
1549 } | 1549 } |
1550 | 1550 |
1551 } // namespace browser_sync | 1551 } // namespace browser_sync |
OLD | NEW |