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
3 // found in the LICENSE file.
5 #include "components/sync_driver/glue/synced_session.h"
7 #include "base/stl_util.h"
9 namespace sync_driver
{
11 SyncedSession::SyncedSession()
12 : session_tag("invalid"), device_type(TYPE_UNSET
) {
15 SyncedSession::~SyncedSession() {
16 STLDeleteContainerPairSecondPointers(windows
.begin(), windows
.end());
19 sync_pb::SessionHeader
SyncedSession::ToSessionHeader() const {
20 sync_pb::SessionHeader header
;
21 SyncedWindowMap::const_iterator iter
;
22 for (iter
= windows
.begin(); iter
!= windows
.end(); ++iter
) {
23 sync_pb::SessionWindow
* w
= header
.add_window();
24 w
->CopyFrom(iter
->second
->ToSyncData());
26 header
.set_client_name(session_name
);
27 switch (device_type
) {
28 case SyncedSession::TYPE_WIN
:
29 header
.set_device_type(sync_pb::SyncEnums_DeviceType_TYPE_WIN
);
31 case SyncedSession::TYPE_MACOSX
:
32 header
.set_device_type(sync_pb::SyncEnums_DeviceType_TYPE_MAC
);
34 case SyncedSession::TYPE_LINUX
:
35 header
.set_device_type(sync_pb::SyncEnums_DeviceType_TYPE_LINUX
);
37 case SyncedSession::TYPE_CHROMEOS
:
38 header
.set_device_type(sync_pb::SyncEnums_DeviceType_TYPE_CROS
);
40 case SyncedSession::TYPE_PHONE
:
41 header
.set_device_type(sync_pb::SyncEnums_DeviceType_TYPE_PHONE
);
43 case SyncedSession::TYPE_TABLET
:
44 header
.set_device_type(sync_pb::SyncEnums_DeviceType_TYPE_TABLET
);
46 case SyncedSession::TYPE_OTHER
:
47 // Intentionally fall-through
49 header
.set_device_type(sync_pb::SyncEnums_DeviceType_TYPE_OTHER
);
55 } // namespace sync_driver