summaryrefslogtreecommitdiffstats
path: root/chrome
diff options
context:
space:
mode:
authorstanisc <stanisc@chromium.org>2014-09-22 09:46:49 -0700
committerCommit bot <commit-bot@chromium.org>2014-09-22 16:47:08 +0000
commit3724e60a79c733002e5f3391809f733ae843c8bb (patch)
treeceb490dee0879c7be4b2e9ea80821d3731d993d3 /chrome
parente88496b3ee30a5fbb97a91a6afa6ce143036ca84 (diff)
downloadchromium_src-3724e60a79c733002e5f3391809f733ae843c8bb.zip
chromium_src-3724e60a79c733002e5f3391809f733ae843c8bb.tar.gz
chromium_src-3724e60a79c733002e5f3391809f733ae843c8bb.tar.bz2
Refactor syncable DEVICE_INFO type from ChangeProcessor to SyncableService - part 3.
This change integrates DeviceIfoSyncService and DeviceInfoDataTypeController introduced in an early change with the rest of the Sync code and removes the old implementation of DEVICE_INFO sync type based on SyncedDeviceTracker. As a part of this change DEVICE_INFO stops being a specially implemented control type and becomes a priority type with implementation that follows pattern of the majority of other sync types. This should help to do some further refactoring including decoupling of DeviceInfo sync code from the browser and moving it to sync_driver component. This change also adds support for syncing of local device backup timestamp to DeviceInfoSyncService. This functionality was missing when DeviceInfoSyncService was initially introduced. BUG=395349 Review URL: https://codereview.chromium.org/566623003 Cr-Commit-Position: refs/heads/master@{#295992}
Diffstat (limited to 'chrome')
-rw-r--r--chrome/browser/extensions/api/sessions/sessions_apitest.cc2
-rw-r--r--chrome/browser/extensions/api/signed_in_devices/signed_in_devices_api.cc24
-rw-r--r--chrome/browser/extensions/api/signed_in_devices/signed_in_devices_api.h4
-rw-r--r--chrome/browser/extensions/api/signed_in_devices/signed_in_devices_api_unittest.cc119
-rw-r--r--chrome/browser/extensions/api/signed_in_devices/signed_in_devices_manager.cc9
-rw-r--r--chrome/browser/extensions/api/signed_in_devices/signed_in_devices_manager.h4
-rw-r--r--chrome/browser/sync/glue/device_info_sync_service.cc157
-rw-r--r--chrome/browser/sync/glue/device_info_sync_service.h32
-rw-r--r--chrome/browser/sync/glue/device_info_sync_service_unittest.cc154
-rw-r--r--chrome/browser/sync/glue/sync_backend_host.h5
-rw-r--r--chrome/browser/sync/glue/sync_backend_host_core.cc32
-rw-r--r--chrome/browser/sync/glue/sync_backend_host_core.h23
-rw-r--r--chrome/browser/sync/glue/sync_backend_host_impl.cc15
-rw-r--r--chrome/browser/sync/glue/sync_backend_host_impl.h2
-rw-r--r--chrome/browser/sync/glue/sync_backend_host_impl_unittest.cc13
-rw-r--r--chrome/browser/sync/glue/sync_backend_host_mock.cc4
-rw-r--r--chrome/browser/sync/glue/sync_backend_host_mock.h2
-rw-r--r--chrome/browser/sync/glue/synced_device_tracker.cc238
-rw-r--r--chrome/browser/sync/glue/synced_device_tracker.h101
-rw-r--r--chrome/browser/sync/glue/synced_device_tracker_unittest.cc242
-rw-r--r--chrome/browser/sync/profile_sync_components_factory_impl.cc10
-rw-r--r--chrome/browser/sync/profile_sync_components_factory_impl_unittest.cc1
-rw-r--r--chrome/browser/sync/profile_sync_service.cc98
-rw-r--r--chrome/browser/sync/profile_sync_service.h30
-rw-r--r--chrome/browser/sync/profile_sync_service_mock.cc9
-rw-r--r--chrome/browser/sync/profile_sync_service_mock.h8
-rw-r--r--chrome/browser/ui/webui/history_ui.cc8
-rw-r--r--chrome/chrome_browser.gypi2
-rw-r--r--chrome/chrome_tests_unit.gypi1
29 files changed, 464 insertions, 885 deletions
diff --git a/chrome/browser/extensions/api/sessions/sessions_apitest.cc b/chrome/browser/extensions/api/sessions/sessions_apitest.cc
index 15a4819b..a10e441 100644
--- a/chrome/browser/extensions/api/sessions/sessions_apitest.cc
+++ b/chrome/browser/extensions/api/sessions/sessions_apitest.cc
@@ -158,7 +158,7 @@ void ExtensionSessionsTest::CreateTestProfileSyncService() {
syncer::ModelTypeSet preferred_types;
preferred_types.Put(syncer::SESSIONS);
GoogleServiceAuthError no_error(GoogleServiceAuthError::NONE);
- ON_CALL(*service, IsSessionsDataTypeControllerRunning())
+ ON_CALL(*service, IsDataTypeControllerRunning(syncer::SESSIONS))
.WillByDefault(testing::Return(true));
ON_CALL(*service, GetRegisteredDataTypes())
.WillByDefault(testing::Return(syncer::UserTypes()));
diff --git a/chrome/browser/extensions/api/signed_in_devices/signed_in_devices_api.cc b/chrome/browser/extensions/api/signed_in_devices/signed_in_devices_api.cc
index d48cc0c..02727a3 100644
--- a/chrome/browser/extensions/api/signed_in_devices/signed_in_devices_api.cc
+++ b/chrome/browser/extensions/api/signed_in_devices/signed_in_devices_api.cc
@@ -9,7 +9,7 @@
#include "base/values.h"
#include "chrome/browser/extensions/api/signed_in_devices/id_mapping_helper.h"
#include "chrome/browser/profiles/profile.h"
-#include "chrome/browser/sync/glue/device_info.h"
+#include "chrome/browser/sync/glue/device_info_tracker.h"
#include "chrome/browser/sync/glue/local_device_info_provider.h"
#include "chrome/browser/sync/profile_sync_service.h"
#include "chrome/browser/sync/profile_sync_service_factory.h"
@@ -18,6 +18,7 @@
using base::DictionaryValue;
using browser_sync::DeviceInfo;
+using browser_sync::DeviceInfoTracker;
using browser_sync::LocalDeviceInfoProvider;
namespace extensions {
@@ -48,13 +49,14 @@ const base::DictionaryValue* GetIdMappingDictionary(
}
// Helper routine to get all signed in devices. The helper takes in
-// the pointers for |ProfileSyncService| and |Extensionprefs|. This
+// the pointers for |DeviceInfoTracker| and |Extensionprefs|. This
// makes it easier to test by passing mock values for these pointers.
ScopedVector<DeviceInfo> GetAllSignedInDevices(
const std::string& extension_id,
- ProfileSyncService* pss,
+ DeviceInfoTracker* device_tracker,
ExtensionPrefs* extension_prefs) {
- ScopedVector<DeviceInfo> devices = pss->GetAllSignedInDevices();
+ DCHECK(device_tracker);
+ ScopedVector<DeviceInfo> devices = device_tracker->GetAllDeviceInfo();
const base::DictionaryValue* mapping_dictionary = GetIdMappingDictionary(
extension_prefs,
extension_id);
@@ -78,14 +80,18 @@ ScopedVector<DeviceInfo> GetAllSignedInDevices(
ScopedVector<DeviceInfo> GetAllSignedInDevices(
const std::string& extension_id,
Profile* profile) {
- // Get the profile sync service and extension prefs pointers
+ // Get the device tracker and extension prefs pointers
// and call the helper.
- ProfileSyncService* pss = ProfileSyncServiceFactory::GetForProfile(profile);
+ DeviceInfoTracker* device_tracker =
+ ProfileSyncServiceFactory::GetForProfile(profile)->GetDeviceInfoTracker();
+ if (device_tracker == NULL) {
+ // Devices are not sync'ing.
+ return ScopedVector<DeviceInfo>().Pass();
+ }
+
ExtensionPrefs* extension_prefs = ExtensionPrefs::Get(profile);
- return GetAllSignedInDevices(extension_id,
- pss,
- extension_prefs);
+ return GetAllSignedInDevices(extension_id, device_tracker, extension_prefs);
}
scoped_ptr<DeviceInfo> GetLocalDeviceInfo(const std::string& extension_id,
diff --git a/chrome/browser/extensions/api/signed_in_devices/signed_in_devices_api.h b/chrome/browser/extensions/api/signed_in_devices/signed_in_devices_api.h
index c6f2643..774ca75 100644
--- a/chrome/browser/extensions/api/signed_in_devices/signed_in_devices_api.h
+++ b/chrome/browser/extensions/api/signed_in_devices/signed_in_devices_api.h
@@ -13,6 +13,7 @@
namespace browser_sync {
class DeviceInfo;
+class DeviceInfoTracker;
} // namespace browser_sync
namespace extensions {
@@ -20,7 +21,6 @@ class ExtensionPrefs;
} // namespace extensions
class Profile;
-class ProfileSyncService;
namespace extensions {
@@ -34,7 +34,7 @@ ScopedVector<browser_sync::DeviceInfo> GetAllSignedInDevices(
ScopedVector<browser_sync::DeviceInfo> GetAllSignedInDevices(
const std::string& extension_id,
- ProfileSyncService* pss,
+ browser_sync::DeviceInfoTracker* device_tracker,
ExtensionPrefs* extension_prefs);
class SignedInDevicesGetFunction : public ChromeSyncExtensionFunction {
diff --git a/chrome/browser/extensions/api/signed_in_devices/signed_in_devices_api_unittest.cc b/chrome/browser/extensions/api/signed_in_devices/signed_in_devices_api_unittest.cc
index f98b954..1ee7dd3 100644
--- a/chrome/browser/extensions/api/signed_in_devices/signed_in_devices_api_unittest.cc
+++ b/chrome/browser/extensions/api/signed_in_devices/signed_in_devices_api_unittest.cc
@@ -23,13 +23,56 @@
#include "testing/gtest/include/gtest/gtest.h"
using browser_sync::DeviceInfo;
+using browser_sync::DeviceInfoTracker;
using testing::Return;
namespace extensions {
+class MockDeviceInfoTracker : public DeviceInfoTracker {
+ public:
+ virtual ~MockDeviceInfoTracker() {}
+
+ virtual scoped_ptr<DeviceInfo> GetDeviceInfo(
+ const std::string& client_id) const OVERRIDE {
+ NOTREACHED();
+ return scoped_ptr<DeviceInfo>();
+ }
+
+ static DeviceInfo* CloneDeviceInfo(const DeviceInfo* device_info) {
+ return new DeviceInfo(device_info->guid(),
+ device_info->client_name(),
+ device_info->chrome_version(),
+ device_info->sync_user_agent(),
+ device_info->device_type(),
+ device_info->signin_scoped_device_id());
+ }
+
+ virtual ScopedVector<DeviceInfo> GetAllDeviceInfo() const OVERRIDE {
+ ScopedVector<DeviceInfo> list;
+
+ for (std::vector<const DeviceInfo*>::const_iterator iter = devices_.begin();
+ iter != devices_.end();
+ ++iter) {
+ list.push_back(CloneDeviceInfo(*iter));
+ }
+
+ return list.Pass();
+ }
+
+ virtual void AddObserver(Observer* observer) OVERRIDE { NOTREACHED(); }
+
+ virtual void RemoveObserver(Observer* observer) OVERRIDE { NOTREACHED(); }
+
+ void Add(const DeviceInfo* device) { devices_.push_back(device); }
+
+ private:
+ // DeviceInfo stored here are not owned.
+ std::vector<const DeviceInfo*> devices_;
+};
+
TEST(SignedInDevicesAPITest, GetSignedInDevices) {
TestingProfile profile;
- ProfileSyncServiceMock pss_mock(&profile);
+ MockDeviceInfoTracker device_tracker;
base::MessageLoop message_loop_;
TestExtensionPrefs extension_prefs(
message_loop_.message_loop_proxy().get());
@@ -53,29 +96,19 @@ TEST(SignedInDevicesAPITest, GetSignedInDevices) {
sync_pb::SyncEnums_DeviceType_TYPE_LINUX,
"device_id");
- std::vector<DeviceInfo*> devices;
- devices.push_back(&device_info1);
- devices.push_back(&device_info2);
-
- EXPECT_CALL(pss_mock, GetAllSignedInDevicesMock()).
- WillOnce(Return(&devices));
+ device_tracker.Add(&device_info1);
+ device_tracker.Add(&device_info2);
ScopedVector<DeviceInfo> output1 = GetAllSignedInDevices(
- extension_test.get()->id(),
- &pss_mock,
- extension_prefs.prefs());
+ extension_test.get()->id(), &device_tracker, extension_prefs.prefs());
- std::string public_id1 = device_info1.public_id();
- std::string public_id2 = device_info2.public_id();
+ std::string public_id1 = output1[0]->public_id();
+ std::string public_id2 = output1[1]->public_id();
EXPECT_FALSE(public_id1.empty());
EXPECT_FALSE(public_id2.empty());
EXPECT_NE(public_id1, public_id2);
- // Now clear output1 so its destructor will not destroy the pointers for
- // |device_info1| and |device_info2|.
- output1.weak_clear();
-
// Add a third device and make sure the first 2 ids are retained and a new
// id is generated for the third device.
DeviceInfo device_info3(base::GenerateGUID(),
@@ -85,27 +118,18 @@ TEST(SignedInDevicesAPITest, GetSignedInDevices) {
sync_pb::SyncEnums_DeviceType_TYPE_LINUX,
"device_id");
- devices.push_back(&device_info3);
-
- EXPECT_CALL(pss_mock, GetAllSignedInDevicesMock()).
- WillOnce(Return(&devices));
+ device_tracker.Add(&device_info3);
ScopedVector<DeviceInfo> output2 = GetAllSignedInDevices(
- extension_test.get()->id(),
- &pss_mock,
- extension_prefs.prefs());
+ extension_test.get()->id(), &device_tracker, extension_prefs.prefs());
- EXPECT_EQ(device_info1.public_id(), public_id1);
- EXPECT_EQ(device_info2.public_id(), public_id2);
+ EXPECT_EQ(output2[0]->public_id(), public_id1);
+ EXPECT_EQ(output2[1]->public_id(), public_id2);
- std::string public_id3 = device_info3.public_id();
+ std::string public_id3 = output2[2]->public_id();
EXPECT_FALSE(public_id3.empty());
EXPECT_NE(public_id3, public_id1);
EXPECT_NE(public_id3, public_id2);
-
- // Now clear output2 so that its destructor does not destroy the
- // |DeviceInfo| pointers.
- output2.weak_clear();
}
class ProfileSyncServiceMockForExtensionTests:
@@ -116,6 +140,7 @@ class ProfileSyncServiceMockForExtensionTests:
~ProfileSyncServiceMockForExtensionTests() {}
MOCK_METHOD0(Shutdown, void());
+ MOCK_CONST_METHOD0(GetDeviceInfoTracker, DeviceInfoTracker*());
};
KeyedService* CreateProfileSyncServiceMock(content::BrowserContext* profile) {
@@ -133,15 +158,6 @@ class ExtensionSignedInDevicesTest : public ExtensionApiUnittest {
}
};
-DeviceInfo* CreateDeviceInfo(const DeviceInfo& device_info) {
- return new DeviceInfo(device_info.guid(),
- device_info.client_name(),
- device_info.chrome_version(),
- device_info.sync_user_agent(),
- device_info.device_type(),
- device_info.signin_scoped_device_id());
-}
-
std::string GetPublicId(const base::DictionaryValue* dictionary) {
std::string public_id;
if (!dictionary->GetString("id", &public_id)) {
@@ -174,6 +190,7 @@ TEST_F(ExtensionSignedInDevicesTest, GetAll) {
ProfileSyncServiceMockForExtensionTests* pss_mock =
static_cast<ProfileSyncServiceMockForExtensionTests*>(
ProfileSyncServiceFactory::GetForProfile(profile()));
+ MockDeviceInfoTracker device_tracker;
DeviceInfo device_info1(base::GenerateGUID(),
"abc Device",
@@ -189,12 +206,11 @@ TEST_F(ExtensionSignedInDevicesTest, GetAll) {
sync_pb::SyncEnums_DeviceType_TYPE_LINUX,
"device_id");
- std::vector<DeviceInfo*> devices;
- devices.push_back(CreateDeviceInfo(device_info1));
- devices.push_back(CreateDeviceInfo(device_info2));
+ device_tracker.Add(&device_info1);
+ device_tracker.Add(&device_info2);
- EXPECT_CALL(*pss_mock, GetAllSignedInDevicesMock()).
- WillOnce(Return(&devices));
+ EXPECT_CALL(*pss_mock, GetDeviceInfoTracker())
+ .WillOnce(Return(&device_tracker));
EXPECT_CALL(*pss_mock, Shutdown());
@@ -216,4 +232,19 @@ TEST_F(ExtensionSignedInDevicesTest, GetAll) {
EXPECT_NE(public_id1, public_id2);
}
+TEST_F(ExtensionSignedInDevicesTest, DeviceInfoTrackerNotInitialized) {
+ ProfileSyncServiceMockForExtensionTests* pss_mock =
+ static_cast<ProfileSyncServiceMockForExtensionTests*>(
+ ProfileSyncServiceFactory::GetForProfile(profile()));
+
+ EXPECT_CALL(*pss_mock, GetDeviceInfoTracker())
+ .WillOnce(Return((DeviceInfoTracker*)NULL));
+ EXPECT_CALL(*pss_mock, Shutdown());
+
+ ScopedVector<DeviceInfo> output = GetAllSignedInDevices(
+ extension()->id(), profile());
+
+ EXPECT_TRUE(output.empty());
+}
+
} // namespace extensions
diff --git a/chrome/browser/extensions/api/signed_in_devices/signed_in_devices_manager.cc b/chrome/browser/extensions/api/signed_in_devices/signed_in_devices_manager.cc
index 30c0ede..3eadd84 100644
--- a/chrome/browser/extensions/api/signed_in_devices/signed_in_devices_manager.cc
+++ b/chrome/browser/extensions/api/signed_in_devices/signed_in_devices_manager.cc
@@ -44,17 +44,16 @@ SignedInDevicesChangeObserver::SignedInDevicesChangeObserver(
Profile* profile) : extension_id_(extension_id),
profile_(profile) {
ProfileSyncService* pss = ProfileSyncServiceFactory::GetForProfile(profile_);
- if (pss) {
- pss->AddObserverForDeviceInfoChange(this);
+ if (pss && pss->GetDeviceInfoTracker()) {
+ pss->GetDeviceInfoTracker()->AddObserver(this);
}
}
SignedInDevicesChangeObserver::~SignedInDevicesChangeObserver() {
ProfileSyncService* pss = ProfileSyncServiceFactory::GetForProfile(profile_);
- if (pss) {
- pss->RemoveObserverForDeviceInfoChange(this);
+ if (pss && pss->GetDeviceInfoTracker()) {
+ pss->GetDeviceInfoTracker()->RemoveObserver(this);
}
-
}
void SignedInDevicesChangeObserver::OnDeviceInfoChange() {
diff --git a/chrome/browser/extensions/api/signed_in_devices/signed_in_devices_manager.h b/chrome/browser/extensions/api/signed_in_devices/signed_in_devices_manager.h
index 925a6ec..646f522 100644
--- a/chrome/browser/extensions/api/signed_in_devices/signed_in_devices_manager.h
+++ b/chrome/browser/extensions/api/signed_in_devices/signed_in_devices_manager.h
@@ -10,7 +10,7 @@
#include "base/gtest_prod_util.h"
#include "base/memory/scoped_vector.h"
#include "base/scoped_observer.h"
-#include "chrome/browser/sync/glue/synced_device_tracker.h"
+#include "chrome/browser/sync/glue/device_info_tracker.h"
#include "extensions/browser/browser_context_keyed_api_factory.h"
#include "extensions/browser/event_router.h"
#include "extensions/browser/extension_registry_observer.h"
@@ -38,7 +38,7 @@ struct EventListenerInfo;
// public ids for devices(public ids for a device, is not the same for
// all extensions).
class SignedInDevicesChangeObserver
- : public browser_sync::SyncedDeviceTracker::Observer {
+ : public browser_sync::DeviceInfoTracker::Observer {
public:
SignedInDevicesChangeObserver(const std::string& extension_id,
Profile* profile);
diff --git a/chrome/browser/sync/glue/device_info_sync_service.cc b/chrome/browser/sync/glue/device_info_sync_service.cc
index 17fd8ed..fe7ccc1 100644
--- a/chrome/browser/sync/glue/device_info_sync_service.cc
+++ b/chrome/browser/sync/glue/device_info_sync_service.cc
@@ -8,6 +8,7 @@
#include "chrome/browser/sync/glue/local_device_info_provider.h"
#include "sync/api/sync_change.h"
#include "sync/protocol/sync.pb.h"
+#include "sync/util/time.h"
namespace browser_sync {
@@ -22,7 +23,8 @@ using syncer::SyncMergeResult;
DeviceInfoSyncService::DeviceInfoSyncService(
LocalDeviceInfoProvider* local_device_info_provider)
- : local_device_info_provider_(local_device_info_provider) {
+ : local_device_backup_time_(-1),
+ local_device_info_provider_(local_device_info_provider) {
DCHECK(local_device_info_provider);
}
@@ -43,51 +45,70 @@ SyncMergeResult DeviceInfoSyncService::MergeDataAndStartSyncing(
sync_processor_ = sync_processor.Pass();
error_handler_ = error_handler.Pass();
+ // Initialization should be completed before this type is enabled
+ // and local device info must be available.
+ const DeviceInfo* local_device_info =
+ local_device_info_provider_->GetLocalDeviceInfo();
+ DCHECK(local_device_info != NULL);
+
+ // Indicates whether a local device has been added or updated.
+ // |change_type| defaults to ADD and might be changed to
+ // UPDATE to INVALID down below if the initial data contains
+ // data matching the local device ID.
+ SyncChange::SyncChangeType change_type = SyncChange::ACTION_ADD;
+ size_t num_items_new = 0;
+ size_t num_items_updated = 0;
+
// Iterate over all initial sync data and copy it to the cache.
for (SyncDataList::const_iterator iter = initial_sync_data.begin();
iter != initial_sync_data.end();
++iter) {
DCHECK_EQ(syncer::DEVICE_INFO, iter->GetDataType());
- StoreSyncData(iter->GetSpecifics().device_info().cache_guid(), *iter);
- }
- size_t num_items_new = initial_sync_data.size();
- size_t num_items_updated = 0;
- // Indicates whether a local device has been added or updated.
- SyncChange::SyncChangeType change_type = SyncChange::ACTION_INVALID;
-
- // Initialization should be completed before this type is enabled
- // and local device info must be available.
- const DeviceInfo* local_device_info =
- local_device_info_provider_->GetLocalDeviceInfo();
- DCHECK(local_device_info != NULL);
- // Before storing the local device info check if the data with
- // the same guid has already been synced. This attempts to retrieve
- // DeviceInfo from the cached data initialized above.
- scoped_ptr<DeviceInfo> synced_local_device_info =
- GetDeviceInfo(local_device_info->guid());
-
- if (synced_local_device_info.get()) {
- // Local device info has been synced and exists in the cache.
- // |num_items_new| and |num_items_updated| need to be updated to
- // reflect that.
- num_items_new--;
- // Overwrite the synced device info with the local data only if
- // it is different.
- if (!synced_local_device_info->Equals(*local_device_info)) {
- num_items_updated++;
- change_type = SyncChange::ACTION_UPDATE;
+ const std::string& id = iter->GetSpecifics().device_info().cache_guid();
+
+ if (id == local_device_info->guid()) {
+ // |initial_sync_data| contains data matching the local device.
+ scoped_ptr<DeviceInfo> synced_local_device_info =
+ make_scoped_ptr(CreateDeviceInfo(*iter));
+
+ // Retrieve local device backup timestamp value from the sync data.
+ bool has_synced_backup_time =
+ iter->GetSpecifics().device_info().has_backup_timestamp();
+ int64 synced_backup_time =
+ has_synced_backup_time
+ ? iter->GetSpecifics().device_info().backup_timestamp()
+ : -1;
+
+ // Overwrite |local_device_backup_time_| with this value if it
+ // hasn't been set yet.
+ if (!has_local_device_backup_time() && has_synced_backup_time) {
+ set_local_device_backup_time(synced_backup_time);
+ }
+
+ // Store the synced device info for the local device only
+ // it is the same as the local info. Otherwise store the local
+ // device info and issue a change further below after finishing
+ // processing the |initial_sync_data|.
+ if (synced_local_device_info->Equals(*local_device_info) &&
+ synced_backup_time == local_device_backup_time()) {
+ change_type = SyncChange::ACTION_INVALID;
+ } else {
+ num_items_updated++;
+ change_type = SyncChange::ACTION_UPDATE;
+ continue;
+ }
+ } else {
+ // A new device that doesn't match the local device.
+ num_items_new++;
}
- } else {
- // Local device info doesn't yet exist in the cache and
- // will be added further below.
- // |num_items_new| and |num_items_updated| are already correct.
- change_type = SyncChange::ACTION_ADD;
+
+ StoreSyncData(id, *iter);
}
syncer::SyncMergeResult result(type);
- // Update SyncData from device info if it is new or different than
+ // Add SyncData for the local device if it is new or different than
// the synced one, and also add it to the |change_list|.
if (change_type != SyncChange::ACTION_INVALID) {
SyncData local_data = CreateLocalData(local_device_info);
@@ -114,6 +135,7 @@ void DeviceInfoSyncService::StopSyncing(syncer::ModelType type) {
all_data_.clear();
sync_processor_.reset();
error_handler_.reset();
+ clear_local_device_backup_time();
}
SyncDataList DeviceInfoSyncService::GetAllSyncData(
@@ -208,6 +230,56 @@ void DeviceInfoSyncService::NotifyObservers() {
FOR_EACH_OBSERVER(Observer, observers_, OnDeviceInfoChange());
}
+void DeviceInfoSyncService::UpdateLocalDeviceBackupTime(
+ base::Time backup_time) {
+ set_local_device_backup_time(syncer::TimeToProtoTime(backup_time));
+
+ if (sync_processor_.get()) {
+ // Local device info must be available in advance
+ DCHECK(local_device_info_provider_->GetLocalDeviceInfo());
+ const std::string& local_id =
+ local_device_info_provider_->GetLocalDeviceInfo()->guid();
+
+ SyncDataMap::iterator iter = all_data_.find(local_id);
+ DCHECK(iter != all_data_.end());
+
+ syncer::SyncData& data = iter->second;
+ if (UpdateBackupTime(&data)) {
+ // Local device backup time has changed.
+ // Push changes to the server via the |sync_processor_|.
+ SyncChangeList change_list;
+ change_list.push_back(SyncChange(
+ FROM_HERE, syncer::SyncChange::ACTION_UPDATE, data));
+ sync_processor_->ProcessSyncChanges(FROM_HERE, change_list);
+ }
+ }
+}
+
+bool DeviceInfoSyncService::UpdateBackupTime(syncer::SyncData* sync_data) {
+ DCHECK(has_local_device_backup_time());
+ DCHECK(sync_data->GetSpecifics().has_device_info());
+ const sync_pb::DeviceInfoSpecifics& source_specifics =
+ sync_data->GetSpecifics().device_info();
+
+ if (!source_specifics.has_backup_timestamp() ||
+ source_specifics.backup_timestamp() != local_device_backup_time()) {
+ sync_pb::EntitySpecifics entity(sync_data->GetSpecifics());
+ entity.mutable_device_info()->set_backup_timestamp(
+ local_device_backup_time());
+ *sync_data = CreateLocalData(entity);
+
+ return true;
+ }
+
+ return false;
+}
+
+base::Time DeviceInfoSyncService::GetLocalDeviceBackupTime() const {
+ return has_local_device_backup_time()
+ ? syncer::ProtoTimeToTime(local_device_backup_time())
+ : base::Time();
+}
+
SyncData DeviceInfoSyncService::CreateLocalData(const DeviceInfo* info) {
sync_pb::EntitySpecifics entity;
sync_pb::DeviceInfoSpecifics& specifics = *entity.mutable_device_info();
@@ -219,11 +291,22 @@ SyncData DeviceInfoSyncService::CreateLocalData(const DeviceInfo* info) {
specifics.set_device_type(info->device_type());
specifics.set_signin_scoped_device_id(info->signin_scoped_device_id());
+ if (has_local_device_backup_time()) {
+ specifics.set_backup_timestamp(local_device_backup_time());
+ }
+
+ return CreateLocalData(entity);
+}
+
+SyncData DeviceInfoSyncService::CreateLocalData(
+ const sync_pb::EntitySpecifics& entity) {
+ const sync_pb::DeviceInfoSpecifics& specifics = entity.device_info();
+
std::string local_device_tag =
- base::StringPrintf("DeviceInfo_%s", info->guid().c_str());
+ base::StringPrintf("DeviceInfo_%s", specifics.cache_guid().c_str());
return SyncData::CreateLocalData(
- local_device_tag, info->client_name(), entity);
+ local_device_tag, specifics.client_name(), entity);
}
DeviceInfo* DeviceInfoSyncService::CreateDeviceInfo(
diff --git a/chrome/browser/sync/glue/device_info_sync_service.h b/chrome/browser/sync/glue/device_info_sync_service.h
index 3313fc4..d638e53 100644
--- a/chrome/browser/sync/glue/device_info_sync_service.h
+++ b/chrome/browser/sync/glue/device_info_sync_service.h
@@ -44,9 +44,18 @@ class DeviceInfoSyncService : public syncer::SyncableService,
virtual void AddObserver(Observer* observer) OVERRIDE;
virtual void RemoveObserver(Observer* observer) OVERRIDE;
+ // Called to update local device backup time.
+ void UpdateLocalDeviceBackupTime(base::Time backup_time);
+ // Gets the most recently set local device backup time.
+ base::Time GetLocalDeviceBackupTime() const;
+
private:
- // Create SyncData from local DeviceInfo.
- static syncer::SyncData CreateLocalData(const DeviceInfo* info);
+ // Create SyncData from local DeviceInfo and |local_device_backup_time_|.
+ syncer::SyncData CreateLocalData(const DeviceInfo* info);
+ // Create SyncData from EntitySpecifics.
+ static syncer::SyncData CreateLocalData(
+ const sync_pb::EntitySpecifics& entity);
+
// Allocate new DeviceInfo from SyncData.
static DeviceInfo* CreateDeviceInfo(const syncer::SyncData sync_data);
// Store SyncData in the cache.
@@ -57,6 +66,25 @@ class DeviceInfoSyncService : public syncer::SyncableService,
// Notify all registered observers.
void NotifyObservers();
+ // Updates backup time in place in |sync_data| if it is different than
+ // the one stored in |local_device_backup_time_|.
+ // Returns true if backup time was updated.
+ bool UpdateBackupTime(syncer::SyncData* sync_data);
+
+ // |local_device_backup_time_| accessors.
+ int64 local_device_backup_time() const { return local_device_backup_time_; }
+ bool has_local_device_backup_time() const {
+ return local_device_backup_time_ >= 0;
+ }
+ void set_local_device_backup_time(int64 value) {
+ local_device_backup_time_ = value;
+ }
+ void clear_local_device_backup_time() { local_device_backup_time_ = -1; }
+
+ // Local device last set backup time (in proto format).
+ // -1 if the value hasn't been specified
+ int64 local_device_backup_time_;
+
// |local_device_info_provider_| isn't owned.
const LocalDeviceInfoProvider* const local_device_info_provider_;
diff --git a/chrome/browser/sync/glue/device_info_sync_service_unittest.cc b/chrome/browser/sync/glue/device_info_sync_service_unittest.cc
index 6fe3a8e..edf4e51c 100644
--- a/chrome/browser/sync/glue/device_info_sync_service_unittest.cc
+++ b/chrome/browser/sync/glue/device_info_sync_service_unittest.cc
@@ -11,6 +11,7 @@
#include "sync/api/sync_change_processor_wrapper_for_test.h"
#include "sync/api/sync_error_factory_mock.h"
#include "sync/internal_api/public/attachments/attachment_service_proxy_for_test.h"
+#include "sync/util/time.h"
#include "testing/gtest/include/gtest/gtest.h"
using syncer::AttachmentIdList;
@@ -112,7 +113,8 @@ class DeviceInfoSyncServiceTest : public testing::Test,
}
SyncData CreateRemoteData(const std::string& client_id,
- const std::string& client_name) {
+ const std::string& client_name,
+ int64 backup_timestamp = 0) {
sync_pb::EntitySpecifics entity;
sync_pb::DeviceInfoSpecifics& specifics = *entity.mutable_device_info();
@@ -123,6 +125,10 @@ class DeviceInfoSyncServiceTest : public testing::Test,
specifics.set_device_type(sync_pb::SyncEnums_DeviceType_TYPE_LINUX);
specifics.set_signin_scoped_device_id("device_id");
+ if (backup_timestamp != 0) {
+ specifics.set_backup_timestamp(backup_timestamp);
+ }
+
return SyncData::CreateRemoteData(1,
entity,
base::Time(),
@@ -400,6 +406,152 @@ TEST_F(DeviceInfoSyncServiceTest, ProcessChangesAfterUnsubscribing) {
EXPECT_EQ(0, num_device_info_changed_callbacks_);
}
+// Verifies setting backup timestamp after the initial sync.
+TEST_F(DeviceInfoSyncServiceTest, UpdateLocalDeviceBackupTime) {
+ // Shouldn't have backuptime initially.
+ base::Time backup_time = sync_service_->GetLocalDeviceBackupTime();
+ EXPECT_TRUE(backup_time.is_null());
+
+ // Perform the initial sync with empty data.
+ SyncMergeResult merge_result =
+ sync_service_->MergeDataAndStartSyncing(syncer::DEVICE_INFO,
+ SyncDataList(),
+ PassProcessor(),
+ CreateAndPassSyncErrorFactory());
+
+ // Should have local device after the initial sync.
+ EXPECT_EQ(1U, sync_processor_->change_list_size());
+ EXPECT_EQ(SyncChange::ACTION_ADD, sync_processor_->change_type_at(0));
+
+ // Shouldn't have backup time initially.
+ EXPECT_EQ("guid_1", sync_processor_->cache_guid_at(0));
+ EXPECT_FALSE(sync_processor_->device_info_at(0).has_backup_timestamp());
+
+ sync_service_->UpdateLocalDeviceBackupTime(base::Time::FromTimeT(1000));
+
+ // Should have local device info updated with the specified backup timestamp.
+ EXPECT_EQ(1U, sync_processor_->change_list_size());
+ EXPECT_EQ(SyncChange::ACTION_UPDATE, sync_processor_->change_type_at(0));
+ EXPECT_EQ("guid_1", sync_processor_->cache_guid_at(0));
+ EXPECT_TRUE(sync_processor_->device_info_at(0).has_backup_timestamp());
+
+ backup_time = syncer::ProtoTimeToTime(
+ sync_processor_->device_info_at(0).backup_timestamp());
+ EXPECT_EQ(1000, backup_time.ToTimeT());
+
+ // Also verify that we get the same backup time directly from the service.
+ backup_time = sync_service_->GetLocalDeviceBackupTime();
+ EXPECT_EQ(1000, backup_time.ToTimeT());
+}
+
+// Verifies setting backup timestamp prior to the initial sync.
+TEST_F(DeviceInfoSyncServiceTest, UpdateLocalDeviceBackupTimeBeforeSync) {
+ // Set the backup timestamp.
+ sync_service_->UpdateLocalDeviceBackupTime(base::Time::FromTimeT(2000));
+ // Verify that we get it back.
+ base::Time backup_time = sync_service_->GetLocalDeviceBackupTime();
+ EXPECT_EQ(2000, backup_time.ToTimeT());
+
+ // Now perform the initial sync with empty data.
+ SyncMergeResult merge_result =
+ sync_service_->MergeDataAndStartSyncing(syncer::DEVICE_INFO,
+ SyncDataList(),
+ PassProcessor(),
+ CreateAndPassSyncErrorFactory());
+
+ // Should have local device after the initial sync.
+ // Should have the backup timestamp set.
+ EXPECT_EQ(1U, sync_processor_->change_list_size());
+ EXPECT_EQ(SyncChange::ACTION_ADD, sync_processor_->change_type_at(0));
+ EXPECT_EQ("guid_1", sync_processor_->cache_guid_at(0));
+ EXPECT_TRUE(sync_processor_->device_info_at(0).has_backup_timestamp());
+
+ backup_time = syncer::ProtoTimeToTime(
+ sync_processor_->device_info_at(0).backup_timestamp());
+ EXPECT_EQ(2000, backup_time.ToTimeT());
+}
+
+// Verifies that the backup timestamp that comes in the intial sync data
+// gets preserved when there are no changes to the local device.
+TEST_F(DeviceInfoSyncServiceTest, PreserveBackupTimeWithMatchingLocalDevice) {
+ base::Time backup_time = base::Time::FromTimeT(3000);
+ SyncDataList sync_data;
+ sync_data.push_back(CreateRemoteData(
+ "guid_1", "client_1", syncer::TimeToProtoTime(backup_time)));
+
+ SyncMergeResult merge_result =
+ sync_service_->MergeDataAndStartSyncing(syncer::DEVICE_INFO,
+ sync_data,
+ PassProcessor(),
+ CreateAndPassSyncErrorFactory());
+
+ // Everything is matching so there should be no updates.
+ EXPECT_EQ(0U, sync_processor_->change_list_size());
+
+ // Verify that we get back the same time.
+ backup_time = sync_service_->GetLocalDeviceBackupTime();
+ EXPECT_EQ(3000, backup_time.ToTimeT());
+}
+
+// Verifies that the backup timestamp that comes in the intial sync data
+// gets merged with the local device data.
+TEST_F(DeviceInfoSyncServiceTest, MergeBackupTimeWithMatchingLocalDevice) {
+ base::Time backup_time = base::Time::FromTimeT(4000);
+ SyncDataList sync_data;
+ sync_data.push_back(CreateRemoteData(
+ "guid_1", "foo_1", syncer::TimeToProtoTime(backup_time)));
+
+ SyncMergeResult merge_result =
+ sync_service_->MergeDataAndStartSyncing(syncer::DEVICE_INFO,
+ sync_data,
+ PassProcessor(),
+ CreateAndPassSyncErrorFactory());
+
+ // Should be one change because of the client name mismatch.
+ // However the backup time passed in the initial data should be merged into
+ // the change.
+ EXPECT_EQ(1U, sync_processor_->change_list_size());
+
+ EXPECT_EQ(SyncChange::ACTION_UPDATE, sync_processor_->change_type_at(0));
+ EXPECT_EQ("guid_1", sync_processor_->cache_guid_at(0));
+ EXPECT_EQ("client_1", sync_processor_->client_name_at(0));
+
+ backup_time = syncer::ProtoTimeToTime(
+ sync_processor_->device_info_at(0).backup_timestamp());
+ EXPECT_EQ(4000, backup_time.ToTimeT());
+}
+
+// Verifies that mismatching backup timestamp generates an update even
+// when the rest of local device data is matching.
+TEST_F(DeviceInfoSyncServiceTest,
+ MergeMismatchingBackupTimeWithMatchingLocalDevice) {
+ base::Time backup_time = base::Time::FromTimeT(5000);
+ SyncDataList sync_data;
+ sync_data.push_back(CreateRemoteData(
+ "guid_1", "client_1", syncer::TimeToProtoTime(backup_time)));
+
+ // Set the backup timestamp different than the one in the sync data.
+ sync_service_->UpdateLocalDeviceBackupTime(base::Time::FromTimeT(6000));
+
+ SyncMergeResult merge_result =
+ sync_service_->MergeDataAndStartSyncing(syncer::DEVICE_INFO,
+ sync_data,
+ PassProcessor(),
+ CreateAndPassSyncErrorFactory());
+
+ // Should generate and update due to timestamp mismatch.
+ // The locally set timestamp wins.
+ EXPECT_EQ(1U, sync_processor_->change_list_size());
+
+ EXPECT_EQ(SyncChange::ACTION_UPDATE, sync_processor_->change_type_at(0));
+ EXPECT_EQ("guid_1", sync_processor_->cache_guid_at(0));
+ EXPECT_EQ("client_1", sync_processor_->client_name_at(0));
+
+ backup_time = syncer::ProtoTimeToTime(
+ sync_processor_->device_info_at(0).backup_timestamp());
+ EXPECT_EQ(6000, backup_time.ToTimeT());
+}
+
} // namespace
} // namespace browser_sync
diff --git a/chrome/browser/sync/glue/sync_backend_host.h b/chrome/browser/sync/glue/sync_backend_host.h
index 32615d4..061c3f4 100644
--- a/chrome/browser/sync/glue/sync_backend_host.h
+++ b/chrome/browser/sync/glue/sync_backend_host.h
@@ -42,8 +42,6 @@ class SyncFrontend;
namespace browser_sync {
-class SyncedDeviceTracker;
-
// An API to "host" the top level SyncAPI element.
//
// This class handles dispatch of potentially blocking calls to appropriate
@@ -187,9 +185,6 @@ class SyncBackendHost : public sync_driver::BackendDataTypeConfigurer {
virtual void GetModelSafeRoutingInfo(
syncer::ModelSafeRoutingInfo* out) const = 0;
- // Fetches the DeviceInfo tracker.
- virtual SyncedDeviceTracker* GetSyncedDeviceTracker() const = 0;
-
// Requests that the backend forward to the fronent any protocol events in
// its buffer and begin forwarding automatically from now on. Repeated calls
// to this function may result in the same events being emitted several
diff --git a/chrome/browser/sync/glue/sync_backend_host_core.cc b/chrome/browser/sync/glue/sync_backend_host_core.cc
index 2a78040..b8c66df 100644
--- a/chrome/browser/sync/glue/sync_backend_host_core.cc
+++ b/chrome/browser/sync/glue/sync_backend_host_core.cc
@@ -9,7 +9,6 @@
#include "chrome/browser/sync/glue/device_info.h"
#include "chrome/browser/sync/glue/invalidation_adapter.h"
#include "chrome/browser/sync/glue/sync_backend_registrar.h"
-#include "chrome/browser/sync/glue/synced_device_tracker.h"
#include "chrome/common/chrome_version_info.h"
#include "components/invalidation/invalidation_util.h"
#include "components/invalidation/object_id_invalidation_map.h"
@@ -71,8 +70,7 @@ DoInitializeOptions::DoInitializeOptions(
scoped_ptr<syncer::InternalComponentsFactory> internal_components_factory,
scoped_ptr<syncer::UnrecoverableErrorHandler> unrecoverable_error_handler,
syncer::ReportUnrecoverableErrorFunction
- report_unrecoverable_error_function,
- const std::string& signin_scoped_device_id)
+ report_unrecoverable_error_function)
: sync_loop(sync_loop),
registrar(registrar),
routing_info(routing_info),
@@ -90,8 +88,7 @@ DoInitializeOptions::DoInitializeOptions(
restored_keystore_key_for_bootstrapping),
internal_components_factory(internal_components_factory.Pass()),
unrecoverable_error_handler(unrecoverable_error_handler.Pass()),
- report_unrecoverable_error_function(report_unrecoverable_error_function),
- signin_scoped_device_id(signin_scoped_device_id) {
+ report_unrecoverable_error_function(report_unrecoverable_error_function) {
}
DoInitializeOptions::~DoInitializeOptions() {}
@@ -404,8 +401,6 @@ void SyncBackendHostCore::DoInitialize(
sync_loop_ = options->sync_loop;
DCHECK(sync_loop_);
- signin_scoped_device_id_ = options->signin_scoped_device_id;
-
// Finish initializing the HttpBridgeFactory. We do this here because
// building the user agent may block on some platforms.
chrome::VersionInfo version_info;
@@ -509,25 +504,6 @@ void SyncBackendHostCore::DoInitialProcessControlTypes() {
return;
}
- // Initialize device info. This is asynchronous on some platforms, so we
- // provide a callback for when it finishes.
- synced_device_tracker_.reset(
- new SyncedDeviceTracker(sync_manager_->GetUserShare(),
- sync_manager_->cache_guid()));
- synced_device_tracker_->InitLocalDeviceInfo(
- signin_scoped_device_id_,
- base::Bind(&SyncBackendHostCore::DoFinishInitialProcessControlTypes,
- weak_ptr_factory_.GetWeakPtr()));
-}
-
-void SyncBackendHostCore::DoFinishInitialProcessControlTypes() {
- DCHECK_EQ(base::MessageLoop::current(), sync_loop_);
-
- registrar_->ActivateDataType(syncer::DEVICE_INFO,
- syncer::GROUP_PASSIVE,
- synced_device_tracker_.get(),
- sync_manager_->GetUserShare());
-
host_.Call(FROM_HERE,
&SyncBackendHostImpl::HandleInitializationSuccessOnFrontendLoop,
js_backend_,
@@ -575,10 +551,6 @@ void SyncBackendHostCore::ShutdownOnUIThread() {
void SyncBackendHostCore::DoShutdown(syncer::ShutdownReason reason) {
DCHECK_EQ(base::MessageLoop::current(), sync_loop_);
- // It's safe to do this even if the type was never activated.
- registrar_->DeactivateDataType(syncer::DEVICE_INFO);
- synced_device_tracker_.reset();
-
DoDestroySyncManager(reason);
registrar_ = NULL;
diff --git a/chrome/browser/sync/glue/sync_backend_host_core.h b/chrome/browser/sync/glue/sync_backend_host_core.h
index 5e61339..46fb599 100644
--- a/chrome/browser/sync/glue/sync_backend_host_core.h
+++ b/chrome/browser/sync/glue/sync_backend_host_core.h
@@ -40,8 +40,7 @@ struct DoInitializeOptions {
scoped_ptr<syncer::InternalComponentsFactory> internal_components_factory,
scoped_ptr<syncer::UnrecoverableErrorHandler> unrecoverable_error_handler,
syncer::ReportUnrecoverableErrorFunction
- report_unrecoverable_error_function,
- const std::string& signin_scoped_device_id);
+ report_unrecoverable_error_function);
~DoInitializeOptions();
base::MessageLoop* sync_loop;
@@ -64,7 +63,6 @@ struct DoInitializeOptions {
scoped_ptr<syncer::UnrecoverableErrorHandler> unrecoverable_error_handler;
syncer::ReportUnrecoverableErrorFunction
report_unrecoverable_error_function;
- std::string signin_scoped_device_id;
};
// Helper struct to handle currying params to
@@ -180,15 +178,9 @@ class SyncBackendHostCore
void OnControlTypesDownloadRetry();
// Called to perform tasks which require the control data to be downloaded.
- // This includes refreshing encryption, setting up the device info change
- // processor, etc.
+ // This includes refreshing encryption, etc.
void DoInitialProcessControlTypes();
- // Some parts of DoInitialProcessControlTypes() may be executed on a different
- // thread. This function asynchronously continues the work started in
- // DoInitialProcessControlTypes() once that other thread gets back to us.
- void DoFinishInitialProcessControlTypes();
-
// The shutdown order is a bit complicated:
// 1) Call ShutdownOnUIThread() from |frontend_loop_| to request sync manager
// to stop as soon as possible.
@@ -219,10 +211,6 @@ class SyncBackendHostCore
syncer::SyncManager* sync_manager() { return sync_manager_.get(); }
- SyncedDeviceTracker* synced_device_tracker() {
- return synced_device_tracker_.get();
- }
-
void SendBufferedProtocolEventsAndEnableForwarding();
void DisableProtocolEventForwarding();
@@ -293,9 +281,6 @@ class SyncBackendHostCore
// Our encryptor, which uses Chrome's encryption functions.
sync_driver::SystemEncryptor encryptor_;
- // A special ChangeProcessor that tracks the DEVICE_INFO type for us.
- scoped_ptr<SyncedDeviceTracker> synced_device_tracker_;
-
// The top-level syncapi entry point. Lives on the sync thread.
scoped_ptr<syncer::SyncManager> sync_manager_;
@@ -323,10 +308,6 @@ class SyncBackendHostCore
// Set when the forwarding of per-type debug counters is enabled.
bool forward_type_info_;
- // Obtained from SigninClient::GetSigninScopedDeviceId(). Stored here just to
- // pass from SyncBackendHostImpl to SyncedDeviceTracker.
- std::string signin_scoped_device_id_;
-
base::WeakPtrFactory<SyncBackendHostCore> weak_ptr_factory_;
DISALLOW_COPY_AND_ASSIGN(SyncBackendHostCore);
diff --git a/chrome/browser/sync/glue/sync_backend_host_impl.cc b/chrome/browser/sync/glue/sync_backend_host_impl.cc
index 6f4c7e3..cbded53 100644
--- a/chrome/browser/sync/glue/sync_backend_host_impl.cc
+++ b/chrome/browser/sync/glue/sync_backend_host_impl.cc
@@ -135,12 +135,6 @@ void SyncBackendHostImpl::Initialize(
InternalComponentsFactory::FORCE_ENABLE_PRE_COMMIT_UPDATE_AVOIDANCE;
}
- SigninClient* signin_client =
- ChromeSigninClientFactory::GetForProfile(profile_);
- DCHECK(signin_client);
- std::string signin_scoped_device_id =
- signin_client->GetSigninScopedDeviceId();
-
scoped_ptr<DoInitializeOptions> init_opts(new DoInitializeOptions(
registrar_->sync_thread()->message_loop(),
registrar_.get(),
@@ -162,8 +156,7 @@ void SyncBackendHostImpl::Initialize(
scoped_ptr<InternalComponentsFactory>(
new syncer::InternalComponentsFactoryImpl(factory_switches)).Pass(),
unrecoverable_error_handler.Pass(),
- report_unrecoverable_error_function,
- signin_scoped_device_id));
+ report_unrecoverable_error_function));
InitCore(init_opts.Pass());
}
@@ -514,12 +507,6 @@ void SyncBackendHostImpl::GetModelSafeRoutingInfo(
}
}
-SyncedDeviceTracker* SyncBackendHostImpl::GetSyncedDeviceTracker() const {
- if (!initialized())
- return NULL;
- return core_->synced_device_tracker();
-}
-
void SyncBackendHostImpl::RequestBufferedProtocolEventsAndEnableForwarding() {
registrar_->sync_thread()->message_loop()->PostTask(
FROM_HERE,
diff --git a/chrome/browser/sync/glue/sync_backend_host_impl.h b/chrome/browser/sync/glue/sync_backend_host_impl.h
index 7e68da0..d4cd61f 100644
--- a/chrome/browser/sync/glue/sync_backend_host_impl.h
+++ b/chrome/browser/sync/glue/sync_backend_host_impl.h
@@ -56,7 +56,6 @@ namespace browser_sync {
class ChangeProcessor;
class SyncBackendHostCore;
class SyncBackendRegistrar;
-class SyncedDeviceTracker;
struct DoInitializeOptions;
// The only real implementation of the SyncBackendHost. See that interface's
@@ -128,7 +127,6 @@ class SyncBackendHostImpl
const syncer::BaseTransaction* trans) const OVERRIDE;
virtual void GetModelSafeRoutingInfo(
syncer::ModelSafeRoutingInfo* out) const OVERRIDE;
- virtual SyncedDeviceTracker* GetSyncedDeviceTracker() const OVERRIDE;
virtual void RequestBufferedProtocolEventsAndEnableForwarding() OVERRIDE;
virtual void DisableProtocolEventForwarding() OVERRIDE;
virtual void EnableDirectoryTypeDebugInfoForwarding() OVERRIDE;
diff --git a/chrome/browser/sync/glue/sync_backend_host_impl_unittest.cc b/chrome/browser/sync/glue/sync_backend_host_impl_unittest.cc
index ef7879f..a7d0aa0 100644
--- a/chrome/browser/sync/glue/sync_backend_host_impl_unittest.cc
+++ b/chrome/browser/sync/glue/sync_backend_host_impl_unittest.cc
@@ -16,7 +16,6 @@
#include "chrome/browser/invalidation/profile_invalidation_provider_factory.h"
#include "chrome/browser/prefs/pref_service_syncable.h"
#include "chrome/browser/sync/glue/device_info.h"
-#include "chrome/browser/sync/glue/synced_device_tracker.h"
#include "chrome/test/base/testing_browser_process.h"
#include "chrome/test/base/testing_profile.h"
#include "chrome/test/base/testing_profile_manager.h"
@@ -630,16 +629,6 @@ TEST_F(SyncBackendHostTest, NewlySupportedTypesWithPartialTypes) {
enabled_types_).Empty());
}
-// Ensure the device info tracker is initialized properly on startup.
-TEST_F(SyncBackendHostTest, InitializeDeviceInfo) {
- ASSERT_EQ(NULL, backend_->GetSyncedDeviceTracker());
-
- InitializeBackend(true);
- const SyncedDeviceTracker* device_tracker =
- backend_->GetSyncedDeviceTracker();
- ASSERT_TRUE(device_tracker->ReadLocalDeviceInfo());
-}
-
// Verify that downloading control types only downloads those types that do
// not have initial sync ended set.
TEST_F(SyncBackendHostTest, DownloadControlTypes) {
@@ -647,7 +636,7 @@ TEST_F(SyncBackendHostTest, DownloadControlTypes) {
// Set sync manager behavior before passing it down. Experiments and device
// info are new types without progress markers or initial sync ended, while
// all other types have been fully downloaded and applied.
- syncer::ModelTypeSet new_types(syncer::EXPERIMENTS, syncer::DEVICE_INFO);
+ syncer::ModelTypeSet new_types(syncer::EXPERIMENTS, syncer::NIGORI);
syncer::ModelTypeSet old_types =
Difference(enabled_types_, new_types);
fake_manager_factory_->set_progress_marker_types(old_types);
diff --git a/chrome/browser/sync/glue/sync_backend_host_mock.cc b/chrome/browser/sync/glue/sync_backend_host_mock.cc
index 8faed53..704f55c 100644
--- a/chrome/browser/sync/glue/sync_backend_host_mock.cc
+++ b/chrome/browser/sync/glue/sync_backend_host_mock.cc
@@ -111,10 +111,6 @@ bool SyncBackendHostMock::IsCryptographerReady(
void SyncBackendHostMock::GetModelSafeRoutingInfo(
syncer::ModelSafeRoutingInfo* out) const {}
-SyncedDeviceTracker* SyncBackendHostMock::GetSyncedDeviceTracker() const {
- return NULL;
-}
-
base::MessageLoop* SyncBackendHostMock::GetSyncLoopForTesting() {
return NULL;
}
diff --git a/chrome/browser/sync/glue/sync_backend_host_mock.h b/chrome/browser/sync/glue/sync_backend_host_mock.h
index 2f233dbd..41c8191 100644
--- a/chrome/browser/sync/glue/sync_backend_host_mock.h
+++ b/chrome/browser/sync/glue/sync_backend_host_mock.h
@@ -94,8 +94,6 @@ class SyncBackendHostMock : public SyncBackendHost {
virtual void GetModelSafeRoutingInfo(
syncer::ModelSafeRoutingInfo* out) const OVERRIDE;
- virtual SyncedDeviceTracker* GetSyncedDeviceTracker() const OVERRIDE;
-
virtual void RequestBufferedProtocolEventsAndEnableForwarding() OVERRIDE;
virtual void DisableProtocolEventForwarding() OVERRIDE;
diff --git a/chrome/browser/sync/glue/synced_device_tracker.cc b/chrome/browser/sync/glue/synced_device_tracker.cc
deleted file mode 100644
index 73e8cbb..0000000
--- a/chrome/browser/sync/glue/synced_device_tracker.cc
+++ /dev/null
@@ -1,238 +0,0 @@
-// Copyright (c) 2012 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_device_tracker.h"
-
-#include "base/strings/stringprintf.h"
-#include "base/strings/utf_string_conversions.h"
-#include "chrome/browser/sync/glue/device_info.h"
-#include "sync/internal_api/public/base/model_type.h"
-#include "sync/internal_api/public/read_node.h"
-#include "sync/internal_api/public/read_transaction.h"
-#include "sync/internal_api/public/user_share.h"
-#include "sync/internal_api/public/write_node.h"
-#include "sync/internal_api/public/write_transaction.h"
-#include "sync/util/time.h"
-
-namespace browser_sync {
-
-namespace {
-
-// Return the DeviceInfo UNIQUE_CLIENT_TAG value for the given sync cache_guid.
-std::string DeviceInfoLookupString(const std::string& cache_guid) {
- return base::StringPrintf("DeviceInfo_%s", cache_guid.c_str());
-}
-
-} // namespace
-
-SyncedDeviceTracker::SyncedDeviceTracker(syncer::UserShare* user_share,
- const std::string& cache_guid)
- : ChangeProcessor(NULL),
- user_share_(user_share),
- cache_guid_(cache_guid),
- local_device_info_tag_(DeviceInfoLookupString(cache_guid)),
- weak_factory_(this) {
- observers_ = new ObserverListThreadSafe<Observer>;
-}
-
-SyncedDeviceTracker::~SyncedDeviceTracker() {
-}
-
-void SyncedDeviceTracker::StartImpl() { }
-
-void SyncedDeviceTracker::ApplyChangesFromSyncModel(
- const syncer::BaseTransaction* trans,
- int64 model_version,
- const syncer::ImmutableChangeRecordList& changes) {
- // If desired, we could maintain a cache of device info. This method will be
- // called with a transaction every time the device info is modified, so this
- // would be the right place to update the cache.
-}
-
-void SyncedDeviceTracker::CommitChangesFromSyncModel() {
- observers_->Notify(&Observer::OnDeviceInfoChange);
-}
-
-scoped_ptr<DeviceInfo> SyncedDeviceTracker::ReadLocalDeviceInfo() const {
- syncer::ReadTransaction trans(FROM_HERE, user_share_);
- return ReadLocalDeviceInfo(trans);
-}
-
-scoped_ptr<DeviceInfo> SyncedDeviceTracker::ReadLocalDeviceInfo(
- const syncer::BaseTransaction& trans) const {
- syncer::ReadNode node(&trans);
- if (node.InitByClientTagLookup(syncer::DEVICE_INFO, local_device_info_tag_) !=
- syncer::BaseNode::INIT_OK) {
- return scoped_ptr<DeviceInfo>();
- }
-
- const sync_pb::DeviceInfoSpecifics& specifics = node.GetDeviceInfoSpecifics();
- return scoped_ptr<DeviceInfo>(
- new DeviceInfo(specifics.cache_guid(),
- specifics.client_name(),
- specifics.chrome_version(),
- specifics.sync_user_agent(),
- specifics.device_type(),
- specifics.signin_scoped_device_id()));
-}
-
-scoped_ptr<DeviceInfo> SyncedDeviceTracker::ReadDeviceInfo(
- const std::string& client_id) const {
- syncer::ReadTransaction trans(FROM_HERE, user_share_);
- syncer::ReadNode node(&trans);
- std::string lookup_string = DeviceInfoLookupString(client_id);
- if (node.InitByClientTagLookup(syncer::DEVICE_INFO, lookup_string) !=
- syncer::BaseNode::INIT_OK) {
- return scoped_ptr<DeviceInfo>();
- }
-
- const sync_pb::DeviceInfoSpecifics& specifics = node.GetDeviceInfoSpecifics();
- return scoped_ptr<DeviceInfo>(
- new DeviceInfo(specifics.cache_guid(),
- specifics.client_name(),
- specifics.chrome_version(),
- specifics.sync_user_agent(),
- specifics.device_type(),
- specifics.signin_scoped_device_id()));
-}
-
-void SyncedDeviceTracker::GetAllSyncedDeviceInfo(
- ScopedVector<DeviceInfo>* device_info) const {
- if (device_info == NULL)
- return;
-
- device_info->clear();
-
- syncer::ReadTransaction trans(FROM_HERE, user_share_);
- syncer::ReadNode root_node(&trans);
-
- if (root_node.InitTypeRoot(syncer::DEVICE_INFO) !=
- syncer::BaseNode::INIT_OK) {
- return;
- }
-
- // Get all the children of the root node and use the child id to read
- // device info for devices.
- std::vector<int64> children;
- root_node.GetChildIds(&children);
-
- for (std::vector<int64>::const_iterator it = children.begin();
- it != children.end(); ++it) {
- syncer::ReadNode node(&trans);
- if (node.InitByIdLookup(*it) != syncer::BaseNode::INIT_OK)
- return;
-
- const sync_pb::DeviceInfoSpecifics& specifics =
- node.GetDeviceInfoSpecifics();
- device_info->push_back(new DeviceInfo(specifics.cache_guid(),
- specifics.client_name(),
- specifics.chrome_version(),
- specifics.sync_user_agent(),
- specifics.device_type(),
- specifics.signin_scoped_device_id()));
- }
-}
-
-std::string SyncedDeviceTracker::cache_guid() const {
- return cache_guid_;
-}
-
-void SyncedDeviceTracker::AddObserver(Observer* observer) {
- observers_->AddObserver(observer);
-}
-
-void SyncedDeviceTracker::RemoveObserver(Observer* observer) {
- observers_->RemoveObserver(observer);
-}
-
-void SyncedDeviceTracker::InitLocalDeviceInfo(
- const std::string& signin_scoped_device_id,
- const base::Closure& callback) {
- DeviceInfo::CreateLocalDeviceInfo(
- cache_guid_,
- signin_scoped_device_id,
- base::Bind(&SyncedDeviceTracker::InitLocalDeviceInfoContinuation,
- weak_factory_.GetWeakPtr(),
- callback));
-}
-
-void SyncedDeviceTracker::InitLocalDeviceInfoContinuation(
- const base::Closure& callback, const DeviceInfo& local_info) {
- WriteLocalDeviceInfo(local_info);
- callback.Run();
-}
-
-void SyncedDeviceTracker::WriteLocalDeviceInfo(const DeviceInfo& info) {
- DCHECK_EQ(cache_guid_, info.guid());
- WriteDeviceInfo(info, local_device_info_tag_);
-}
-
-void SyncedDeviceTracker::WriteDeviceInfo(const DeviceInfo& info,
- const std::string& tag) {
- syncer::WriteTransaction trans(FROM_HERE, user_share_);
- syncer::WriteNode node(&trans);
-
- sync_pb::DeviceInfoSpecifics specifics;
- specifics.set_cache_guid(info.guid());
- specifics.set_client_name(info.client_name());
- specifics.set_chrome_version(info.chrome_version());
- specifics.set_sync_user_agent(info.sync_user_agent());
- specifics.set_device_type(info.device_type());
- specifics.set_signin_scoped_device_id(info.signin_scoped_device_id());
-
- if (node.InitByClientTagLookup(syncer::DEVICE_INFO, tag) ==
- syncer::BaseNode::INIT_OK) {
- const sync_pb::DeviceInfoSpecifics& sync_specifics =
- node.GetDeviceInfoSpecifics();
- if (sync_specifics.has_backup_timestamp())
- specifics.set_backup_timestamp(sync_specifics.backup_timestamp());
- node.SetDeviceInfoSpecifics(specifics);
- node.SetTitle(specifics.client_name());
- } else {
- syncer::ReadNode type_root(&trans);
- syncer::BaseNode::InitByLookupResult type_root_lookup_result =
- type_root.InitTypeRoot(syncer::DEVICE_INFO);
- DCHECK_EQ(syncer::BaseNode::INIT_OK, type_root_lookup_result);
-
- syncer::WriteNode new_node(&trans);
- syncer::WriteNode::InitUniqueByCreationResult create_result =
- new_node.InitUniqueByCreation(syncer::DEVICE_INFO,
- type_root,
- tag);
- DCHECK_EQ(syncer::WriteNode::INIT_SUCCESS, create_result);
- new_node.SetDeviceInfoSpecifics(specifics);
- new_node.SetTitle(specifics.client_name());
- }
-}
-
-void SyncedDeviceTracker::UpdateLocalDeviceBackupTime(base::Time backup_time) {
- syncer::WriteTransaction trans(FROM_HERE, user_share_);
- syncer::WriteNode node(&trans);
-
- if (node.InitByClientTagLookup(syncer::DEVICE_INFO, local_device_info_tag_)
- == syncer::BaseNode::INIT_OK) {
- sync_pb::DeviceInfoSpecifics specifics = node.GetDeviceInfoSpecifics();
- int64 new_backup_timestamp = syncer::TimeToProtoTime(backup_time);
- if (!specifics.has_backup_timestamp() ||
- specifics.backup_timestamp() != new_backup_timestamp) {
- specifics.set_backup_timestamp(new_backup_timestamp);
- node.SetDeviceInfoSpecifics(specifics);
- }
- }
-}
-
-base::Time SyncedDeviceTracker::GetLocalDeviceBackupTime() const {
- syncer::ReadTransaction trans(FROM_HERE, user_share_);
- syncer::ReadNode node(&trans);
- if (node.InitByClientTagLookup(syncer::DEVICE_INFO, local_device_info_tag_)
- == syncer::BaseNode::INIT_OK &&
- node.GetDeviceInfoSpecifics().has_backup_timestamp()) {
- return syncer::ProtoTimeToTime(
- node.GetDeviceInfoSpecifics().backup_timestamp());
- } else {
- return base::Time();
- }
-}
-
-} // namespace browser_sync
diff --git a/chrome/browser/sync/glue/synced_device_tracker.h b/chrome/browser/sync/glue/synced_device_tracker.h
deleted file mode 100644
index 9f6fc33..0000000
--- a/chrome/browser/sync/glue/synced_device_tracker.h
+++ /dev/null
@@ -1,101 +0,0 @@
-// Copyright (c) 2012 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_DEVICE_TRACKER_H_
-#define CHROME_BROWSER_SYNC_GLUE_SYNCED_DEVICE_TRACKER_H_
-
-#include <string>
-
-#include "base/basictypes.h"
-#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 "components/sync_driver/change_processor.h"
-
-namespace syncer {
-struct UserShare;
-}
-
-namespace browser_sync {
-
-class DeviceInfo;
-
-class SyncedDeviceTracker : public sync_driver::ChangeProcessor {
- public:
- SyncedDeviceTracker(syncer::UserShare* user_share,
- 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() OVERRIDE;
- virtual void ApplyChangesFromSyncModel(
- const syncer::BaseTransaction* trans,
- int64 model_version,
- const syncer::ImmutableChangeRecordList& changes) OVERRIDE;
- virtual void CommitChangesFromSyncModel() OVERRIDE;
-
- // Methods for accessing and updating the device_info list.
- // These are virtual for testing.
- virtual scoped_ptr<DeviceInfo> ReadLocalDeviceInfo(
- const syncer::BaseTransaction &trans) const;
- virtual scoped_ptr<DeviceInfo> ReadLocalDeviceInfo() const;
- virtual void InitLocalDeviceInfo(const std::string& signin_scoped_device_id,
- const base::Closure& callback);
- virtual scoped_ptr<DeviceInfo> ReadDeviceInfo(
- const std::string& client_id) const;
- virtual void GetAllSyncedDeviceInfo(
- ScopedVector<DeviceInfo>* device_info) const;
-
- virtual std::string cache_guid() 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);
-
- // Update |backup_timestamp| in local device info specifics to |backup_time|
- // if different.
- void UpdateLocalDeviceBackupTime(base::Time backup_time);
-
- // Return time derived from |backup_timestamp| in local device info specifics.
- base::Time GetLocalDeviceBackupTime() const;
-
- private:
- friend class SyncedDeviceTrackerTest;
-
- void InitLocalDeviceInfoContinuation(const base::Closure& callback,
- const DeviceInfo& local_info);
-
- // Helper to write specifics into our node. Also useful for testing.
- void WriteLocalDeviceInfo(const DeviceInfo& info);
-
- // Helper to write arbitrary device info. Useful for writing local device
- // info and also used by test cases to write arbitrary device infos.
- void WriteDeviceInfo(const DeviceInfo& info, const std::string& tag);
-
- syncer::UserShare* user_share_;
- 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_;
-
- base::WeakPtrFactory<SyncedDeviceTracker> weak_factory_;
-
- DISALLOW_COPY_AND_ASSIGN(SyncedDeviceTracker);
-};
-
-} // namespace browser_sync
-
-#endif // CHROME_BROWSER_SYNC_GLUE_SYNCED_DEVICE_TRACKER_H_
diff --git a/chrome/browser/sync/glue/synced_device_tracker_unittest.cc b/chrome/browser/sync/glue/synced_device_tracker_unittest.cc
deleted file mode 100644
index 15161e3..0000000
--- a/chrome/browser/sync/glue/synced_device_tracker_unittest.cc
+++ /dev/null
@@ -1,242 +0,0 @@
-// Copyright (c) 2012 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 <string>
-
-#include "base/guid.h"
-#include "base/memory/scoped_ptr.h"
-#include "base/memory/scoped_vector.h"
-#include "base/message_loop/message_loop.h"
-#include "base/run_loop.h"
-#include "chrome/browser/sync/glue/device_info.h"
-#include "chrome/browser/sync/glue/synced_device_tracker.h"
-#include "sync/internal_api/public/base/model_type.h"
-#include "sync/internal_api/public/test/test_user_share.h"
-#include "sync/protocol/sync.pb.h"
-#include "sync/syncable/directory.h"
-#include "sync/test/test_transaction_observer.h"
-#include "testing/gtest/include/gtest/gtest.h"
-
-namespace browser_sync {
-
-class SyncedDeviceTrackerTest : public ::testing::Test {
- protected:
- SyncedDeviceTrackerTest() : transaction_count_baseline_(0) { }
- virtual ~SyncedDeviceTrackerTest() { }
-
- virtual void SetUp() {
- test_user_share_.SetUp();
- syncer::TestUserShare::CreateRoot(syncer::DEVICE_INFO, user_share());
-
- synced_device_tracker_.reset(
- new SyncedDeviceTracker(user_share(),
- user_share()->directory->cache_guid()));
-
- // We don't actually touch the Profile, so we can get away with passing in a
- // NULL here. Constructing a TestingProfile can take over a 100ms, so this
- // optimization can be the difference between 'tests run with a noticeable
- // delay' and 'tests run instantaneously'.
- synced_device_tracker_->Start(user_share());
- }
-
- virtual void TearDown() {
- synced_device_tracker_.reset();
- test_user_share_.TearDown();
- }
-
- syncer::UserShare* user_share() {
- return test_user_share_.user_share();
- }
-
- // Expose the private method to our tests.
- void WriteLocalDeviceInfo(const DeviceInfo& info) {
- synced_device_tracker_->WriteLocalDeviceInfo(info);
- }
-
- void WriteDeviceInfo(const DeviceInfo& device_info) {
- synced_device_tracker_->WriteDeviceInfo(device_info, device_info.guid());
- }
-
- void ResetObservedChangesCounter() {
- transaction_count_baseline_ = GetTotalTransactionsCount();
- }
-
- int GetObservedChangesCounter() {
- return GetTotalTransactionsCount() - transaction_count_baseline_;
- }
-
- scoped_ptr<SyncedDeviceTracker> synced_device_tracker_;
-
- private:
- // Count of how many closed WriteTransactions notified of meaningful changes.
- int GetTotalTransactionsCount() {
- base::RunLoop run_loop;
- run_loop.RunUntilIdle();
- return test_user_share_.transaction_observer()->transactions_observed();
- }
-
- base::MessageLoop message_loop_;
- syncer::TestUserShare test_user_share_;
- int transaction_count_baseline_;
-};
-
-namespace {
-
-// New client scenario: set device info when no previous info existed.
-TEST_F(SyncedDeviceTrackerTest, CreateNewDeviceInfo) {
- ASSERT_FALSE(synced_device_tracker_->ReadLocalDeviceInfo());
-
- ResetObservedChangesCounter();
-
- // Include the non-ASCII character "’" (typographic apostrophe) in the client
- // name to ensure that SyncedDeviceTracker can properly handle non-ASCII
- // characters, which client names can include on some platforms (e.g., Mac
- // and iOS).
- DeviceInfo write_device_info(user_share()->directory->cache_guid(),
- "John’s Device",
- "Chromium 3000",
- "ChromeSyncAgent 3000",
- sync_pb::SyncEnums_DeviceType_TYPE_LINUX,
- "device_id");
- WriteLocalDeviceInfo(write_device_info);
-
- scoped_ptr<DeviceInfo> read_device_info(
- synced_device_tracker_->ReadLocalDeviceInfo());
- ASSERT_TRUE(read_device_info);
- EXPECT_TRUE(write_device_info.Equals(*read_device_info.get()));
-
- EXPECT_EQ(1, GetObservedChangesCounter());
-}
-
-// Restart scenario: update existing device info with identical data.
-TEST_F(SyncedDeviceTrackerTest, DontModifyExistingDeviceInfo) {
- // For writing.
- DeviceInfo device_info(user_share()->directory->cache_guid(),
- "John’s Device",
- "XYZ v1",
- "XYZ SyncAgent v1",
- sync_pb::SyncEnums_DeviceType_TYPE_LINUX,
- "device_id");
- WriteLocalDeviceInfo(device_info);
-
- // First read.
- scoped_ptr<DeviceInfo> old_device_info(
- synced_device_tracker_->ReadLocalDeviceInfo());
- ASSERT_TRUE(old_device_info);
-
- ResetObservedChangesCounter();
-
- // Overwrite the device info with the same data as before.
- WriteLocalDeviceInfo(device_info);
-
- // Ensure that this didn't count as a change worth syncing.
- EXPECT_EQ(0, GetObservedChangesCounter());
-
- // Second read.
- scoped_ptr<DeviceInfo> new_device_info(
- synced_device_tracker_->ReadLocalDeviceInfo());
- ASSERT_TRUE(new_device_info);
- EXPECT_TRUE(old_device_info->Equals(*new_device_info.get()));
-}
-
-// Upgrade scenario: update existing device info with new version.
-TEST_F(SyncedDeviceTrackerTest, UpdateExistingDeviceInfo) {
- // Write v1 device info.
- DeviceInfo device_info_v1(user_share()->directory->cache_guid(),
- "John’s Device",
- "XYZ v1",
- "XYZ SyncAgent v1",
- sync_pb::SyncEnums_DeviceType_TYPE_LINUX,
- "device_id1");
- WriteLocalDeviceInfo(device_info_v1);
-
- ResetObservedChangesCounter();
-
- // Write upgraded device info.
- DeviceInfo device_info_v2(user_share()->directory->cache_guid(),
- "John’s Device",
- "XYZ v2",
- "XYZ SyncAgent v2",
- sync_pb::SyncEnums_DeviceType_TYPE_LINUX,
- "device_id2");
- WriteLocalDeviceInfo(device_info_v2);
-
- // Verify result.
- scoped_ptr<DeviceInfo> result_device_info(
- synced_device_tracker_->ReadLocalDeviceInfo());
- ASSERT_TRUE(result_device_info);
-
- EXPECT_TRUE(result_device_info->Equals(device_info_v2));
-
- // The update write should have sent a nudge.
- EXPECT_EQ(1, GetObservedChangesCounter());
-}
-
-// Test retrieving DeviceInfos for all the syncing devices.
-TEST_F(SyncedDeviceTrackerTest, GetAllDeviceInfo) {
- DeviceInfo device_info1(base::GenerateGUID(),
- "abc Device",
- "XYZ v1",
- "XYZ SyncAgent v1",
- sync_pb::SyncEnums_DeviceType_TYPE_LINUX,
- "device_id1");
-
- std::string guid1 = base::GenerateGUID();
-
- DeviceInfo device_info2(base::GenerateGUID(),
- "def Device",
- "XYZ v2",
- "XYZ SyncAgent v2",
- sync_pb::SyncEnums_DeviceType_TYPE_LINUX,
- "device_id2");
-
- std::string guid2 = base::GenerateGUID();
-
- WriteDeviceInfo(device_info1);
- WriteDeviceInfo(device_info2);
-
- ScopedVector<DeviceInfo> device_info;
- synced_device_tracker_->GetAllSyncedDeviceInfo(&device_info);
-
- EXPECT_EQ(device_info.size(), 2U);
- EXPECT_TRUE(device_info[0]->Equals(device_info1));
- EXPECT_TRUE(device_info[1]->Equals(device_info2));
-}
-
-TEST_F(SyncedDeviceTrackerTest, DeviceBackupTime) {
- DeviceInfo device_info(user_share()->directory->cache_guid(),
- "John’s Device",
- "XYZ v1",
- "XYZ SyncAgent v1",
- sync_pb::SyncEnums_DeviceType_TYPE_LINUX,
- "device_id");
- const base::Time test_backup_time =
- base::Time::UnixEpoch() + base::TimeDelta::FromDays(10000);
-
- WriteLocalDeviceInfo(device_info);
- synced_device_tracker_->UpdateLocalDeviceBackupTime(test_backup_time);
-
- // Verify read of device info and backup time.
- EXPECT_EQ(test_backup_time,
- synced_device_tracker_->GetLocalDeviceBackupTime());
- scoped_ptr<DeviceInfo> device_info_out(
- synced_device_tracker_->ReadLocalDeviceInfo());
- ASSERT_TRUE(device_info_out);
- EXPECT_TRUE(device_info.Equals(*device_info_out.get()));
-
- // Verify backup time is not lost after updating device info.
- DeviceInfo device_info2(user_share()->directory->cache_guid(),
- "def Device",
- "XYZ v2",
- "XYZ SyncAgent v2",
- sync_pb::SyncEnums_DeviceType_TYPE_LINUX,
- "device_id");
- WriteLocalDeviceInfo(device_info2);
- EXPECT_EQ(test_backup_time,
- synced_device_tracker_->GetLocalDeviceBackupTime());
-}
-
-} // namespace
-
-} // namespace browser_sync
diff --git a/chrome/browser/sync/profile_sync_components_factory_impl.cc b/chrome/browser/sync/profile_sync_components_factory_impl.cc
index d68f582..a899107 100644
--- a/chrome/browser/sync/profile_sync_components_factory_impl.cc
+++ b/chrome/browser/sync/profile_sync_components_factory_impl.cc
@@ -24,6 +24,7 @@
#include "chrome/browser/sync/glue/bookmark_data_type_controller.h"
#include "chrome/browser/sync/glue/bookmark_model_associator.h"
#include "chrome/browser/sync/glue/chrome_report_unrecoverable_error.h"
+#include "chrome/browser/sync/glue/device_info_data_type_controller.h"
#include "chrome/browser/sync/glue/extension_backed_data_type_controller.h"
#include "chrome/browser/sync/glue/extension_data_type_controller.h"
#include "chrome/browser/sync/glue/extension_setting_data_type_controller.h"
@@ -104,6 +105,7 @@ using browser_sync::BookmarkChangeProcessor;
using browser_sync::BookmarkDataTypeController;
using browser_sync::BookmarkModelAssociator;
using browser_sync::ChromeReportUnrecoverableError;
+using browser_sync::DeviceInfoDataTypeController;
using browser_sync::ExtensionBackedDataTypeController;
using browser_sync::ExtensionDataTypeController;
using browser_sync::ExtensionSettingDataTypeController;
@@ -185,6 +187,10 @@ void ProfileSyncComponentsFactoryImpl::RegisterCommonDataTypes(
syncer::ModelTypeSet disabled_types,
syncer::ModelTypeSet enabled_types,
ProfileSyncService* pss) {
+ // TODO(stanisc): can DEVICE_INFO be one of disabled datatypes?
+ pss->RegisterDataTypeController(new DeviceInfoDataTypeController(
+ this, pss->GetLocalDeviceInfoProvider()));
+
// Autofill sync is enabled by default. Register unless explicitly
// disabled.
if (!disabled_types.Has(syncer::AUTOFILL)) {
@@ -443,6 +449,10 @@ base::WeakPtr<syncer::SyncableService> ProfileSyncComponentsFactoryImpl::
return base::WeakPtr<syncer::SyncableService>();
}
switch (type) {
+ case syncer::DEVICE_INFO:
+ return ProfileSyncServiceFactory::GetForProfile(profile_)
+ ->GetDeviceInfoSyncableService()
+ ->AsWeakPtr();
case syncer::PREFERENCES:
return PrefServiceSyncable::FromProfile(
profile_)->GetSyncableService(syncer::PREFERENCES)->AsWeakPtr();
diff --git a/chrome/browser/sync/profile_sync_components_factory_impl_unittest.cc b/chrome/browser/sync/profile_sync_components_factory_impl_unittest.cc
index 2f5925a..04dc8d4 100644
--- a/chrome/browser/sync/profile_sync_components_factory_impl_unittest.cc
+++ b/chrome/browser/sync/profile_sync_components_factory_impl_unittest.cc
@@ -50,6 +50,7 @@ class ProfileSyncComponentsFactoryImplTest : public testing::Test {
datatypes.push_back(syncer::AUTOFILL);
datatypes.push_back(syncer::AUTOFILL_PROFILE);
datatypes.push_back(syncer::BOOKMARKS);
+ datatypes.push_back(syncer::DEVICE_INFO);
#if defined(OS_LINUX) || defined(OS_WIN) || defined(OS_CHROMEOS)
datatypes.push_back(syncer::DICTIONARY);
#endif
diff --git a/chrome/browser/sync/profile_sync_service.cc b/chrome/browser/sync/profile_sync_service.cc
index 6375c34..a23f96e 100644
--- a/chrome/browser/sync/profile_sync_service.cc
+++ b/chrome/browser/sync/profile_sync_service.cc
@@ -47,11 +47,9 @@
#include "chrome/browser/sync/glue/sync_backend_host.h"
#include "chrome/browser/sync/glue/sync_backend_host_impl.h"
#include "chrome/browser/sync/glue/sync_start_util.h"
-#include "chrome/browser/sync/glue/synced_device_tracker.h"
#include "chrome/browser/sync/glue/typed_url_data_type_controller.h"
#include "chrome/browser/sync/profile_sync_components_factory_impl.h"
#include "chrome/browser/sync/sessions/notification_service_sessions_router.h"
-#include "chrome/browser/sync/sessions/sessions_sync_manager.h"
#include "chrome/browser/sync/supervised_user_signin_manager_wrapper.h"
#include "chrome/browser/sync/sync_error_controller.h"
#include "chrome/browser/sync/sync_type_preference_provider.h"
@@ -259,6 +257,8 @@ ProfileSyncService::ProfileSyncService(
local_device_ = factory_->CreateLocalDeviceInfoProvider();
sessions_sync_manager_.reset(
new SessionsSyncManager(profile, local_device_.get(), router.Pass()));
+ device_info_sync_service_.reset(
+ new DeviceInfoSyncService(local_device_.get()));
}
ProfileSyncService::~ProfileSyncService() {
@@ -426,15 +426,18 @@ void ProfileSyncService::InitializeNonBlockingType(
type, task_runner, type_sync_proxy);
}
-bool ProfileSyncService::IsSessionsDataTypeControllerRunning() const {
- return directory_data_type_controllers_.find(syncer::SESSIONS) !=
- directory_data_type_controllers_.end() &&
- (directory_data_type_controllers_.find(syncer::SESSIONS)->
- second->state() == DataTypeController::RUNNING);
+bool ProfileSyncService::IsDataTypeControllerRunning(
+ syncer::ModelType type) const {
+ DataTypeController::TypeMap::const_iterator iter =
+ directory_data_type_controllers_.find(type);
+ if (iter == directory_data_type_controllers_.end()) {
+ return false;
+ }
+ return iter->second->state() == DataTypeController::RUNNING;
}
browser_sync::OpenTabsUIDelegate* ProfileSyncService::GetOpenTabsUIDelegate() {
- if (!IsSessionsDataTypeControllerRunning())
+ if (!IsDataTypeControllerRunning(syncer::SESSIONS))
return NULL;
return sessions_sync_manager_.get();
}
@@ -448,58 +451,17 @@ ProfileSyncService::GetSyncedWindowDelegatesGetter() const {
return sessions_sync_manager_->GetSyncedWindowDelegatesGetter();
}
-browser_sync::LocalDeviceInfoProvider*
-ProfileSyncService::GetLocalDeviceInfoProvider() {
- return local_device_.get();
-}
-
-scoped_ptr<browser_sync::DeviceInfo>
-ProfileSyncService::GetDeviceInfo(const std::string& client_id) const {
- if (HasSyncingBackend()) {
- browser_sync::SyncedDeviceTracker* device_tracker =
- backend_->GetSyncedDeviceTracker();
- if (device_tracker)
- return device_tracker->ReadDeviceInfo(client_id);
- }
- return scoped_ptr<browser_sync::DeviceInfo>();
-}
-
-ScopedVector<browser_sync::DeviceInfo>
- ProfileSyncService::GetAllSignedInDevices() const {
- ScopedVector<browser_sync::DeviceInfo> devices;
- if (HasSyncingBackend()) {
- browser_sync::SyncedDeviceTracker* device_tracker =
- backend_->GetSyncedDeviceTracker();
- if (device_tracker) {
- // TODO(lipalani) - Make device tracker return a scoped vector.
- device_tracker->GetAllSyncedDeviceInfo(&devices);
- }
- }
- return devices.Pass();
-}
+browser_sync::DeviceInfoTracker* ProfileSyncService::GetDeviceInfoTracker()
+ const {
+ if (!IsDataTypeControllerRunning(syncer::DEVICE_INFO))
+ return NULL;
-// Notifies the observer of any device info changes.
-void ProfileSyncService::AddObserverForDeviceInfoChange(
- browser_sync::SyncedDeviceTracker::Observer* observer) {
- if (HasSyncingBackend()) {
- browser_sync::SyncedDeviceTracker* device_tracker =
- backend_->GetSyncedDeviceTracker();
- if (device_tracker) {
- device_tracker->AddObserver(observer);
- }
- }
+ return device_info_sync_service_.get();
}
-// Removes the observer from device info change notification.
-void ProfileSyncService::RemoveObserverForDeviceInfoChange(
- browser_sync::SyncedDeviceTracker::Observer* observer) {
- if (HasSyncingBackend()) {
- browser_sync::SyncedDeviceTracker* device_tracker =
- backend_->GetSyncedDeviceTracker();
- if (device_tracker) {
- device_tracker->RemoveObserver(observer);
- }
- }
+browser_sync::LocalDeviceInfoProvider*
+ProfileSyncService::GetLocalDeviceInfoProvider() {
+ return local_device_.get();
}
void ProfileSyncService::GetDataTypeControllerStates(
@@ -1048,10 +1010,8 @@ void ProfileSyncService::PostBackendInitialization() {
DCHECK_EQ(backend_mode_, SYNC);
if (last_backup_time_) {
- browser_sync::SyncedDeviceTracker* device_tracker =
- backend_->GetSyncedDeviceTracker();
- if (device_tracker)
- device_tracker->UpdateLocalDeviceBackupTime(*last_backup_time_);
+ DCHECK(device_info_sync_service_);
+ device_info_sync_service_->UpdateLocalDeviceBackupTime(*last_backup_time_);
}
if (protocol_event_observers_.might_have_observers()) {
@@ -1157,7 +1117,7 @@ void ProfileSyncService::OnBackendInitialized(
void ProfileSyncService::OnSyncCycleCompleted() {
UpdateLastSyncedTime();
- if (IsSessionsDataTypeControllerRunning()) {
+ if (IsDataTypeControllerRunning(syncer::SESSIONS)) {
// Trigger garbage collection of old sessions now that we've downloaded
// any new session data.
base::MessageLoop::current()->PostTask(FROM_HERE, base::Bind(
@@ -2608,6 +2568,10 @@ syncer::SyncableService* ProfileSyncService::GetSessionsSyncableService() {
return sessions_sync_manager_.get();
}
+syncer::SyncableService* ProfileSyncService::GetDeviceInfoSyncableService() {
+ return device_info_sync_service_.get();
+}
+
ProfileSyncService::SyncTokenStatus::SyncTokenStatus()
: connection_status(syncer::CONNECTION_NOT_ATTEMPTED),
last_get_token_error(GoogleServiceAuthError::AuthErrorNone()) {}
@@ -2738,12 +2702,8 @@ void ProfileSyncService::CheckSyncBackupIfNeeded() {
void ProfileSyncService::CheckSyncBackupCallback(base::Time backup_time) {
last_backup_time_.reset(new base::Time(backup_time));
- if (HasSyncingBackend() && backend_initialized_) {
- browser_sync::SyncedDeviceTracker* device_tracker =
- backend_->GetSyncedDeviceTracker();
- if (device_tracker)
- device_tracker->UpdateLocalDeviceBackupTime(*last_backup_time_);
- }
+ DCHECK(device_info_sync_service_);
+ device_info_sync_service_->UpdateLocalDeviceBackupTime(*last_backup_time_);
}
void ProfileSyncService::TryStartSyncAfterBackup() {
@@ -2765,5 +2725,5 @@ bool ProfileSyncService::NeedBackup() const {
}
base::Time ProfileSyncService::GetDeviceBackupTimeForTesting() const {
- return backend_->GetSyncedDeviceTracker()->GetLocalDeviceBackupTime();
+ return device_info_sync_service_->GetLocalDeviceBackupTime();
}
diff --git a/chrome/browser/sync/profile_sync_service.h b/chrome/browser/sync/profile_sync_service.h
index e923869..4d88648 100644
--- a/chrome/browser/sync/profile_sync_service.h
+++ b/chrome/browser/sync/profile_sync_service.h
@@ -23,9 +23,9 @@
#include "chrome/browser/browsing_data/browsing_data_remover.h"
#include "chrome/browser/sync/backend_unrecoverable_error_handler.h"
#include "chrome/browser/sync/backup_rollback_controller.h"
+#include "chrome/browser/sync/glue/device_info_sync_service.h"
#include "chrome/browser/sync/glue/local_device_info_provider.h"
#include "chrome/browser/sync/glue/sync_backend_host.h"
-#include "chrome/browser/sync/glue/synced_device_tracker.h"
#include "chrome/browser/sync/profile_sync_service_base.h"
#include "chrome/browser/sync/profile_sync_service_observer.h"
#include "chrome/browser/sync/protocol_event_observer.h"
@@ -66,7 +66,6 @@ class CommandLine;
namespace browser_sync {
class BackendMigrator;
-class DeviceInfo;
class FaviconCache;
class JsController;
class OpenTabsUIDelegate;
@@ -95,6 +94,7 @@ namespace sync_pb {
class EncryptedData;
} // namespace sync_pb
+using browser_sync::DeviceInfoSyncService;
using browser_sync::LocalDeviceInfoProvider;
using browser_sync::SessionsSyncManager;
@@ -374,26 +374,15 @@ class ProfileSyncService : public ProfileSyncServiceBase,
// Returns the SyncableService for syncer::SESSIONS.
virtual syncer::SyncableService* GetSessionsSyncableService();
+ // Returns the SyncableService for syncer::DEVICE_INFO.
+ virtual syncer::SyncableService* GetDeviceInfoSyncableService();
+
// Returns DeviceInfo provider for the local device.
virtual browser_sync::LocalDeviceInfoProvider* GetLocalDeviceInfoProvider();
- // Returns sync's representation of the device info for a client identified
- // by |client_id|. Return value is an empty scoped ptr if the device info
- // is unavailable.
- virtual scoped_ptr<browser_sync::DeviceInfo> GetDeviceInfo(
- const std::string& client_id) const;
-
- // Gets the device info for all devices signed into the account associated
- // with this profile.
- virtual ScopedVector<browser_sync::DeviceInfo> GetAllSignedInDevices() const;
-
- // Notifies the observer of any device info changes.
- virtual void AddObserverForDeviceInfoChange(
- browser_sync::SyncedDeviceTracker::Observer* observer);
-
- // Removes the observer from device info notification.
- virtual void RemoveObserverForDeviceInfoChange(
- browser_sync::SyncedDeviceTracker::Observer* observer);
+ // Returns synced devices tracker. If DEVICE_INFO model type isn't yet
+ // enabled or syncing, returns NULL.
+ virtual browser_sync::DeviceInfoTracker* GetDeviceInfoTracker() const;
// Fills state_map with a map of current data types that are possible to
// sync, as well as their states.
@@ -776,7 +765,7 @@ class ProfileSyncService : public ProfileSyncServiceBase,
void OverrideNetworkResourcesForTest(
scoped_ptr<syncer::NetworkResources> network_resources);
- virtual bool IsSessionsDataTypeControllerRunning() const;
+ virtual bool IsDataTypeControllerRunning(syncer::ModelType type) const;
BackendMode backend_mode() const {
return backend_mode_;
@@ -1142,6 +1131,7 @@ class ProfileSyncService : public ProfileSyncServiceBase,
// Locally owned SyncableService implementations.
scoped_ptr<SessionsSyncManager> sessions_sync_manager_;
+ scoped_ptr<DeviceInfoSyncService> device_info_sync_service_;
scoped_ptr<syncer::NetworkResources> network_resources_;
diff --git a/chrome/browser/sync/profile_sync_service_mock.cc b/chrome/browser/sync/profile_sync_service_mock.cc
index 7364111..f2fc5c1 100644
--- a/chrome/browser/sync/profile_sync_service_mock.cc
+++ b/chrome/browser/sync/profile_sync_service_mock.cc
@@ -55,12 +55,3 @@ KeyedService* ProfileSyncServiceMock::BuildMockProfileSyncService(
content::BrowserContext* profile) {
return new ProfileSyncServiceMock(static_cast<Profile*>(profile));
}
-
-ScopedVector<browser_sync::DeviceInfo>
- ProfileSyncServiceMock::GetAllSignedInDevices() const {
- ScopedVector<browser_sync::DeviceInfo> devices;
- std::vector<browser_sync::DeviceInfo*>* device_vector =
- GetAllSignedInDevicesMock();
- devices.get() = *device_vector;
- return devices.Pass();
-}
diff --git a/chrome/browser/sync/profile_sync_service_mock.h b/chrome/browser/sync/profile_sync_service_mock.h
index c7584e1..25074e6 100644
--- a/chrome/browser/sync/profile_sync_service_mock.h
+++ b/chrome/browser/sync/profile_sync_service_mock.h
@@ -93,13 +93,7 @@ class ProfileSyncServiceMock : public ProfileSyncService {
MOCK_METHOD1(OnActionableError, void(
const syncer::SyncProtocolError&));
MOCK_METHOD1(SetSetupInProgress, void(bool));
- MOCK_CONST_METHOD0(IsSessionsDataTypeControllerRunning, bool());
-
- MOCK_CONST_METHOD0(GetAllSignedInDevicesMock,
- std::vector<browser_sync::DeviceInfo*>* ());
- // This is to get around the fact that GMOCK does not handle Scoped*.
- virtual ScopedVector<browser_sync::DeviceInfo>
- GetAllSignedInDevices() const OVERRIDE;
+ MOCK_CONST_METHOD1(IsDataTypeControllerRunning, bool(syncer::ModelType));
// DataTypeManagerObserver mocks.
MOCK_METHOD0(OnConfigureBlocked, void());
diff --git a/chrome/browser/ui/webui/history_ui.cc b/chrome/browser/ui/webui/history_ui.cc
index 1c604f6..f65ddc2 100644
--- a/chrome/browser/ui/webui/history_ui.cc
+++ b/chrome/browser/ui/webui/history_ui.cc
@@ -233,9 +233,11 @@ void GetDeviceNameAndType(const ProfileSyncService* sync_service,
const std::string& client_id,
std::string* name,
std::string* type) {
- if (sync_service && sync_service->sync_initialized()) {
+ // DeviceInfoTracker becomes available when Sync backend gets initialed.
+ // It must exist in order for remote history entries to be available.
+ if (sync_service && sync_service->GetDeviceInfoTracker()) {
scoped_ptr<browser_sync::DeviceInfo> device_info =
- sync_service->GetDeviceInfo(client_id);
+ sync_service->GetDeviceInfoTracker()->GetDeviceInfo(client_id);
if (device_info.get()) {
*name = device_info->client_name();
switch (device_info->device_type()) {
@@ -251,7 +253,7 @@ void GetDeviceNameAndType(const ProfileSyncService* sync_service,
return;
}
} else {
- NOTREACHED() << "Got a remote history entry but no ProfileSyncService.";
+ NOTREACHED() << "Got a remote history entry but no DeviceInfoTracker.";
}
*name = l10n_util::GetStringUTF8(IDS_HISTORY_UNKNOWN_DEVICE);
*type = kDeviceTypeLaptop;
diff --git a/chrome/chrome_browser.gypi b/chrome/chrome_browser.gypi
index 68b1b7b..869cd77 100644
--- a/chrome/chrome_browser.gypi
+++ b/chrome/chrome_browser.gypi
@@ -1267,8 +1267,6 @@
'browser/sync/glue/sync_backend_registrar.h',
'browser/sync/glue/sync_start_util.cc',
'browser/sync/glue/sync_start_util.h',
- 'browser/sync/glue/synced_device_tracker.cc',
- 'browser/sync/glue/synced_device_tracker.h',
'browser/sync/glue/synced_session.cc',
'browser/sync/glue/synced_session.h',
'browser/sync/glue/synced_session_tracker.cc',
diff --git a/chrome/chrome_tests_unit.gypi b/chrome/chrome_tests_unit.gypi
index 5e3d770..2074c6a 100644
--- a/chrome/chrome_tests_unit.gypi
+++ b/chrome/chrome_tests_unit.gypi
@@ -779,7 +779,6 @@
'browser/sync/glue/sync_backend_host_mock.cc',
'browser/sync/glue/sync_backend_host_mock.h',
'browser/sync/glue/sync_backend_registrar_unittest.cc',
- 'browser/sync/glue/synced_device_tracker_unittest.cc',
'browser/sync/glue/synced_session_tracker_unittest.cc',
'browser/sync/glue/typed_url_model_associator_unittest.cc',
'browser/sync/glue/ui_model_worker_unittest.cc',