OLD | NEW |
| (Empty) |
1 // Copyright 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. | |
4 | |
5 #ifndef COMPONENTS_SYNC_DRIVER_GLUE_SYNCED_SESSION_H_ | |
6 #define COMPONENTS_SYNC_DRIVER_GLUE_SYNCED_SESSION_H_ | |
7 | |
8 #include <map> | |
9 #include <string> | |
10 | |
11 #include "base/time/time.h" | |
12 #include "components/sessions/core/session_id.h" | |
13 #include "components/sessions/core/session_types.h" | |
14 #include "sync/protocol/session_specifics.pb.h" | |
15 | |
16 namespace sessions { | |
17 struct SessionWindow; | |
18 } | |
19 | |
20 namespace sync_driver { | |
21 | |
22 // Defines a synced session for use by session sync. A synced session is a | |
23 // list of windows along with a unique session identifer (tag) and meta-data | |
24 // about the device being synced. | |
25 struct SyncedSession { | |
26 typedef std::map<SessionID::id_type, sessions::SessionWindow*> | |
27 SyncedWindowMap; | |
28 | |
29 // The type of device. | |
30 // Please keep in sync with ForeignSessionHelper.java | |
31 enum DeviceType { | |
32 TYPE_UNSET = 0, | |
33 TYPE_WIN = 1, | |
34 TYPE_MACOSX = 2, | |
35 TYPE_LINUX = 3, | |
36 TYPE_CHROMEOS = 4, | |
37 TYPE_OTHER = 5, | |
38 TYPE_PHONE = 6, | |
39 TYPE_TABLET = 7 | |
40 }; | |
41 | |
42 SyncedSession(); | |
43 ~SyncedSession(); | |
44 | |
45 // Unique tag for each session. | |
46 std::string session_tag; | |
47 // User-visible name | |
48 std::string session_name; | |
49 | |
50 // Type of device this session is from. | |
51 DeviceType device_type; | |
52 | |
53 // Last time this session was modified remotely. | |
54 base::Time modified_time; | |
55 | |
56 // Map of windows that make up this session. Windowws are owned by the session | |
57 // itself and free'd on destruction. | |
58 SyncedWindowMap windows; | |
59 | |
60 // Converts the DeviceType enum value to a string. This is used | |
61 // in the NTP handler for foreign sessions for matching session | |
62 // types to an icon style. | |
63 std::string DeviceTypeAsString() const { | |
64 switch (device_type) { | |
65 case SyncedSession::TYPE_WIN: | |
66 return "win"; | |
67 case SyncedSession::TYPE_MACOSX: | |
68 return "macosx"; | |
69 case SyncedSession::TYPE_LINUX: | |
70 return "linux"; | |
71 case SyncedSession::TYPE_CHROMEOS: | |
72 return "chromeos"; | |
73 case SyncedSession::TYPE_OTHER: | |
74 return "other"; | |
75 case SyncedSession::TYPE_PHONE: | |
76 return "phone"; | |
77 case SyncedSession::TYPE_TABLET: | |
78 return "tablet"; | |
79 default: | |
80 return std::string(); | |
81 } | |
82 } | |
83 | |
84 // Convert this object to its protocol buffer equivalent. Shallow conversion, | |
85 // does not create SessionTab protobufs. | |
86 sync_pb::SessionHeader ToSessionHeader() const; | |
87 | |
88 private: | |
89 DISALLOW_COPY_AND_ASSIGN(SyncedSession); | |
90 }; | |
91 | |
92 } // namespace sync_driver | |
93 | |
94 #endif // COMPONENTS_SYNC_DRIVER_GLUE_SYNCED_SESSION_H_ | |
OLD | NEW |