summaryrefslogtreecommitdiffstats
path: root/chrome
diff options
context:
space:
mode:
authorthakis@chromium.org <thakis@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2011-09-02 21:01:24 +0000
committerthakis@chromium.org <thakis@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2011-09-02 21:01:24 +0000
commit812abfc8f60724644a3aaf61a877e4434286707a (patch)
tree3476b6b0f07b962c557f0f8ddf874e9b361f828c /chrome
parentfbb68edc9f2470338576d584425a9f7b45479fac (diff)
downloadchromium_src-812abfc8f60724644a3aaf61a877e4434286707a.zip
chromium_src-812abfc8f60724644a3aaf61a877e4434286707a.tar.gz
chromium_src-812abfc8f60724644a3aaf61a877e4434286707a.tar.bz2
Set user-visible machine names and devices types for synced sessions.
On OSX: - Read the computer name, falling back to reading hw.model and stripping any trialing numbers. This will give us something like MacBookPro, iMac, MacBookAir. On Linux: - Use distro name which gives something like "Ubuntu 10.04.2 LTS". On Windows: - Use the computer name On ChromeOS: - Use "Chromebook" BUG=94693, 59672 TEST=enable session sync, sync two clients, and then look at the entries in about:sync and see that the "client_name" is set Committed: http://src.chromium.org/viewvc/chrome?view=rev&revision=99391 Review URL: http://codereview.chromium.org/7740055 Patch from Yaron Friedman <yfriedman@chromium.org>. git-svn-id: svn://svn.chromium.org/chrome/trunk/src@99450 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome')
-rw-r--r--chrome/browser/sessions/session_types.cc10
-rw-r--r--chrome/browser/sessions/session_types.h11
-rw-r--r--chrome/browser/sync/glue/session_model_associator.cc136
-rw-r--r--chrome/browser/sync/glue/session_model_associator.h37
-rw-r--r--chrome/browser/sync/glue/session_model_associator_mac.mm52
-rw-r--r--chrome/browser/sync/glue/session_model_associator_unittest.cc32
-rw-r--r--chrome/browser/sync/glue/synced_session.cc19
-rw-r--r--chrome/browser/sync/glue/synced_session.h42
-rw-r--r--chrome/browser/sync/glue/synced_session_tracker.h1
-rw-r--r--chrome/browser/sync/profile_sync_service_session_unittest.cc2
-rw-r--r--chrome/browser/ui/webui/sessions_ui.cc28
-rw-r--r--chrome/chrome_browser.gypi3
-rw-r--r--chrome/test/live_sync/performance/sessions_sync_perf_test.cc2
-rw-r--r--chrome/test/live_sync/sessions_helper.cc11
-rw-r--r--chrome/test/live_sync/sessions_helper.h8
15 files changed, 342 insertions, 52 deletions
diff --git a/chrome/browser/sessions/session_types.cc b/chrome/browser/sessions/session_types.cc
index 086eb3e..bef9b73 100644
--- a/chrome/browser/sessions/session_types.cc
+++ b/chrome/browser/sessions/session_types.cc
@@ -122,13 +122,3 @@ SessionWindow::SessionWindow()
SessionWindow::~SessionWindow() {
STLDeleteElements(&tabs);
}
-
-// SyncedSession --------------------------------------------------------------
-
-SyncedSession::SyncedSession() : session_tag("invalid") {
-}
-
-SyncedSession::~SyncedSession() {
- STLDeleteElements(&windows);
-}
-
diff --git a/chrome/browser/sessions/session_types.h b/chrome/browser/sessions/session_types.h
index fd52cb9..4edf1e9 100644
--- a/chrome/browser/sessions/session_types.h
+++ b/chrome/browser/sessions/session_types.h
@@ -197,15 +197,4 @@ struct SessionWindow {
DISALLOW_COPY_AND_ASSIGN(SessionWindow);
};
-// Defines a synced session for use by session sync. A synced session is a
-// list of windows along with a unique session identifer (tag).
-struct SyncedSession {
- SyncedSession();
- ~SyncedSession();
-
- // Unique tag for each session.
- std::string session_tag;
- std::vector<SessionWindow*> windows;
-};
-
#endif // CHROME_BROWSER_SESSIONS_SESSION_TYPES_H_
diff --git a/chrome/browser/sync/glue/session_model_associator.cc b/chrome/browser/sync/glue/session_model_associator.cc
index ea4eee3..111f90c 100644
--- a/chrome/browser/sync/glue/session_model_associator.cc
+++ b/chrome/browser/sync/glue/session_model_associator.cc
@@ -9,10 +9,13 @@
#include <utility>
#include "base/logging.h"
+#include "base/sys_info.h"
#include "base/tracked.h"
+#include "chrome/browser/browser_process.h"
#include "chrome/browser/profiles/profile.h"
#include "chrome/browser/sessions/session_service_factory.h"
#include "chrome/browser/sync/api/sync_error.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"
#include "chrome/browser/sync/internal_api/read_node.h"
@@ -26,6 +29,11 @@
#include "content/browser/tab_contents/navigation_entry.h"
#include "content/common/notification_details.h"
#include "content/common/notification_service.h"
+#if defined(OS_LINUX)
+#include "base/linux_util.h"
+#elif defined(OS_WIN)
+#include <windows.h>
+#endif
namespace browser_sync {
@@ -123,6 +131,18 @@ void SessionModelAssociator::ReassociateWindows(bool reload_tabs) {
sync_pb::SessionHeader* header_s = specifics.mutable_header();
SyncedSession* current_session =
synced_session_tracker_.GetSession(local_tag);
+ header_s->set_client_name(current_session_name_);
+#if 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);
+#elif defined(OS_CHROMEOS)
+ header_s->set_device_type(sync_pb::SessionHeader_DeviceType_TYPE_CROS);
+#else
+ header_s->set_device_type(sync_pb::SessionHeader_DeviceType_TYPE_OTHER);
+#endif
size_t window_num = 0;
std::set<SyncedWindowDelegate*> windows =
@@ -427,8 +447,13 @@ bool SessionModelAssociator::AssociateModels(SyncError* error) {
}
// Make sure we have a machine tag.
- if (current_machine_tag_.empty())
+ if (current_machine_tag_.empty()) {
InitializeCurrentMachineTag(&trans);
+ // 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.
+ InitializeCurrentSessionName();
+ }
synced_session_tracker_.SetLocalSessionTag(current_machine_tag_);
if (!UpdateAssociationsFromSyncModel(root, &trans)) {
error->Reset(FROM_HERE,
@@ -466,6 +491,8 @@ bool SessionModelAssociator::DisassociateModels(SyncError* error) {
tab_map_.clear();
tab_pool_.clear();
local_session_syncid_ = sync_api::kInvalidId;
+ current_machine_tag_ = "";
+ current_session_name_ = "";
// There is no local model stored with which to disassociate, just notify
// foreign session handlers.
@@ -480,19 +507,64 @@ void SessionModelAssociator::InitializeCurrentMachineTag(
sync_api::WriteTransaction* trans) {
DCHECK(CalledOnValidThread());
syncable::Directory* dir = trans->GetWrappedWriteTrans()->directory();
-
- // TODO(zea): We need a better way of creating a machine tag. The directory
- // kernel's cache_guid changes every time syncing is turned on and off. This
- // will result in session's associated with stale machine tags persisting on
- // the server since that tag will not be reused. Eventually this should
- // become some string identifiable to the user. (Home, Work, Laptop, etc.)
- // See issue at http://crbug.com/59672
current_machine_tag_ = "session_sync";
current_machine_tag_.append(dir->cache_guid());
VLOG(1) << "Creating machine tag: " << current_machine_tag_;
tab_pool_.set_machine_tag(current_machine_tag_);
}
+void SessionModelAssociator::OnSessionNameInitialized(const std::string name) {
+ DCHECK(CalledOnValidThread());
+ // Only use the default machine name if it hasn't already been set.
+ if (current_session_name_.empty()) {
+ current_session_name_ = name;
+ }
+}
+
+// Task which runs on the file thread because it runs system calls which can
+// block while retrieving sytem information.
+class GetSessionNameTask : public Task {
+ public:
+ explicit GetSessionNameTask(
+ const WeakHandle<SessionModelAssociator> associator) :
+ associator_(associator) {}
+
+ virtual void Run() {
+#if defined(OS_LINUX)
+ std::string session_name = base::GetLinuxDistro();
+#elif defined(OS_MACOSX)
+ std::string session_name = SessionModelAssociator::GetHardwareModelName();
+#elif defined(OS_WIN)
+ std::string session_name = SessionModelAssociator::GetComputerName();
+#else
+ std::string session_name;
+#endif
+ if (session_name == "Unknown" || session_name.empty()) {
+ session_name = base::SysInfo::OperatingSystemName();
+ }
+ associator_.Call(FROM_HERE,
+ &SessionModelAssociator::OnSessionNameInitialized,
+ session_name);
+ }
+ const WeakHandle<SessionModelAssociator> associator_;
+
+ DISALLOW_COPY_AND_ASSIGN(GetSessionNameTask);
+};
+
+void SessionModelAssociator::InitializeCurrentSessionName() {
+ DCHECK(CalledOnValidThread());
+ if (setup_for_test_) {
+ OnSessionNameInitialized("TestSessionName");
+ } else {
+#if defined(OS_CHROMEOS)
+ OnSessionNameInitialized("Chromebook");
+#else
+ BrowserThread::PostTask(BrowserThread::FILE, FROM_HERE,
+ new GetSessionNameTask(MakeWeakHandle(AsWeakPtr())));
+#endif
+ }
+}
+
bool SessionModelAssociator::UpdateAssociationsFromSyncModel(
const sync_api::ReadNode& root,
const sync_api::BaseTransaction* trans) {
@@ -522,6 +594,9 @@ bool SessionModelAssociator::UpdateAssociationsFromSyncModel(
// This is our previous header node, reuse it.
local_session_syncid_ = id;
+ if (specifics.header().has_client_name()) {
+ current_session_name_ = specifics.header().client_name();
+ }
} else {
if (!specifics.has_tab())
return false;
@@ -561,6 +636,7 @@ bool SessionModelAssociator::AssociateForeignSpecifics(
synced_session_tracker_.GetSession(foreign_session_tag);
const sync_pb::SessionHeader& header = specifics.header();
+ PopulateSessionHeaderFromSpecifics(header, foreign_session);
foreign_session->windows.reserve(header.window_size());
VLOG(1) << "Associating " << foreign_session_tag << " with " <<
header.window_size() << " windows.";
@@ -605,6 +681,36 @@ void SessionModelAssociator::DisassociateForeignSession(
}
// Static
+void SessionModelAssociator::PopulateSessionHeaderFromSpecifics(
+ const sync_pb::SessionHeader& header_specifics,
+ SyncedSession* session_header) {
+ if (header_specifics.has_client_name()) {
+ session_header->session_name = header_specifics.client_name();
+ }
+ if (header_specifics.has_device_type()) {
+ switch (header_specifics.device_type()) {
+ case sync_pb::SessionHeader_DeviceType_TYPE_WIN:
+ session_header->device_type = SyncedSession::TYPE_WIN;
+ break;
+ case sync_pb::SessionHeader_DeviceType_TYPE_MAC:
+ session_header->device_type = SyncedSession::TYPE_MACOSX;
+ break;
+ case sync_pb::SessionHeader_DeviceType_TYPE_LINUX:
+ session_header->device_type = SyncedSession::TYPE_LINUX;
+ break;
+ case sync_pb::SessionHeader_DeviceType_TYPE_CROS:
+ session_header->device_type = SyncedSession::TYPE_CHROMEOS;
+ break;
+ case sync_pb::SessionHeader_DeviceType_TYPE_OTHER:
+ // Intentionally fall-through
+ default:
+ session_header->device_type = SyncedSession::TYPE_OTHER;
+ break;
+ }
+ }
+}
+
+// Static
void SessionModelAssociator::PopulateSessionWindowFromSpecifics(
const std::string& session_tag,
const sync_pb::SessionWindow& specifics,
@@ -1076,4 +1182,18 @@ bool SessionModelAssociator::CryptoReadyIfNecessary() {
sync_service_->IsCryptographerReady(&trans);
}
+#if defined(OS_WIN)
+// Static
+// TODO(nzea): This isn't safe to call on the UI-thread. Move it out to a util
+// or object that lives on the FILE thread.
+std::string SessionModelAssociator::GetComputerName() {
+ char computer_name[MAX_COMPUTERNAME_LENGTH + 1];
+ DWORD size = sizeof(computer_name);
+ if (GetComputerNameA(computer_name, &size)) {
+ return computer_name;
+ }
+ return std::string();
+}
+#endif
+
} // namespace browser_sync
diff --git a/chrome/browser/sync/glue/session_model_associator.h b/chrome/browser/sync/glue/session_model_associator.h
index 9579140..561f1b5 100644
--- a/chrome/browser/sync/glue/session_model_associator.h
+++ b/chrome/browser/sync/glue/session_model_associator.h
@@ -14,6 +14,7 @@
#include "base/format_macros.h"
#include "base/gtest_prod_util.h"
#include "base/memory/scoped_vector.h"
+#include "base/memory/weak_ptr.h"
#include "base/observer_list.h"
#include "base/stringprintf.h"
#include "base/threading/non_thread_safe.h"
@@ -27,6 +28,7 @@
#include "chrome/browser/sync/glue/synced_window_delegate.h"
#include "chrome/browser/sync/protocol/session_specifics.pb.h"
#include "chrome/browser/sync/syncable/model_type.h"
+#include "chrome/browser/sync/weak_handle.h"
class Profile;
class ProfileSyncService;
@@ -50,6 +52,7 @@ static const char kSessionsTag[] = "google_chrome_sessions";
// the sync sessions model.
class SessionModelAssociator
: public PerDataTypeAssociatorInterface<SyncedTabDelegate, size_t>,
+ public base::SupportsWeakPtr<SessionModelAssociator>,
public base::NonThreadSafe {
public:
// Does not take ownership of sync_service.
@@ -183,6 +186,23 @@ class SessionModelAssociator
// when a local change is made, or when timeout_milli occurs, whichever is
// first.
void BlockUntilLocalChangeForTest(int64 timeout_milli);
+
+ // Callback for when the session name has been computed.
+ void OnSessionNameInitialized(const std::string name);
+
+#if defined(OS_WIN)
+ // Returns the computer name or the empty string an error occurred.
+ static std::string GetComputerName();
+#endif
+
+#if defined(OS_MACOSX)
+ // Returns the Hardware model name, without trailing numbers, if possible.
+ // See http://www.cocoadev.com/index.pl?MacintoshModels for an example list of
+ // models. If an error occurs trying to read the model, this simply returns
+ // "Unknown".
+ static std::string GetHardwareModelName();
+#endif
+
private:
FRIEND_TEST_ALL_PREFIXES(ProfileSyncServiceSessionTest, WriteSessionToNode);
FRIEND_TEST_ALL_PREFIXES(ProfileSyncServiceSessionTest,
@@ -191,8 +211,11 @@ class SessionModelAssociator
WriteForeignSessionToNode);
FRIEND_TEST_ALL_PREFIXES(ProfileSyncServiceSessionTest, TabNodePoolEmpty);
FRIEND_TEST_ALL_PREFIXES(ProfileSyncServiceSessionTest, TabNodePoolNonEmpty);
+ FRIEND_TEST_ALL_PREFIXES(SessionModelAssociatorTest, PopulateSessionHeader);
FRIEND_TEST_ALL_PREFIXES(SessionModelAssociatorTest, PopulateSessionWindow);
FRIEND_TEST_ALL_PREFIXES(SessionModelAssociatorTest, PopulateSessionTab);
+ FRIEND_TEST_ALL_PREFIXES(SessionModelAssociatorTest,
+ InitializeCurrentSessionName);
// Keep all the links to local tab data in one place.
class TabLinks {
@@ -321,6 +344,9 @@ class SessionModelAssociator
// Initializes the tag corresponding to this machine.
void InitializeCurrentMachineTag(sync_api::WriteTransaction* trans);
+ // Initializes the user visible name for this session
+ void InitializeCurrentSessionName();
+
// Updates the server data based upon the current client session. If no node
// corresponding to this machine exists in the sync model, one is created.
void UpdateSyncModelDataFromClient();
@@ -338,6 +364,12 @@ class SessionModelAssociator
const int64 sync_id,
sync_api::WriteTransaction* trans);
+ // Used to populate a session header from the session specifics header
+ // provided.
+ static void PopulateSessionHeaderFromSpecifics(
+ const sync_pb::SessionHeader& header_specifics,
+ SyncedSession* session_header);
+
// Used to populate a session window from the session specifics window
// provided. Tracks any foreign session data created through |tracker|.
static void PopulateSessionWindowFromSpecifics(
@@ -395,9 +427,12 @@ class SessionModelAssociator
// For testing only.
void QuitLoopForTest();
- // Local client name.
+ // Unique client tag.
std::string current_machine_tag_;
+ // User-visible machine name.
+ std::string current_session_name_;
+
// Pool of all used/available sync nodes associated with tabs.
TabNodePool tab_pool_;
diff --git a/chrome/browser/sync/glue/session_model_associator_mac.mm b/chrome/browser/sync/glue/session_model_associator_mac.mm
new file mode 100644
index 0000000..16635b2
--- /dev/null
+++ b/chrome/browser/sync/glue/session_model_associator_mac.mm
@@ -0,0 +1,52 @@
+// Copyright (c) 2011 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include "chrome/browser/sync/glue/session_model_associator.h"
+
+#import <Foundation/Foundation.h>
+#import <SystemConfiguration/SCDynamicStoreCopySpecific.h>
+#include <sys/sysctl.h> // sysctlbyname()
+
+#include "base/mac/foundation_util.h"
+#include "base/mac/mac_util.h"
+#include "base/memory/scoped_nsobject.h"
+#include "base/string_util.h"
+#include "base/sys_info.h"
+#include "base/sys_string_conversions.h"
+
+@interface NSHost(SnowLeopardAPI)
+- (NSString*)localizedName;
+@end
+
+namespace browser_sync {
+
+// Static
+std::string SessionModelAssociator::GetHardwareModelName() {
+ NSHost* myHost = [NSHost currentHost];
+ if ([myHost respondsToSelector:@selector(localizedName)]) {
+ return base::SysNSStringToUTF8([myHost localizedName]);
+ }
+ // Fallback for 10.5
+ scoped_nsobject<NSString> computerName(base::mac::CFToNSCast(
+ SCDynamicStoreCopyComputerName(NULL, NULL)));
+ if (computerName.get() != NULL) {
+ return base::SysNSStringToUTF8(computerName.get());
+ }
+
+ // If all else fails, return to using a slightly nicer version of the
+ // hardware model.
+ char modelBuffer[256];
+ size_t length = sizeof(modelBuffer);
+ if (!sysctlbyname("hw.model", modelBuffer, &length, NULL, 0)) {
+ for (size_t i = 0; i < length; i++) {
+ if (IsAsciiDigit(modelBuffer[i])) {
+ return std::string(modelBuffer, 0, i);
+ }
+ }
+ return std::string(modelBuffer, 0, length);
+ }
+ return "Unknown";
+}
+
+} // namespace browser_sync
diff --git a/chrome/browser/sync/glue/session_model_associator_unittest.cc b/chrome/browser/sync/glue/session_model_associator_unittest.cc
index b6c5986..f3f7b29 100644
--- a/chrome/browser/sync/glue/session_model_associator_unittest.cc
+++ b/chrome/browser/sync/glue/session_model_associator_unittest.cc
@@ -15,6 +15,7 @@
using browser_sync::SessionModelAssociator;
using browser_sync::SyncedSessionTracker;
+
namespace browser_sync {
typedef testing::Test SessionModelAssociatorTest;
@@ -51,6 +52,18 @@ TEST_F(SessionModelAssociatorTest, IsValidSessionTab) {
ASSERT_TRUE(SessionModelAssociator::IsValidSessionTab(tab));
}
+TEST_F(SessionModelAssociatorTest, PopulateSessionHeader) {
+ sync_pb::SessionHeader header_s;
+ header_s.set_client_name("Client 1");
+ header_s.set_device_type(sync_pb::SessionHeader_DeviceType_TYPE_WIN);
+
+ SyncedSession session;
+ SessionModelAssociator::PopulateSessionHeaderFromSpecifics(
+ header_s, &session);
+ ASSERT_EQ("Client 1", session.session_name);
+ ASSERT_EQ(SyncedSession::TYPE_WIN, session.device_type);
+}
+
TEST_F(SessionModelAssociatorTest, PopulateSessionWindow) {
sync_pb::SessionWindow window_s;
window_s.add_tab(0);
@@ -158,5 +171,22 @@ TEST_F(SessionModelAssociatorTest, SyncedSessionTracker) {
ASSERT_EQ(0U, tracker.num_synced_sessions());
}
-} // namespace browser_sync
+#if defined(OS_WIN)
+// The test is somewhat silly, and just verifies that we return a computer name.
+TEST(SessionModelAssociatorTest, TestGetComputerName) {
+ std::string computer_name = SessionModelAssociator::GetComputerName();
+ EXPECT_TRUE(!computer_name.empty());
+}
+#endif
+
+#if defined(OS_MACOSX)
+// The test is somewhat silly, and just verifies that we return a hardware
+// model name.
+TEST_F(SessionModelAssociatorTest, GetHardwareModelName) {
+ std::string hardware_model = SessionModelAssociator::GetHardwareModelName();
+ EXPECT_TRUE(!hardware_model.empty());
+}
+#endif
+
+} // namespace browser_sync
diff --git a/chrome/browser/sync/glue/synced_session.cc b/chrome/browser/sync/glue/synced_session.cc
new file mode 100644
index 0000000..18011c8
--- /dev/null
+++ b/chrome/browser/sync/glue/synced_session.cc
@@ -0,0 +1,19 @@
+// Copyright (c) 2011 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include "chrome/browser/sync/glue/synced_session.h"
+
+#include "base/stl_util.h"
+#include "chrome/browser/sessions/session_types.h"
+
+namespace browser_sync {
+
+SyncedSession::SyncedSession() : session_tag("invalid") {
+}
+
+SyncedSession::~SyncedSession() {
+ STLDeleteElements(&windows);
+}
+
+} // namespace browser_sync
diff --git a/chrome/browser/sync/glue/synced_session.h b/chrome/browser/sync/glue/synced_session.h
new file mode 100644
index 0000000..fcac6ecd
--- /dev/null
+++ b/chrome/browser/sync/glue/synced_session.h
@@ -0,0 +1,42 @@
+// Copyright (c) 2011 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#ifndef CHROME_BROWSER_SYNC_GLUE_SYNCED_SESSION_H_
+#define CHROME_BROWSER_SYNC_GLUE_SYNCED_SESSION_H_
+#pragma once
+
+#include <string>
+#include <vector>
+
+struct SessionWindow;
+
+namespace browser_sync {
+
+// Defines a synced session for use by session sync. A synced session is a
+// list of windows along with a unique session identifer (tag) and meta-data
+// about the device being synced.
+struct SyncedSession {
+ // The type of device.
+ enum DeviceType {
+ TYPE_WIN = 1,
+ TYPE_MACOSX = 2,
+ TYPE_LINUX = 3,
+ TYPE_CHROMEOS = 4,
+ TYPE_OTHER = 5
+ };
+
+ SyncedSession();
+ ~SyncedSession();
+
+ // Unique tag for each session.
+ std::string session_tag;
+ // User-visible name
+ std::string session_name;
+ DeviceType device_type;
+ std::vector<SessionWindow*> windows;
+};
+
+} // namespace browser_sync
+
+#endif // CHROME_BROWSER_SYNC_GLUE_SYNCED_SESSION_H_
diff --git a/chrome/browser/sync/glue/synced_session_tracker.h b/chrome/browser/sync/glue/synced_session_tracker.h
index c0088bd..5140f90 100644
--- a/chrome/browser/sync/glue/synced_session_tracker.h
+++ b/chrome/browser/sync/glue/synced_session_tracker.h
@@ -15,6 +15,7 @@
#include "base/memory/scoped_vector.h"
#include "chrome/browser/sessions/session_id.h"
#include "chrome/browser/sessions/session_types.h"
+#include "chrome/browser/sync/glue/synced_session.h"
namespace browser_sync {
diff --git a/chrome/browser/sync/profile_sync_service_session_unittest.cc b/chrome/browser/sync/profile_sync_service_session_unittest.cc
index 5c74b74..e47aa20 100644
--- a/chrome/browser/sync/profile_sync_service_session_unittest.cc
+++ b/chrome/browser/sync/profile_sync_service_session_unittest.cc
@@ -207,6 +207,8 @@ TEST_F(ProfileSyncServiceSessionTest, WriteSessionToNode) {
ASSERT_EQ(machine_tag, specifics.session_tag());
ASSERT_TRUE(specifics.has_header());
const sync_pb::SessionHeader& header_s = specifics.header();
+ ASSERT_TRUE(header_s.has_device_type());
+ ASSERT_EQ("TestSessionName", header_s.client_name());
ASSERT_EQ(0, header_s.window_size());
}
diff --git a/chrome/browser/ui/webui/sessions_ui.cc b/chrome/browser/ui/webui/sessions_ui.cc
index 4522ddf..0638252 100644
--- a/chrome/browser/ui/webui/sessions_ui.cc
+++ b/chrome/browser/ui/webui/sessions_ui.cc
@@ -8,6 +8,7 @@
#include "chrome/browser/profiles/profile.h"
#include "chrome/browser/sync/glue/session_model_associator.h"
+#include "chrome/browser/sync/glue/synced_session.h"
#include "chrome/browser/sync/profile_sync_service.h"
#include "chrome/browser/ui/webui/chrome_url_data_manager.h"
#include "chrome/browser/ui/webui/chrome_web_ui_data_source.h"
@@ -81,16 +82,19 @@ class SessionsDOMHandler : public WebUIMessageHandler {
ListValue* window_list);
// Appends each entry in |sessions| to |session_list| as a DictonaryValue.
- void GetSessionList(const std::vector<const SyncedSession*>& sessions,
- ListValue* session_list);
+ void GetSessionList(
+ const std::vector<const browser_sync::SyncedSession*>& sessions,
+ ListValue* session_list);
// Traverses all tabs in |sessions| and adds them to |all_tabs|.
- void GetAllTabs(const std::vector<const SyncedSession*>& sessions,
- std::vector<SessionTab*>* all_tabs);
+ void GetAllTabs(
+ const std::vector<const browser_sync::SyncedSession*>& sessions,
+ std::vector<SessionTab*>* all_tabs);
// Creates a "magic" list of tabs from all the sessions.
- void CreateMagicTabList(const std::vector<const SyncedSession*>& sessions,
- ListValue* tab_list);
+ void CreateMagicTabList(
+ const std::vector<const browser_sync::SyncedSession*>& sessions,
+ ListValue* tab_list);
DISALLOW_COPY_AND_ASSIGN(SessionsDOMHandler);
};
@@ -168,11 +172,11 @@ void SessionsDOMHandler::GetWindowList(
}
void SessionsDOMHandler::GetSessionList(
- const std::vector<const SyncedSession*>& sessions,
+ const std::vector<const browser_sync::SyncedSession*>& sessions,
ListValue* session_list) {
- for (std::vector<const SyncedSession*>::const_iterator it =
+ for (std::vector<const browser_sync::SyncedSession*>::const_iterator it =
sessions.begin(); it != sessions.end(); ++it) {
- const SyncedSession* session = *it;
+ const browser_sync::SyncedSession* session = *it;
scoped_ptr<DictionaryValue> session_data(new DictionaryValue());
session_data->SetString("tag", session->session_tag);
scoped_ptr<ListValue> window_list(new ListValue());
@@ -183,7 +187,7 @@ void SessionsDOMHandler::GetSessionList(
}
void SessionsDOMHandler::GetAllTabs(
- const std::vector<const SyncedSession*>& sessions,
+ const std::vector<const browser_sync::SyncedSession*>& sessions,
std::vector<SessionTab*>* all_tabs) {
for (size_t i = 0; i < sessions.size(); i++) {
const std::vector<SessionWindow*>& windows = sessions[i]->windows;
@@ -200,7 +204,7 @@ bool CompareTabsByTimestamp(SessionTab* lhs, SessionTab* rhs) {
}
void SessionsDOMHandler::CreateMagicTabList(
- const std::vector<const SyncedSession*>& sessions,
+ const std::vector<const browser_sync::SyncedSession*>& sessions,
ListValue* tab_list) {
std::vector<SessionTab*> all_tabs;
GetAllTabs(sessions, &all_tabs);
@@ -223,7 +227,7 @@ void SessionsDOMHandler::UpdateUI() {
browser_sync::SessionModelAssociator* associator = GetModelAssociator();
// Make sure the associator has been created.
if (associator) {
- std::vector<const SyncedSession*> sessions;
+ std::vector<const browser_sync::SyncedSession*> sessions;
if (associator->GetAllForeignSessions(&sessions)) {
GetSessionList(sessions, &session_list);
CreateMagicTabList(sessions, &magic_list);
diff --git a/chrome/chrome_browser.gypi b/chrome/chrome_browser.gypi
index 15c04cd..2830f8c 100644
--- a/chrome/chrome_browser.gypi
+++ b/chrome/chrome_browser.gypi
@@ -2101,9 +2101,12 @@
'browser/sync/glue/session_data_type_controller.cc',
'browser/sync/glue/session_data_type_controller.h',
'browser/sync/glue/session_model_associator.cc',
+ 'browser/sync/glue/session_model_associator_mac.mm',
'browser/sync/glue/session_model_associator.h',
'browser/sync/glue/syncable_service_adapter.cc',
'browser/sync/glue/syncable_service_adapter.h',
+ 'browser/sync/glue/synced_session.h',
+ 'browser/sync/glue/synced_session.cc',
'browser/sync/glue/synced_window_delegate.h',
'browser/sync/glue/sync_backend_host.cc',
'browser/sync/glue/sync_backend_host.h',
diff --git a/chrome/test/live_sync/performance/sessions_sync_perf_test.cc b/chrome/test/live_sync/performance/sessions_sync_perf_test.cc
index 23a08ef..ecc5b25 100644
--- a/chrome/test/live_sync/performance/sessions_sync_perf_test.cc
+++ b/chrome/test/live_sync/performance/sessions_sync_perf_test.cc
@@ -72,7 +72,7 @@ void SessionsSyncPerfTest::RemoveTabs(int profile) {
int SessionsSyncPerfTest::GetTabCount(int profile) {
int tab_count = 0;
- const SyncedSession* local_session;
+ const browser_sync::SyncedSession* local_session;
SyncedSessionVector sessions;
if (!GetLocalSession(profile, &local_session)) {
diff --git a/chrome/test/live_sync/sessions_helper.cc b/chrome/test/live_sync/sessions_helper.cc
index 24b578d..f3c9447 100644
--- a/chrome/test/live_sync/sessions_helper.cc
+++ b/chrome/test/live_sync/sessions_helper.cc
@@ -23,14 +23,14 @@ using sync_datatype_helper::test;
namespace sessions_helper {
-bool GetLocalSession(int index, const SyncedSession** session) {
+bool GetLocalSession(int index, const browser_sync::SyncedSession** session) {
return test()->GetProfile(index)->GetProfileSyncService()->
GetSessionModelAssociator()->GetLocalSession(session);
}
bool ModelAssociatorHasTabWithUrl(int index, const GURL& url) {
ui_test_utils::RunAllPendingInMessageLoop();
- const SyncedSession* local_session;
+ const browser_sync::SyncedSession* local_session;
if (!GetLocalSession(index, &local_session)) {
return false;
}
@@ -119,7 +119,7 @@ bool WaitForTabsToLoad(int index, const std::vector<GURL>& urls) {
bool GetLocalWindows(int index, SessionWindowVector& local_windows) {
// The local session provided by GetLocalSession is owned, and has lifetime
// controlled, by the model associator, so we must make our own copy.
- const SyncedSession* local_session;
+ const browser_sync::SyncedSession* local_session;
if (!GetLocalSession(index, &local_session)) {
return false;
}
@@ -161,7 +161,7 @@ bool CheckInitialState(int index) {
}
int GetNumWindows(int index) {
- const SyncedSession* local_session;
+ const browser_sync::SyncedSession* local_session;
if (!GetLocalSession(index, &local_session)) {
return 0;
}
@@ -204,7 +204,8 @@ void SortSessionWindows(SessionWindowVector& windows) {
CompareSessionWindows);
}
-bool CompareSyncedSessions(const SyncedSession* lhs, const SyncedSession* rhs) {
+bool CompareSyncedSessions(const browser_sync::SyncedSession* lhs,
+ const browser_sync::SyncedSession* rhs) {
if (!lhs ||
!rhs ||
lhs->windows.size() < 1 ||
diff --git a/chrome/test/live_sync/sessions_helper.h b/chrome/test/live_sync/sessions_helper.h
index bf8a39d..5ca01fd 100644
--- a/chrome/test/live_sync/sessions_helper.h
+++ b/chrome/test/live_sync/sessions_helper.h
@@ -11,12 +11,13 @@
#include "base/compiler_specific.h"
#include "chrome/browser/sessions/session_types.h"
+#include "chrome/browser/sync/glue/synced_session.h"
#include "chrome/browser/sync/engine/nigori_util.h"
#include "chrome/test/live_sync/live_sync_test.h"
class GURL;
-typedef std::vector<const SyncedSession*> SyncedSessionVector;
+typedef std::vector<const browser_sync::SyncedSession*> SyncedSessionVector;
typedef std::vector<SessionWindow*> SessionWindowVector;
namespace sessions_helper {
@@ -55,7 +56,8 @@ void SortSessionWindows(SessionWindowVector& windows);
// Compares a foreign session based on the first session window.
// Returns true based on the comparison of the session windows.
-bool CompareSyncedSessions(const SyncedSession* lhs, const SyncedSession* rhs);
+bool CompareSyncedSessions(const browser_sync::SyncedSession* lhs,
+ const browser_sync::SyncedSession* rhs);
// Sort a SyncedSession vector using our custom SyncedSession comparator.
void SortSyncedSessions(SyncedSessionVector* sessions);
@@ -102,7 +104,7 @@ bool ModelAssociatorHasTabWithUrl(int index, const GURL& url);
// Stores a pointer to the local session for a given profile in |session|.
// Returns true on success, false on failure.
-bool GetLocalSession(int index, const SyncedSession** session);
+bool GetLocalSession(int index, const browser_sync::SyncedSession** session);
} // namespace sessions_helper