summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authoryfriedman@chromium.org <yfriedman@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2012-03-14 22:10:48 +0000
committeryfriedman@chromium.org <yfriedman@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2012-03-14 22:10:48 +0000
commit1256c5d431ac15d9dc94bab2d42eac36212f0007 (patch)
tree7c299112cd6c9b2178858a17fb121b639ab485b2
parentd80c3146f251a0ebb49963a0567438eecb807339 (diff)
downloadchromium_src-1256c5d431ac15d9dc94bab2d42eac36212f0007.zip
chromium_src-1256c5d431ac15d9dc94bab2d42eac36212f0007.tar.gz
chromium_src-1256c5d431ac15d9dc94bab2d42eac36212f0007.tar.bz2
Add Phone/Tablet device types for syncing session from Android.
This is most of the scaffolding. The logic to choose between Tablet/Phone requires Java code which can't be upstreamed yet due to other dependencies. BUG= TEST= Review URL: http://codereview.chromium.org/9664008 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@126762 0039d316-1c4b-4281-b951-d872f2087c98
-rw-r--r--chrome/browser/sync/glue/session_model_associator.cc36
-rw-r--r--chrome/browser/sync/glue/synced_session.h4
-rw-r--r--chrome/browser/sync/protocol/proto_enum_conversions.cc4
-rw-r--r--sync/protocol/session_specifics.proto2
4 files changed, 33 insertions, 13 deletions
diff --git a/chrome/browser/sync/glue/session_model_associator.cc b/chrome/browser/sync/glue/session_model_associator.cc
index 86b273d..2ec8336 100644
--- a/chrome/browser/sync/glue/session_model_associator.cc
+++ b/chrome/browser/sync/glue/session_model_associator.cc
@@ -57,6 +57,24 @@ static const int kMaxSyncNavigationCount = 6;
// Default number of days without activity after which a session is considered
// stale and becomes a candidate for garbage collection.
static const size_t kDefaultStaleSessionThresholdDays = 14; // 2 weeks.
+
+sync_pb::SessionHeader::DeviceType GetLocalDeviceType() {
+#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)
+ // TODO(yfriedman): Add logic to conditionally set device_type to tablet.
+ return sync_pb::SessionHeader_DeviceType_TYPE_PHONE;
+#else
+ return sync_pb::SessionHeader_DeviceType_TYPE_OTHER;
+#endif
+}
+
} // namespace
SessionModelAssociator::SessionModelAssociator(ProfileSyncService* sync_service)
@@ -153,17 +171,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_);
-#if defined(OS_CHROMEOS)
- header_s->set_device_type(sync_pb::SessionHeader_DeviceType_TYPE_CROS);
-#elif defined(OS_LINUX)
- header_s->set_device_type(sync_pb::SessionHeader_DeviceType_TYPE_LINUX);
-#elif defined(OS_MACOSX)
- header_s->set_device_type(sync_pb::SessionHeader_DeviceType_TYPE_MAC);
-#elif defined(OS_WIN)
- header_s->set_device_type(sync_pb::SessionHeader_DeviceType_TYPE_WIN);
-#else
- header_s->set_device_type(sync_pb::SessionHeader_DeviceType_TYPE_OTHER);
-#endif
+ header_s->set_device_type(GetLocalDeviceType());
synced_session_tracker_.ResetSessionTracking(local_tag);
std::set<SyncedWindowDelegate*> windows =
@@ -721,6 +729,12 @@ void SessionModelAssociator::PopulateSessionHeaderFromSpecifics(
case sync_pb::SessionHeader_DeviceType_TYPE_CROS:
session_header->device_type = SyncedSession::TYPE_CHROMEOS;
break;
+ case sync_pb::SessionHeader_DeviceType_TYPE_PHONE:
+ session_header->device_type = SyncedSession::TYPE_PHONE;
+ break;
+ case sync_pb::SessionHeader_DeviceType_TYPE_TABLET:
+ session_header->device_type = SyncedSession::TYPE_TABLET;
+ break;
case sync_pb::SessionHeader_DeviceType_TYPE_OTHER:
// Intentionally fall-through
default:
diff --git a/chrome/browser/sync/glue/synced_session.h b/chrome/browser/sync/glue/synced_session.h
index c4037dd..c87cc28 100644
--- a/chrome/browser/sync/glue/synced_session.h
+++ b/chrome/browser/sync/glue/synced_session.h
@@ -30,7 +30,9 @@ struct SyncedSession {
TYPE_MACOSX = 2,
TYPE_LINUX = 3,
TYPE_CHROMEOS = 4,
- TYPE_OTHER = 5
+ TYPE_OTHER = 5,
+ TYPE_PHONE = 6,
+ TYPE_TABLET = 7
};
SyncedSession();
diff --git a/chrome/browser/sync/protocol/proto_enum_conversions.cc b/chrome/browser/sync/protocol/proto_enum_conversions.cc
index 4832b85..030e53f 100644
--- a/chrome/browser/sync/protocol/proto_enum_conversions.cc
+++ b/chrome/browser/sync/protocol/proto_enum_conversions.cc
@@ -92,13 +92,15 @@ const char* GetUpdatesSourceString(
const char* GetDeviceTypeString(
sync_pb::SessionHeader::DeviceType device_type) {
- ASSERT_ENUM_BOUNDS(sync_pb::SessionHeader, DeviceType, TYPE_WIN, TYPE_OTHER);
+ ASSERT_ENUM_BOUNDS(sync_pb::SessionHeader, DeviceType, TYPE_WIN, TYPE_TABLET);
switch (device_type) {
ENUM_CASE(sync_pb::SessionHeader, TYPE_WIN);
ENUM_CASE(sync_pb::SessionHeader, TYPE_MAC);
ENUM_CASE(sync_pb::SessionHeader, TYPE_LINUX);
ENUM_CASE(sync_pb::SessionHeader, TYPE_CROS);
ENUM_CASE(sync_pb::SessionHeader, TYPE_OTHER);
+ ENUM_CASE(sync_pb::SessionHeader, TYPE_PHONE);
+ ENUM_CASE(sync_pb::SessionHeader, TYPE_TABLET);
}
NOTREACHED();
return "";
diff --git a/sync/protocol/session_specifics.proto b/sync/protocol/session_specifics.proto
index 9b59dd0..07323b1 100644
--- a/sync/protocol/session_specifics.proto
+++ b/sync/protocol/session_specifics.proto
@@ -33,6 +33,8 @@ message SessionHeader {
TYPE_LINUX = 3;
TYPE_CROS = 4;
TYPE_OTHER = 5;
+ TYPE_PHONE = 6;
+ TYPE_TABLET = 7;
}
optional DeviceType device_type = 4;
}