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 12 matching lines...) Expand all Loading... |
23 #include "chrome/browser/sync/profile_sync_service.h" | 23 #include "chrome/browser/sync/profile_sync_service.h" |
24 #include "chrome/common/chrome_notification_types.h" | 24 #include "chrome/common/chrome_notification_types.h" |
25 #include "chrome/common/chrome_switches.h" | 25 #include "chrome/common/chrome_switches.h" |
26 #include "chrome/common/pref_names.h" | 26 #include "chrome/common/pref_names.h" |
27 #include "chrome/common/url_constants.h" | 27 #include "chrome/common/url_constants.h" |
28 #include "content/public/browser/navigation_entry.h" | 28 #include "content/public/browser/navigation_entry.h" |
29 #include "content/public/browser/notification_details.h" | 29 #include "content/public/browser/notification_details.h" |
30 #include "content/public/browser/notification_service.h" | 30 #include "content/public/browser/notification_service.h" |
31 #include "sync/api/sync_error.h" | 31 #include "sync/api/sync_error.h" |
32 #include "sync/internal_api/public/base/model_type.h" | 32 #include "sync/internal_api/public/base/model_type.h" |
33 #include "sync/internal_api/public/base/model_type_payload_map.h" | 33 #include "sync/internal_api/public/base/model_type_state_map.h" |
34 #include "sync/internal_api/public/read_node.h" | 34 #include "sync/internal_api/public/read_node.h" |
35 #include "sync/internal_api/public/read_transaction.h" | 35 #include "sync/internal_api/public/read_transaction.h" |
36 #include "sync/internal_api/public/write_node.h" | 36 #include "sync/internal_api/public/write_node.h" |
37 #include "sync/internal_api/public/write_transaction.h" | 37 #include "sync/internal_api/public/write_transaction.h" |
38 #include "sync/protocol/session_specifics.pb.h" | 38 #include "sync/protocol/session_specifics.pb.h" |
39 #include "sync/syncable/directory.h" | 39 #include "sync/syncable/directory.h" |
40 #include "sync/syncable/read_transaction.h" | 40 #include "sync/syncable/read_transaction.h" |
41 #include "sync/syncable/write_transaction.h" | 41 #include "sync/syncable/write_transaction.h" |
42 #include "sync/util/get_session_name.h" | 42 #include "sync/util/get_session_name.h" |
43 #include "sync/util/time.h" | 43 #include "sync/util/time.h" |
(...skipping 1359 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1403 | 1403 |
1404 void SessionModelAssociator::TabNodePool::FreeTabNode(int64 sync_id) { | 1404 void SessionModelAssociator::TabNodePool::FreeTabNode(int64 sync_id) { |
1405 // Pool size should always match # of free tab nodes. | 1405 // Pool size should always match # of free tab nodes. |
1406 DCHECK_LT(tab_pool_fp_, static_cast<int64>(tab_syncid_pool_.size())); | 1406 DCHECK_LT(tab_pool_fp_, static_cast<int64>(tab_syncid_pool_.size())); |
1407 tab_syncid_pool_[static_cast<size_t>(++tab_pool_fp_)] = sync_id; | 1407 tab_syncid_pool_[static_cast<size_t>(++tab_pool_fp_)] = sync_id; |
1408 } | 1408 } |
1409 | 1409 |
1410 void SessionModelAssociator::AttemptSessionsDataRefresh() const { | 1410 void SessionModelAssociator::AttemptSessionsDataRefresh() const { |
1411 DVLOG(1) << "Triggering sync refresh for sessions datatype."; | 1411 DVLOG(1) << "Triggering sync refresh for sessions datatype."; |
1412 const syncer::ModelType type = syncer::SESSIONS; | 1412 const syncer::ModelType type = syncer::SESSIONS; |
1413 syncer::ModelTypePayloadMap payload_map; | 1413 syncer::ModelTypeStateMap state_map; |
1414 payload_map[type] = ""; | 1414 state_map.insert(std::make_pair(type, syncer::InvalidationState())); |
1415 content::NotificationService::current()->Notify( | 1415 content::NotificationService::current()->Notify( |
1416 chrome::NOTIFICATION_SYNC_REFRESH_LOCAL, | 1416 chrome::NOTIFICATION_SYNC_REFRESH_LOCAL, |
1417 content::Source<Profile>(profile_), | 1417 content::Source<Profile>(profile_), |
1418 content::Details<const syncer::ModelTypePayloadMap>(&payload_map)); | 1418 content::Details<const syncer::ModelTypeStateMap>(&state_map)); |
1419 } | 1419 } |
1420 | 1420 |
1421 bool SessionModelAssociator::GetLocalSession( | 1421 bool SessionModelAssociator::GetLocalSession( |
1422 const SyncedSession* * local_session) { | 1422 const SyncedSession* * local_session) { |
1423 DCHECK(CalledOnValidThread()); | 1423 DCHECK(CalledOnValidThread()); |
1424 if (current_machine_tag_.empty()) | 1424 if (current_machine_tag_.empty()) |
1425 return false; | 1425 return false; |
1426 *local_session = synced_session_tracker_.GetSession(GetCurrentMachineTag()); | 1426 *local_session = synced_session_tracker_.GetSession(GetCurrentMachineTag()); |
1427 return true; | 1427 return true; |
1428 } | 1428 } |
(...skipping 164 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1593 bool SessionModelAssociator::CryptoReadyIfNecessary() { | 1593 bool SessionModelAssociator::CryptoReadyIfNecessary() { |
1594 // We only access the cryptographer while holding a transaction. | 1594 // We only access the cryptographer while holding a transaction. |
1595 syncer::ReadTransaction trans(FROM_HERE, sync_service_->GetUserShare()); | 1595 syncer::ReadTransaction trans(FROM_HERE, sync_service_->GetUserShare()); |
1596 const syncer::ModelTypeSet encrypted_types = | 1596 const syncer::ModelTypeSet encrypted_types = |
1597 syncer::GetEncryptedTypes(&trans); | 1597 syncer::GetEncryptedTypes(&trans); |
1598 return !encrypted_types.Has(SESSIONS) || | 1598 return !encrypted_types.Has(SESSIONS) || |
1599 sync_service_->IsCryptographerReady(&trans); | 1599 sync_service_->IsCryptographerReady(&trans); |
1600 } | 1600 } |
1601 | 1601 |
1602 } // namespace browser_sync | 1602 } // namespace browser_sync |
OLD | NEW |