Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(340)

Unified Diff: chrome/browser/sync/glue/session_model_associator.cc

Issue 11414013: Depend on stored sync session GUID for Android. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Simplified implementation Created 8 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | sync/sync.gyp » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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..96433818fe401f0c520a05785bbcb1883e188157 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;
@@ -57,6 +55,19 @@ using content::NavigationEntry;
using prefs::kSyncSessionsGUID;
using syncer::SESSIONS;
+namespace {
+// Given a transaction, returns the GUID-based string that should be used for
+// |current_machine_tag_|.
+std::string GetMachineTagFromTransaction(
+ 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;
+}
+
+} // namespace
+
namespace browser_sync {
namespace {
@@ -643,6 +654,11 @@ syncer::SyncError SessionModelAssociator::AssociateModels(
local_session_syncid_ = write_node.GetId();
}
+#if defined(OS_ANDROID)
+ std::string transaction_tag = GetMachineTagFromTransaction(&trans);
+ if (current_machine_tag_.compare(transaction_tag) != 0)
+ DeleteForeignSession(transaction_tag);
+#endif
}
// Check if anything has changed on the client side.
@@ -690,19 +706,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_);
« no previous file with comments | « no previous file | sync/sync.gyp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698