summaryrefslogtreecommitdiff
path: root/chrome/browser/sync/glue
diff options
context:
space:
mode:
authorTorne (Richard Coles) <torne@google.com>2013-08-30 15:14:49 +0100
committerTorne (Richard Coles) <torne@google.com>2013-08-30 15:14:49 +0100
commit424c4d7b64af9d0d8fd9624f381f469654d5e3d2 (patch)
treeaf8b16dc2ba7fc8c8bb1c9fa18b907c847f3883d /chrome/browser/sync/glue
parentc70ef2906f891fe7d218980660e4cda465717916 (diff)
downloadchromium_org-424c4d7b64af9d0d8fd9624f381f469654d5e3d2.tar.gz
Merge from Chromium at DEPS revision r220549
This commit was generated by merge_to_master.py. Change-Id: I8fcb82db764ec1eb0294280936c177bd9ba8a9e9
Diffstat (limited to 'chrome/browser/sync/glue')
-rw-r--r--chrome/browser/sync/glue/session_model_associator.cc24
-rw-r--r--chrome/browser/sync/glue/session_model_associator_unittest.cc7
-rw-r--r--chrome/browser/sync/glue/sync_backend_host.cc10
-rw-r--r--chrome/browser/sync/glue/synced_device_tracker.cc11
-rw-r--r--chrome/browser/sync/glue/synced_device_tracker.h18
-rw-r--r--chrome/browser/sync/glue/synced_tab_delegate.h1
-rw-r--r--chrome/browser/sync/glue/synced_tab_delegate_android.cc6
-rw-r--r--chrome/browser/sync/glue/synced_tab_delegate_android.h1
8 files changed, 74 insertions, 4 deletions
diff --git a/chrome/browser/sync/glue/session_model_associator.cc b/chrome/browser/sync/glue/session_model_associator.cc
index 0598340460..10e8feb5d3 100644
--- a/chrome/browser/sync/glue/session_model_associator.cc
+++ b/chrome/browser/sync/glue/session_model_associator.cc
@@ -17,6 +17,9 @@
#include "chrome/browser/chrome_notification_types.h"
#include "chrome/browser/favicon/favicon_service_factory.h"
#include "chrome/browser/history/history_service.h"
+#if !defined(OS_ANDROID)
+#include "chrome/browser/network_time/navigation_time_helper.h"
+#endif
#include "chrome/browser/prefs/pref_service_syncable.h"
#include "chrome/browser/profiles/profile.h"
#include "chrome/browser/sessions/session_id.h"
@@ -503,6 +506,15 @@ void SessionModelAssociator::SetSessionTabFromDelegate(
tab_delegate.GetEntryCount());
bool is_managed = tab_delegate.ProfileIsManaged();
session_tab->navigations.clear();
+
+#if !defined(OS_ANDROID)
+ // For getting navigation time in network time.
+ NavigationTimeHelper* nav_time_helper =
+ tab_delegate.HasWebContents() ?
+ NavigationTimeHelper::FromWebContents(tab_delegate.GetWebContents()) :
+ NULL;
+#endif
+
for (int i = min_index; i < max_index; ++i) {
const NavigationEntry* entry = (i == pending_index) ?
tab_delegate.GetPendingEntry() : tab_delegate.GetEntryAtIndex(i);
@@ -510,8 +522,17 @@ void SessionModelAssociator::SetSessionTabFromDelegate(
if (!entry->GetVirtualURL().is_valid())
continue;
+ scoped_ptr<content::NavigationEntry> network_time_entry(
+ content::NavigationEntry::Create(*entry));
+#if !defined(OS_ANDROID)
+ if (nav_time_helper) {
+ network_time_entry->SetTimestamp(
+ nav_time_helper->GetNavigationTime(entry));
+ }
+#endif
+
session_tab->navigations.push_back(
- SerializedNavigationEntry::FromNavigationEntry(i, *entry));
+ SerializedNavigationEntry::FromNavigationEntry(i, *network_time_entry));
if (is_managed) {
session_tab->navigations.back().set_blocked_state(
SerializedNavigationEntry::STATE_ALLOWED);
@@ -526,6 +547,7 @@ void SessionModelAssociator::SetSessionTabFromDelegate(
session_tab->navigations.push_back(
SerializedNavigationEntry::FromNavigationEntry(
i + offset, *blocked_navigations[i]));
+ // Blocked navigations already use network navigation time.
session_tab->navigations.back().set_blocked_state(
SerializedNavigationEntry::STATE_BLOCKED);
// TODO(bauerb): Add categories
diff --git a/chrome/browser/sync/glue/session_model_associator_unittest.cc b/chrome/browser/sync/glue/session_model_associator_unittest.cc
index a88354658a..a380168e8f 100644
--- a/chrome/browser/sync/glue/session_model_associator_unittest.cc
+++ b/chrome/browser/sync/glue/session_model_associator_unittest.cc
@@ -190,6 +190,7 @@ class SyncedTabDelegateMock : public SyncedTabDelegate {
const std::vector<const content::NavigationEntry*>*());
MOCK_CONST_METHOD0(IsPinned, bool());
MOCK_CONST_METHOD0(HasWebContents, bool());
+ MOCK_CONST_METHOD0(GetWebContents, content::WebContents*());
MOCK_CONST_METHOD0(GetSyncId, int());
MOCK_METHOD1(SetSyncId, void(int));
};
@@ -325,14 +326,17 @@ TEST_F(SyncSessionModelAssociatorTest, SetSessionTabFromDelegate) {
content::NavigationEntry::Create());
entry1->SetVirtualURL(GURL("http://www.google.com"));
entry1->SetTimestamp(kTime1);
+ entry1->SetHttpStatusCode(200);
scoped_ptr<content::NavigationEntry> entry2(
content::NavigationEntry::Create());
entry2->SetVirtualURL(GURL("http://www.noodle.com"));
entry2->SetTimestamp(kTime2);
+ entry2->SetHttpStatusCode(201);
scoped_ptr<content::NavigationEntry> entry3(
content::NavigationEntry::Create());
entry3->SetVirtualURL(GURL("http://www.doodle.com"));
entry3->SetTimestamp(kTime3);
+ entry3->SetHttpStatusCode(202);
EXPECT_CALL(tab_mock, GetCurrentEntryIndex()).WillRepeatedly(Return(2));
EXPECT_CALL(tab_mock, GetEntryAtIndex(0)).WillRepeatedly(
Return(entry1.get()));
@@ -377,6 +381,9 @@ TEST_F(SyncSessionModelAssociatorTest, SetSessionTabFromDelegate) {
EXPECT_EQ(kTime1, session_tab.navigations[0].timestamp());
EXPECT_EQ(kTime2, session_tab.navigations[1].timestamp());
EXPECT_EQ(kTime3, session_tab.navigations[2].timestamp());
+ EXPECT_EQ(200, session_tab.navigations[0].http_status_code());
+ EXPECT_EQ(201, session_tab.navigations[1].http_status_code());
+ EXPECT_EQ(202, session_tab.navigations[2].http_status_code());
EXPECT_EQ(SerializedNavigationEntry::STATE_INVALID,
session_tab.navigations[0].blocked_state());
EXPECT_EQ(SerializedNavigationEntry::STATE_INVALID,
diff --git a/chrome/browser/sync/glue/sync_backend_host.cc b/chrome/browser/sync/glue/sync_backend_host.cc
index 7843081958..2f91728d69 100644
--- a/chrome/browser/sync/glue/sync_backend_host.cc
+++ b/chrome/browser/sync/glue/sync_backend_host.cc
@@ -655,6 +655,14 @@ void SyncBackendHost::ConfigureDataTypes(
GetDataTypesInState(CONFIGURE_INACTIVE, config_state_map);
types_to_purge.RemoveAll(inactive_types);
+ // If a type has already been disabled and unapplied or journaled, it will
+ // not be part of the |types_to_purge| set, and therefore does not need
+ // to be acted on again.
+ fatal_types.RetainAll(types_to_purge);
+ syncer::ModelTypeSet unapply_types =
+ syncer::Union(crypto_types, clean_first_types);
+ unapply_types.RetainAll(types_to_purge);
+
DCHECK(syncer::Intersection(current_types, fatal_types).Empty());
DCHECK(syncer::Intersection(current_types, crypto_types).Empty());
DCHECK(current_types.HasAll(types_to_download));
@@ -678,7 +686,7 @@ void SyncBackendHost::ConfigureDataTypes(
types_to_download,
types_to_purge,
fatal_types,
- syncer::Union(crypto_types, clean_first_types),
+ unapply_types,
inactive_types,
routing_info,
ready_task,
diff --git a/chrome/browser/sync/glue/synced_device_tracker.cc b/chrome/browser/sync/glue/synced_device_tracker.cc
index 3db32a991f..e4fd61a942 100644
--- a/chrome/browser/sync/glue/synced_device_tracker.cc
+++ b/chrome/browser/sync/glue/synced_device_tracker.cc
@@ -32,6 +32,7 @@ SyncedDeviceTracker::SyncedDeviceTracker(syncer::UserShare* user_share,
user_share_(user_share),
cache_guid_(cache_guid),
local_device_info_tag_(DeviceInfoLookupString(cache_guid)) {
+ observers_ = new ObserverListThreadSafe<Observer>;
}
SyncedDeviceTracker::~SyncedDeviceTracker() {
@@ -49,7 +50,7 @@ void SyncedDeviceTracker::ApplyChangesFromSyncModel(
}
void SyncedDeviceTracker::CommitChangesFromSyncModel() {
- // TODO(sync): notify our listeners.
+ observers_->Notify(&Observer::OnDeviceInfoChange);
}
scoped_ptr<DeviceInfo> SyncedDeviceTracker::ReadLocalDeviceInfo() const {
@@ -132,6 +133,14 @@ void SyncedDeviceTracker::GetAllSyncedDeviceInfo(
}
}
+void SyncedDeviceTracker::AddObserver(Observer* observer) {
+ observers_->AddObserver(observer);
+}
+
+void SyncedDeviceTracker::RemoveObserver(Observer* observer) {
+ observers_->RemoveObserver(observer);
+}
+
void SyncedDeviceTracker::InitLocalDeviceInfo(const base::Closure& callback) {
DeviceInfo::CreateLocalDeviceInfo(
cache_guid_,
diff --git a/chrome/browser/sync/glue/synced_device_tracker.h b/chrome/browser/sync/glue/synced_device_tracker.h
index 877d83310b..ce72aea201 100644
--- a/chrome/browser/sync/glue/synced_device_tracker.h
+++ b/chrome/browser/sync/glue/synced_device_tracker.h
@@ -11,6 +11,7 @@
#include "base/memory/scoped_ptr.h"
#include "base/memory/scoped_vector.h"
#include "base/memory/weak_ptr.h"
+#include "base/observer_list_threadsafe.h"
#include "chrome/browser/sync/glue/change_processor.h"
namespace syncer {
@@ -27,6 +28,12 @@ class SyncedDeviceTracker : public ChangeProcessor {
const std::string& cache_guid);
virtual ~SyncedDeviceTracker();
+ // Observer class for listening to device info changes.
+ class Observer {
+ public:
+ virtual void OnDeviceInfoChange() = 0;
+ };
+
// ChangeProcessor methods
virtual void StartImpl(Profile* profile) OVERRIDE;
virtual void ApplyChangesFromSyncModel(
@@ -46,6 +53,12 @@ class SyncedDeviceTracker : public ChangeProcessor {
virtual void GetAllSyncedDeviceInfo(
ScopedVector<DeviceInfo>* device_info) const;
+ // Can be called on any thread. Will be notified back on the same thread
+ // they were called on. Observer will be called on every device info
+ // change.
+ void AddObserver(Observer* observer);
+ void RemoveObserver(Observer* observer);
+
private:
friend class SyncedDeviceTrackerTest;
@@ -66,6 +79,11 @@ class SyncedDeviceTracker : public ChangeProcessor {
const std::string cache_guid_;
const std::string local_device_info_tag_;
+ // The |ObserverList| has to be thread safe as the changes happen
+ // on sync thread and the observers could be on any thread.
+ typedef ObserverListThreadSafe<Observer> ObserverList;
+ scoped_refptr<ObserverList> observers_;
+
DISALLOW_COPY_AND_ASSIGN(SyncedDeviceTracker);
};
diff --git a/chrome/browser/sync/glue/synced_tab_delegate.h b/chrome/browser/sync/glue/synced_tab_delegate.h
index a4033a4f72..008748ecaa 100644
--- a/chrome/browser/sync/glue/synced_tab_delegate.h
+++ b/chrome/browser/sync/glue/synced_tab_delegate.h
@@ -53,6 +53,7 @@ class SyncedTabDelegate {
virtual bool IsPinned() const = 0;
virtual bool HasWebContents() const = 0;
+ virtual content::WebContents* GetWebContents() const = 0;
// Session sync related methods.
virtual int GetSyncId() const = 0;
diff --git a/chrome/browser/sync/glue/synced_tab_delegate_android.cc b/chrome/browser/sync/glue/synced_tab_delegate_android.cc
index 300b90a4b7..8585537c6a 100644
--- a/chrome/browser/sync/glue/synced_tab_delegate_android.cc
+++ b/chrome/browser/sync/glue/synced_tab_delegate_android.cc
@@ -30,7 +30,7 @@ SessionID::id_type SyncedTabDelegateAndroid::GetWindowId() const {
}
SessionID::id_type SyncedTabDelegateAndroid::GetSessionId() const {
- return tab_android_->id().id();
+ return tab_android_->session_id().id();
}
bool SyncedTabDelegateAndroid::IsBeingDestroyed() const {
@@ -87,6 +87,10 @@ bool SyncedTabDelegateAndroid::HasWebContents() const {
return web_contents_ != NULL;
}
+content::WebContents* SyncedTabDelegateAndroid::GetWebContents() const {
+ return web_contents_;
+}
+
void SyncedTabDelegateAndroid::SetWebContents(
content::WebContents* web_contents) {
web_contents_ = web_contents;
diff --git a/chrome/browser/sync/glue/synced_tab_delegate_android.h b/chrome/browser/sync/glue/synced_tab_delegate_android.h
index 35502775b5..90d239afa8 100644
--- a/chrome/browser/sync/glue/synced_tab_delegate_android.h
+++ b/chrome/browser/sync/glue/synced_tab_delegate_android.h
@@ -38,6 +38,7 @@ class SyncedTabDelegateAndroid : public browser_sync::SyncedTabDelegate {
virtual content::NavigationEntry* GetActiveEntry() const OVERRIDE;
virtual bool IsPinned() const OVERRIDE;
virtual bool HasWebContents() const OVERRIDE;
+ virtual content::WebContents* GetWebContents() const OVERRIDE;
virtual int GetSyncId() const OVERRIDE;
virtual void SetSyncId(int sync_id) OVERRIDE;