Chromium Code Reviews| Index: chrome/browser/sync/glue/session_model_associator.cc |
| diff --git a/chrome/browser/sync/glue/session_model_associator.cc b/chrome/browser/sync/glue/session_model_associator.cc |
| index e34133d95f155a729f4051b4e5ce574b252efefe..9dddbb43c4d23d24a97e96f645365c103402c538 100644 |
| --- a/chrome/browser/sync/glue/session_model_associator.cc |
| +++ b/chrome/browser/sync/glue/session_model_associator.cc |
| @@ -48,8 +48,6 @@ |
| #include "base/linux_util.h" |
| #elif defined(OS_WIN) |
| #include <windows.h> |
| -#elif defined(OS_ANDROID) |
| -#include "sync/util/session_utils_android.h" |
| #endif |
| using content::BrowserThread; |
| @@ -643,6 +641,16 @@ syncer::SyncError SessionModelAssociator::AssociateModels( |
| local_session_syncid_ = write_node.GetId(); |
| } |
| +#if defined(OS_ANDROID) |
| + std::string persisted_machine_tag; |
|
Nicolas Zea
2012/11/16 18:55:20
I don't think you need this variable, doesn't curr
nyquist
2012/12/04 01:55:05
Done.
|
| + if (pref_service_) |
| + persisted_machine_tag = pref_service_->GetString(kSyncSessionsGUID); |
| + |
| + std::string transaction_tag = GetMachineTagFromTransaction(&trans); |
| + if (persisted_machine_tag.compare(transaction_tag) != 0) { |
| + DeleteForeignSession(transaction_tag); |
| + } |
| +#endif |
| } |
| // Check if anything has changed on the client side. |
| @@ -690,19 +698,7 @@ void SessionModelAssociator::InitializeCurrentMachineTag( |
| DVLOG(1) << "Restoring persisted session sync guid: " |
| << persisted_guid; |
| } else { |
| - syncer::syncable::Directory* dir = |
| - trans->GetWrappedWriteTrans()->directory(); |
| - current_machine_tag_ = "session_sync"; |
| -#if defined(OS_ANDROID) |
| - const std::string android_id = syncer::internal::GetAndroidId(); |
| - // There are reports that sometimes the android_id can't be read. Those |
| - // are supposed to be fixed as of Gingerbread, but if it happens we fall |
| - // back to use the same GUID generation as on other platforms. |
| - current_machine_tag_.append(android_id.empty() ? |
| - dir->cache_guid() : android_id); |
| -#else |
| - current_machine_tag_.append(dir->cache_guid()); |
| -#endif |
| + current_machine_tag_ = GetMachineTagFromTransaction(trans); |
| DVLOG(1) << "Creating session sync guid: " << current_machine_tag_; |
| if (pref_service_) |
| pref_service_->SetString(kSyncSessionsGUID, current_machine_tag_); |
| @@ -1282,6 +1278,14 @@ bool SessionModelAssociator::TabHasValidEntry( |
| return found_valid_url; |
| } |
| +std::string SessionModelAssociator::GetMachineTagFromTransaction( |
|
Nicolas Zea
2012/11/16 18:55:20
Since this is basically a static helper method, I
nyquist
2012/12/04 01:55:05
Done.
|
| + syncer::WriteTransaction* trans) { |
| + syncer::syncable::Directory* dir = trans->GetWrappedWriteTrans()->directory(); |
| + std::string machine_tag = "session_sync"; |
| + machine_tag.append(dir->cache_guid()); |
| + return machine_tag; |
| +} |
| + |
| // If this functionality changes, SyncedSession::ShouldSyncSessionTab should be |
| // modified to match. |
| bool SessionModelAssociator::ShouldSyncTab(const SyncedTabDelegate& tab) const { |