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

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

Issue 10911073: NOT FOR COMMIT: Add DeviceInfo type and ChangeProcessor (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Fix several issues Created 8 years, 3 months 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
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 0457f7241c4dd6511e1f02ad88a3212fd33c60ea..66cb3c677eb1c0aed0b503f685e1739d56395319 100644
--- a/chrome/browser/sync/glue/session_model_associator.cc
+++ b/chrome/browser/sync/glue/session_model_associator.cc
@@ -18,6 +18,7 @@
#include "chrome/browser/prefs/pref_service.h"
#include "chrome/browser/profiles/profile.h"
#include "chrome/browser/sessions/session_id.h"
+#include "chrome/browser/sync/glue/device_info.h"
#include "chrome/browser/sync/glue/synced_session.h"
#include "chrome/browser/sync/glue/synced_tab_delegate.h"
#include "chrome/browser/sync/glue/synced_window_delegate.h"
@@ -34,12 +35,10 @@
#include "sync/internal_api/public/base/model_type_state_map.h"
#include "sync/internal_api/public/read_node.h"
#include "sync/internal_api/public/read_transaction.h"
+#include "sync/internal_api/public/user_share.h"
#include "sync/internal_api/public/write_node.h"
#include "sync/internal_api/public/write_transaction.h"
#include "sync/protocol/session_specifics.pb.h"
-#include "sync/syncable/directory.h"
-#include "sync/syncable/read_transaction.h"
-#include "sync/syncable/write_transaction.h"
#include "sync/util/get_session_name.h"
#include "sync/util/time.h"
#include "ui/gfx/favicon_size.h"
@@ -76,26 +75,6 @@ bool IsTabletUI() {
}
#endif
-sync_pb::SessionHeader::DeviceType GetLocalDeviceType() {
- // TODO(yfriedman): Refactor/combine with "DeviceInformation" code in
- // sync_manager.cc[1060]
-#if defined(OS_CHROMEOS)
- return sync_pb::SessionHeader_DeviceType_TYPE_CROS;
-#elif defined(OS_LINUX)
- return sync_pb::SessionHeader_DeviceType_TYPE_LINUX;
-#elif defined(OS_MACOSX)
- return sync_pb::SessionHeader_DeviceType_TYPE_MAC;
-#elif defined(OS_WIN)
- return sync_pb::SessionHeader_DeviceType_TYPE_WIN;
-#elif defined(OS_ANDROID)
- return IsTabletUI() ?
- sync_pb::SessionHeader_DeviceType_TYPE_TABLET :
- sync_pb::SessionHeader_DeviceType_TYPE_PHONE;
-#else
- return sync_pb::SessionHeader_DeviceType_TYPE_OTHER;
-#endif
-}
-
} // namespace
SessionModelAssociator::SessionModelAssociator(ProfileSyncService* sync_service,
@@ -203,7 +182,7 @@ bool SessionModelAssociator::AssociateWindows(bool reload_tabs,
synced_session_tracker_.GetSession(local_tag);
current_session->modified_time = base::Time::Now();
header_s->set_client_name(current_session_name_);
- header_s->set_device_type(GetLocalDeviceType());
+ header_s->set_device_type(DeviceInfo::GetLocalDeviceType());
synced_session_tracker_.ResetSessionTracking(local_tag);
std::set<SyncedWindowDelegate*> windows =
@@ -763,7 +742,7 @@ syncer::SyncError SessionModelAssociator::AssociateModels() {
// Make sure we have a machine tag.
if (current_machine_tag_.empty()) {
- InitializeCurrentMachineTag(&trans);
+ InitializeCurrentMachineTag(sync_service_->GetUserShare());
// The session name is retrieved asynchronously so it might not come back
// for the writing of the session. However, we write to the session often
// enough (on every navigation) that we'll pick it up quickly.
@@ -797,7 +776,7 @@ syncer::SyncError SessionModelAssociator::AssociateModels() {
base_specifics.set_session_tag(current_machine_tag_);
sync_pb::SessionHeader* header_s = base_specifics.mutable_header();
header_s->set_client_name(current_session_name_);
- header_s->set_device_type(GetLocalDeviceType());
+ header_s->set_device_type(DeviceInfo::GetLocalDeviceType());
write_node.SetSessionSpecifics(base_specifics);
local_session_syncid_ = write_node.GetId();
@@ -838,7 +817,7 @@ syncer::SyncError SessionModelAssociator::DisassociateModels() {
}
void SessionModelAssociator::InitializeCurrentMachineTag(
- syncer::WriteTransaction* trans) {
+ syncer::UserShare* share) {
DCHECK(CalledOnValidThread());
DCHECK(current_machine_tag_.empty());
std::string persisted_guid;
@@ -849,8 +828,6 @@ 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();
@@ -858,9 +835,9 @@ void SessionModelAssociator::InitializeCurrentMachineTag(
// 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);
+ share->cache_guid() : android_id);
#else
- current_machine_tag_.append(dir->cache_guid());
+ current_machine_tag_.append(share->cache_guid());
#endif
DVLOG(1) << "Creating session sync guid: " << current_machine_tag_;
if (pref_service_)
@@ -1123,25 +1100,25 @@ void SessionModelAssociator::PopulateSessionHeaderFromSpecifics(
}
if (header_specifics.has_device_type()) {
switch (header_specifics.device_type()) {
- case sync_pb::SessionHeader_DeviceType_TYPE_WIN:
+ case sync_pb::SyncEnums_DeviceType_TYPE_WIN:
session_header->device_type = SyncedSession::TYPE_WIN;
break;
- case sync_pb::SessionHeader_DeviceType_TYPE_MAC:
+ case sync_pb::SyncEnums_DeviceType_TYPE_MAC:
session_header->device_type = SyncedSession::TYPE_MACOSX;
break;
- case sync_pb::SessionHeader_DeviceType_TYPE_LINUX:
+ case sync_pb::SyncEnums_DeviceType_TYPE_LINUX:
session_header->device_type = SyncedSession::TYPE_LINUX;
break;
- case sync_pb::SessionHeader_DeviceType_TYPE_CROS:
+ case sync_pb::SyncEnums_DeviceType_TYPE_CROS:
session_header->device_type = SyncedSession::TYPE_CHROMEOS;
break;
- case sync_pb::SessionHeader_DeviceType_TYPE_PHONE:
+ case sync_pb::SyncEnums_DeviceType_TYPE_PHONE:
session_header->device_type = SyncedSession::TYPE_PHONE;
break;
- case sync_pb::SessionHeader_DeviceType_TYPE_TABLET:
+ case sync_pb::SyncEnums_DeviceType_TYPE_TABLET:
session_header->device_type = SyncedSession::TYPE_TABLET;
break;
- case sync_pb::SessionHeader_DeviceType_TYPE_OTHER:
+ case sync_pb::SyncEnums_DeviceType_TYPE_OTHER:
// Intentionally fall-through
default:
session_header->device_type = SyncedSession::TYPE_OTHER;
« no previous file with comments | « chrome/browser/sync/glue/session_model_associator.h ('k') | chrome/browser/sync/glue/session_model_associator_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698