summaryrefslogtreecommitdiff
path: root/chrome/browser/sync/glue
diff options
context:
space:
mode:
authorTorne (Richard Coles) <torne@google.com>2014-06-09 12:00:27 +0100
committerTorne (Richard Coles) <torne@google.com>2014-06-09 12:00:27 +0100
commit46d4c2bc3267f3f028f39e7e311b0f89aba2e4fd (patch)
treeed52337c337f5fd1db77873d9ff980ca3e334b35 /chrome/browser/sync/glue
parent7ef4c70daab901f557268ad466f62cd2f7896916 (diff)
downloadchromium_org-46d4c2bc3267f3f028f39e7e311b0f89aba2e4fd.tar.gz
Merge from Chromium at DEPS revision 275586
This commit was generated by merge_to_master.py. Change-Id: Ief3a0ffd810858bfddbe0ec5931e3ee90d53f78c
Diffstat (limited to 'chrome/browser/sync/glue')
-rw-r--r--chrome/browser/sync/glue/bookmark_change_processor.cc2
-rw-r--r--chrome/browser/sync/glue/bookmark_model_associator.cc6
-rw-r--r--chrome/browser/sync/glue/favicon_cache.cc2
-rw-r--r--chrome/browser/sync/glue/non_ui_data_type_controller.cc2
-rw-r--r--chrome/browser/sync/glue/non_ui_data_type_controller.h2
-rw-r--r--chrome/browser/sync/glue/shared_change_processor.cc211
-rw-r--r--chrome/browser/sync/glue/shared_change_processor.h144
-rw-r--r--chrome/browser/sync/glue/shared_change_processor_ref.cc42
-rw-r--r--chrome/browser/sync/glue/shared_change_processor_ref.h50
-rw-r--r--chrome/browser/sync/glue/shared_change_processor_unittest.cc145
-rw-r--r--chrome/browser/sync/glue/sync_backend_host_impl.cc2
-rw-r--r--chrome/browser/sync/glue/sync_backend_host_impl_unittest.cc2
-rw-r--r--chrome/browser/sync/glue/synced_device_tracker.cc5
-rw-r--r--chrome/browser/sync/glue/typed_url_change_processor.cc6
-rw-r--r--chrome/browser/sync/glue/typed_url_model_associator.cc18
-rw-r--r--chrome/browser/sync/glue/typed_url_model_associator.h2
-rw-r--r--chrome/browser/sync/glue/ui_data_type_controller.cc2
-rw-r--r--chrome/browser/sync/glue/ui_data_type_controller.h2
18 files changed, 28 insertions, 617 deletions
diff --git a/chrome/browser/sync/glue/bookmark_change_processor.cc b/chrome/browser/sync/glue/bookmark_change_processor.cc
index 92324a8a6a..67cce64e56 100644
--- a/chrome/browser/sync/glue/bookmark_change_processor.cc
+++ b/chrome/browser/sync/glue/bookmark_change_processor.cc
@@ -551,7 +551,7 @@ void BookmarkChangeProcessor::ApplyChangesFromSyncModel(
syncer::ReadNode synced_bookmarks(trans);
int64 synced_bookmarks_id = syncer::kInvalidId;
- if (synced_bookmarks.InitByTagLookup(kMobileBookmarksTag) ==
+ if (synced_bookmarks.InitByTagLookupForBookmarks(kMobileBookmarksTag) ==
syncer::BaseNode::INIT_OK) {
synced_bookmarks_id = synced_bookmarks.GetId();
}
diff --git a/chrome/browser/sync/glue/bookmark_model_associator.cc b/chrome/browser/sync/glue/bookmark_model_associator.cc
index ab29bac177..ede4307e9f 100644
--- a/chrome/browser/sync/glue/bookmark_model_associator.cc
+++ b/chrome/browser/sync/glue/bookmark_model_associator.cc
@@ -387,7 +387,8 @@ bool BookmarkModelAssociator::GetSyncIdForTaggedNode(const std::string& tag,
int64* sync_id) {
syncer::ReadTransaction trans(FROM_HERE, user_share_);
syncer::ReadNode sync_node(&trans);
- if (sync_node.InitByTagLookup(tag.c_str()) != syncer::BaseNode::INIT_OK)
+ if (sync_node.InitByTagLookupForBookmarks(
+ tag.c_str()) != syncer::BaseNode::INIT_OK)
return false;
*sync_id = sync_node.GetId();
return true;
@@ -484,8 +485,7 @@ syncer::SyncError BookmarkModelAssociator::BuildAssociations(
syncer::WriteTransaction trans(FROM_HERE, user_share_);
syncer::ReadNode bm_root(&trans);
- if (bm_root.InitByTagLookup(syncer::ModelTypeToRootTag(syncer::BOOKMARKS)) ==
- syncer::BaseNode::INIT_OK) {
+ if (bm_root.InitTypeRoot(syncer::BOOKMARKS) == syncer::BaseNode::INIT_OK) {
syncer_merge_result->set_num_items_before_association(
bm_root.GetTotalNodeCount());
}
diff --git a/chrome/browser/sync/glue/favicon_cache.cc b/chrome/browser/sync/glue/favicon_cache.cc
index e64b24093d..e75d6a49d2 100644
--- a/chrome/browser/sync/glue/favicon_cache.cc
+++ b/chrome/browser/sync/glue/favicon_cache.cc
@@ -577,7 +577,7 @@ void FaviconCache::Observe(int type,
content::Details<history::URLsDeletedDetails> deleted_details(details);
// We only care about actual user (or sync) deletions.
- if (deleted_details->archived)
+ if (deleted_details->expired)
return;
if (!deleted_details->all_history) {
diff --git a/chrome/browser/sync/glue/non_ui_data_type_controller.cc b/chrome/browser/sync/glue/non_ui_data_type_controller.cc
index d8e364ca90..a9a3b151f6 100644
--- a/chrome/browser/sync/glue/non_ui_data_type_controller.cc
+++ b/chrome/browser/sync/glue/non_ui_data_type_controller.cc
@@ -7,10 +7,10 @@
#include "base/logging.h"
#include "base/memory/weak_ptr.h"
#include "chrome/browser/profiles/profile.h"
-#include "chrome/browser/sync/glue/shared_change_processor_ref.h"
#include "chrome/browser/sync/profile_sync_components_factory.h"
#include "chrome/browser/sync/profile_sync_service.h"
#include "components/sync_driver/generic_change_processor_factory.h"
+#include "components/sync_driver/shared_change_processor_ref.h"
#include "content/public/browser/browser_thread.h"
#include "sync/api/sync_error.h"
#include "sync/api/syncable_service.h"
diff --git a/chrome/browser/sync/glue/non_ui_data_type_controller.h b/chrome/browser/sync/glue/non_ui_data_type_controller.h
index 29dbc98763..0bb01d66bd 100644
--- a/chrome/browser/sync/glue/non_ui_data_type_controller.h
+++ b/chrome/browser/sync/glue/non_ui_data_type_controller.h
@@ -11,8 +11,8 @@
#include "base/compiler_specific.h"
#include "base/memory/ref_counted.h"
#include "base/memory/weak_ptr.h"
-#include "chrome/browser/sync/glue/shared_change_processor.h"
#include "components/sync_driver/data_type_controller.h"
+#include "components/sync_driver/shared_change_processor.h"
class Profile;
class ProfileSyncService;
diff --git a/chrome/browser/sync/glue/shared_change_processor.cc b/chrome/browser/sync/glue/shared_change_processor.cc
deleted file mode 100644
index 1a122686ce..0000000000
--- a/chrome/browser/sync/glue/shared_change_processor.cc
+++ /dev/null
@@ -1,211 +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/shared_change_processor.h"
-
-#include "base/message_loop/message_loop_proxy.h"
-#include "components/sync_driver/generic_change_processor.h"
-#include "components/sync_driver/generic_change_processor_factory.h"
-#include "components/sync_driver/sync_api_component_factory.h"
-#include "sync/api/sync_change.h"
-
-using base::AutoLock;
-
-namespace browser_sync {
-
-SharedChangeProcessor::SharedChangeProcessor()
- : disconnected_(false),
- type_(syncer::UNSPECIFIED),
- frontend_loop_(base::MessageLoopProxy::current()),
- generic_change_processor_(NULL),
- error_handler_(NULL) {
-}
-
-SharedChangeProcessor::~SharedChangeProcessor() {
- // We can either be deleted when the DTC is destroyed (on UI
- // thread), or when the syncer::SyncableService stop's syncing (datatype
- // thread). |generic_change_processor_|, if non-NULL, must be
- // deleted on |backend_loop_|.
- if (frontend_loop_->BelongsToCurrentThread()) {
- if (backend_loop_.get()) {
- if (!backend_loop_->DeleteSoon(FROM_HERE, generic_change_processor_)) {
- NOTREACHED();
- }
- } else {
- DCHECK(!generic_change_processor_);
- }
- } else {
- DCHECK(backend_loop_.get());
- DCHECK(backend_loop_->BelongsToCurrentThread());
- delete generic_change_processor_;
- }
-}
-
-base::WeakPtr<syncer::SyncableService> SharedChangeProcessor::Connect(
- browser_sync::SyncApiComponentFactory* sync_factory,
- GenericChangeProcessorFactory* processor_factory,
- syncer::UserShare* user_share,
- DataTypeErrorHandler* error_handler,
- syncer::ModelType type,
- const base::WeakPtr<syncer::SyncMergeResult>& merge_result) {
- DCHECK(sync_factory);
- DCHECK(error_handler);
- DCHECK_NE(type, syncer::UNSPECIFIED);
- backend_loop_ = base::MessageLoopProxy::current();
- AutoLock lock(monitor_lock_);
- if (disconnected_)
- return base::WeakPtr<syncer::SyncableService>();
- type_ = type;
- error_handler_ = error_handler;
- base::WeakPtr<syncer::SyncableService> local_service =
- sync_factory->GetSyncableServiceForType(type);
- if (!local_service.get()) {
- LOG(WARNING) << "SyncableService destroyed before DTC was stopped.";
- disconnected_ = true;
- return base::WeakPtr<syncer::SyncableService>();
- }
-
- generic_change_processor_ =
- processor_factory->CreateGenericChangeProcessor(user_share,
- error_handler,
- local_service,
- merge_result,
- sync_factory).release();
- return local_service;
-}
-
-bool SharedChangeProcessor::Disconnect() {
- // May be called from any thread.
- DVLOG(1) << "Disconnecting change processor.";
- AutoLock lock(monitor_lock_);
- bool was_connected = !disconnected_;
- disconnected_ = true;
- error_handler_ = NULL;
- return was_connected;
-}
-
-ChangeProcessor* SharedChangeProcessor::generic_change_processor() {
- return generic_change_processor_;
-}
-
-int SharedChangeProcessor::GetSyncCount() {
- DCHECK(backend_loop_.get());
- DCHECK(backend_loop_->BelongsToCurrentThread());
- AutoLock lock(monitor_lock_);
- if (disconnected_) {
- LOG(ERROR) << "Change processor disconnected.";
- return 0;
- }
- return generic_change_processor_->GetSyncCountForType(type_);
-}
-
-syncer::SyncError SharedChangeProcessor::ProcessSyncChanges(
- const tracked_objects::Location& from_here,
- const syncer::SyncChangeList& list_of_changes) {
- DCHECK(backend_loop_.get());
- DCHECK(backend_loop_->BelongsToCurrentThread());
- AutoLock lock(monitor_lock_);
- if (disconnected_) {
- // The DTC that disconnects us must ensure it posts a StopSyncing task.
- // If we reach this, it means it just hasn't executed yet.
- syncer::SyncError error(FROM_HERE,
- syncer::SyncError::DATATYPE_ERROR,
- "Change processor disconnected.",
- type_);
- return error;
- }
- return generic_change_processor_->ProcessSyncChanges(
- from_here, list_of_changes);
-}
-
-syncer::SyncDataList SharedChangeProcessor::GetAllSyncData(
- syncer::ModelType type) const {
- syncer::SyncDataList data;
- GetAllSyncDataReturnError(type, &data); // Handles the disconnect case.
- return data;
-}
-
-syncer::SyncError SharedChangeProcessor::GetAllSyncDataReturnError(
- syncer::ModelType type,
- syncer::SyncDataList* data) const {
- DCHECK(backend_loop_.get());
- DCHECK(backend_loop_->BelongsToCurrentThread());
- AutoLock lock(monitor_lock_);
- if (disconnected_) {
- syncer::SyncError error(FROM_HERE,
- syncer::SyncError::DATATYPE_ERROR,
- "Change processor disconnected.",
- type_);
- return error;
- }
- return generic_change_processor_->GetAllSyncDataReturnError(type, data);
-}
-
-syncer::SyncError SharedChangeProcessor::UpdateDataTypeContext(
- syncer::ModelType type,
- syncer::SyncChangeProcessor::ContextRefreshStatus refresh_status,
- const std::string& context) {
- DCHECK(backend_loop_.get());
- DCHECK(backend_loop_->BelongsToCurrentThread());
- AutoLock lock(monitor_lock_);
- if (disconnected_) {
- syncer::SyncError error(FROM_HERE,
- syncer::SyncError::DATATYPE_ERROR,
- "Change processor disconnected.",
- type_);
- return error;
- }
- return generic_change_processor_->UpdateDataTypeContext(
- type, refresh_status, context);
-}
-
-bool SharedChangeProcessor::SyncModelHasUserCreatedNodes(bool* has_nodes) {
- DCHECK(backend_loop_.get());
- DCHECK(backend_loop_->BelongsToCurrentThread());
- AutoLock lock(monitor_lock_);
- if (disconnected_) {
- LOG(ERROR) << "Change processor disconnected.";
- return false;
- }
- return generic_change_processor_->SyncModelHasUserCreatedNodes(
- type_, has_nodes);
-}
-
-bool SharedChangeProcessor::CryptoReadyIfNecessary() {
- DCHECK(backend_loop_.get());
- DCHECK(backend_loop_->BelongsToCurrentThread());
- AutoLock lock(monitor_lock_);
- if (disconnected_) {
- LOG(ERROR) << "Change processor disconnected.";
- return true; // Otherwise we get into infinite spin waiting.
- }
- return generic_change_processor_->CryptoReadyIfNecessary(type_);
-}
-
-bool SharedChangeProcessor::GetDataTypeContext(std::string* context) const {
- DCHECK(backend_loop_.get());
- DCHECK(backend_loop_->BelongsToCurrentThread());
- AutoLock lock(monitor_lock_);
- if (disconnected_) {
- LOG(ERROR) << "Change processor disconnected.";
- return false;
- }
- return generic_change_processor_->GetDataTypeContext(type_, context);
-}
-
-syncer::SyncError SharedChangeProcessor::CreateAndUploadError(
- const tracked_objects::Location& location,
- const std::string& message) {
- AutoLock lock(monitor_lock_);
- if (!disconnected_) {
- return error_handler_->CreateAndUploadError(location, message, type_);
- } else {
- return syncer::SyncError(location,
- syncer::SyncError::DATATYPE_ERROR,
- message,
- type_);
- }
-}
-
-} // namespace browser_sync
diff --git a/chrome/browser/sync/glue/shared_change_processor.h b/chrome/browser/sync/glue/shared_change_processor.h
deleted file mode 100644
index 7000bd9a18..0000000000
--- a/chrome/browser/sync/glue/shared_change_processor.h
+++ /dev/null
@@ -1,144 +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_SHARED_CHANGE_PROCESSOR_H_
-#define CHROME_BROWSER_SYNC_GLUE_SHARED_CHANGE_PROCESSOR_H_
-
-#include "base/location.h"
-#include "base/memory/ref_counted.h"
-#include "base/memory/weak_ptr.h"
-#include "base/message_loop/message_loop_proxy.h"
-#include "base/synchronization/lock.h"
-#include "components/sync_driver/data_type_error_handler.h"
-#include "sync/api/sync_change_processor.h"
-#include "sync/api/sync_data.h"
-#include "sync/api/sync_error.h"
-#include "sync/api/sync_error_factory.h"
-#include "sync/api/sync_merge_result.h"
-#include "sync/internal_api/public/engine/model_safe_worker.h"
-
-class ProfileSyncService;
-
-namespace syncer {
-class SyncableService;
-struct UserShare;
-} // namespace syncer
-
-namespace browser_sync {
-
-class ChangeProcessor;
-class GenericChangeProcessor;
-class GenericChangeProcessorFactory;
-class DataTypeErrorHandler;
-class SyncApiComponentFactory;
-
-// A ref-counted wrapper around a GenericChangeProcessor for use with datatypes
-// that don't live on the UI thread.
-//
-// We need to make it refcounted as the ownership transfer from the
-// DataTypeController is dependent on threading, and hence racy. The
-// SharedChangeProcessor should be created on the UI thread, but should only be
-// connected and used on the same thread as the datatype it interacts with.
-//
-// The only thread-safe method is Disconnect, which will disconnect from the
-// generic change processor, letting us shut down the syncer/datatype without
-// waiting for non-UI threads.
-//
-// Note: since we control the work being done while holding the lock, we ensure
-// no I/O or other intensive work is done while blocking the UI thread (all
-// the work is in-memory sync interactions).
-//
-// We use virtual methods so that we can use mock's in testing.
-class SharedChangeProcessor
- : public base::RefCountedThreadSafe<SharedChangeProcessor> {
- public:
- // Create an uninitialized SharedChangeProcessor.
- SharedChangeProcessor();
-
- // Connect to the Syncer and prepare to handle changes for |type|. Will
- // create and store a new GenericChangeProcessor and return a weak pointer to
- // the syncer::SyncableService associated with |type|.
- // Note: If this SharedChangeProcessor has been disconnected, or the
- // syncer::SyncableService was not alive, will return a null weak pointer.
- virtual base::WeakPtr<syncer::SyncableService> Connect(
- browser_sync::SyncApiComponentFactory* sync_factory,
- GenericChangeProcessorFactory* processor_factory,
- syncer::UserShare* user_share,
- DataTypeErrorHandler* error_handler,
- syncer::ModelType type,
- const base::WeakPtr<syncer::SyncMergeResult>& merge_result);
-
- // Disconnects from the generic change processor. May be called from any
- // thread. After this, all attempts to interact with the change processor by
- // |local_service_| are dropped and return errors. The syncer will be safe to
- // shut down from the point of view of this datatype.
- // Note: Once disconnected, you cannot reconnect without creating a new
- // SharedChangeProcessor.
- // Returns: true if we were previously succesfully connected, false if we were
- // already disconnected.
- virtual bool Disconnect();
-
- // GenericChangeProcessor stubs (with disconnect support).
- // Should only be called on the same thread the datatype resides.
- virtual int GetSyncCount();
- virtual syncer::SyncError ProcessSyncChanges(
- const tracked_objects::Location& from_here,
- const syncer::SyncChangeList& change_list);
- virtual syncer::SyncDataList GetAllSyncData(syncer::ModelType type) const;
- virtual syncer::SyncError GetAllSyncDataReturnError(
- syncer::ModelType type,
- syncer::SyncDataList* data) const;
- virtual syncer::SyncError UpdateDataTypeContext(
- syncer::ModelType type,
- syncer::SyncChangeProcessor::ContextRefreshStatus refresh_status,
- const std::string& context);
- virtual bool SyncModelHasUserCreatedNodes(bool* has_nodes);
- virtual bool CryptoReadyIfNecessary();
-
- // If a datatype context associated with the current type exists, fills
- // |context| and returns true. Otheriwse, if there has not been a context
- // set, returns false.
- virtual bool GetDataTypeContext(std::string* context) const;
-
- virtual syncer::SyncError CreateAndUploadError(
- const tracked_objects::Location& location,
- const std::string& message);
-
- ChangeProcessor* generic_change_processor();
-
- protected:
- friend class base::RefCountedThreadSafe<SharedChangeProcessor>;
- virtual ~SharedChangeProcessor();
-
- private:
- // Monitor lock for this object. All methods that interact with the change
- // processor must aquire this lock and check whether we're disconnected or
- // not. Once disconnected, all attempted changes to or loads from the change
- // processor return errors. This enables us to shut down the syncer without
- // having to wait for possibly non-UI thread datatypes to complete work.
- mutable base::Lock monitor_lock_;
- bool disconnected_;
-
- // The sync datatype we were last connected to.
- syncer::ModelType type_;
-
- // The frontend / UI MessageLoop this object is constructed on. May also be
- // destructed and/or disconnected on this loop, see ~SharedChangeProcessor.
- const scoped_refptr<const base::MessageLoopProxy> frontend_loop_;
-
- // The loop that all methods except the constructor, destructor, and
- // Disconnect() should be called on. Set in Connect().
- scoped_refptr<base::MessageLoopProxy> backend_loop_;
-
- // Used only on |backend_loop_|.
- GenericChangeProcessor* generic_change_processor_;
-
- DataTypeErrorHandler* error_handler_;
-
- DISALLOW_COPY_AND_ASSIGN(SharedChangeProcessor);
-};
-
-} // namespace browser_sync
-
-#endif // CHROME_BROWSER_SYNC_GLUE_SHARED_CHANGE_PROCESSOR_H_
diff --git a/chrome/browser/sync/glue/shared_change_processor_ref.cc b/chrome/browser/sync/glue/shared_change_processor_ref.cc
deleted file mode 100644
index 632ec85111..0000000000
--- a/chrome/browser/sync/glue/shared_change_processor_ref.cc
+++ /dev/null
@@ -1,42 +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/shared_change_processor_ref.h"
-
-namespace browser_sync {
-
-SharedChangeProcessorRef::SharedChangeProcessorRef(
- const scoped_refptr<SharedChangeProcessor>& change_processor)
- : change_processor_(change_processor) {
- DCHECK(change_processor_.get());
-}
-
-SharedChangeProcessorRef::~SharedChangeProcessorRef() {}
-
-syncer::SyncError SharedChangeProcessorRef::ProcessSyncChanges(
- const tracked_objects::Location& from_here,
- const syncer::SyncChangeList& change_list) {
- return change_processor_->ProcessSyncChanges(from_here, change_list);
-}
-
-syncer::SyncDataList SharedChangeProcessorRef::GetAllSyncData(
- syncer::ModelType type) const {
- return change_processor_->GetAllSyncData(type);
-}
-
-syncer::SyncError SharedChangeProcessorRef::UpdateDataTypeContext(
- syncer::ModelType type,
- syncer::SyncChangeProcessor::ContextRefreshStatus refresh_status,
- const std::string& context) {
- return change_processor_->UpdateDataTypeContext(
- type, refresh_status, context);
-}
-
-syncer::SyncError SharedChangeProcessorRef::CreateAndUploadError(
- const tracked_objects::Location& from_here,
- const std::string& message) {
- return change_processor_->CreateAndUploadError(from_here, message);
-}
-
-} // namespace browser_sync
diff --git a/chrome/browser/sync/glue/shared_change_processor_ref.h b/chrome/browser/sync/glue/shared_change_processor_ref.h
deleted file mode 100644
index f8ba91c0e1..0000000000
--- a/chrome/browser/sync/glue/shared_change_processor_ref.h
+++ /dev/null
@@ -1,50 +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_SHARED_CHANGE_PROCESSOR_REF_H_
-#define CHROME_BROWSER_SYNC_GLUE_SHARED_CHANGE_PROCESSOR_REF_H_
-
-#include "base/compiler_specific.h"
-#include "base/memory/ref_counted.h"
-#include "chrome/browser/sync/glue/shared_change_processor.h"
-#include "sync/api/sync_change_processor.h"
-#include "sync/api/sync_error_factory.h"
-
-namespace browser_sync {
-
-// A syncer::SyncChangeProcessor stub for interacting with a refcounted
-// SharedChangeProcessor.
-class SharedChangeProcessorRef : public syncer::SyncChangeProcessor,
- public syncer::SyncErrorFactory {
- public:
- SharedChangeProcessorRef(
- const scoped_refptr<browser_sync::SharedChangeProcessor>&
- change_processor);
- virtual ~SharedChangeProcessorRef();
-
- // syncer::SyncChangeProcessor implementation.
- virtual syncer::SyncError ProcessSyncChanges(
- const tracked_objects::Location& from_here,
- const syncer::SyncChangeList& change_list) OVERRIDE;
- virtual syncer::SyncDataList GetAllSyncData(
- syncer::ModelType type) const OVERRIDE;
- virtual syncer::SyncError UpdateDataTypeContext(
- syncer::ModelType type,
- syncer::SyncChangeProcessor::ContextRefreshStatus refresh_status,
- const std::string& context) OVERRIDE;
-
- // syncer::SyncErrorFactory implementation.
- virtual syncer::SyncError CreateAndUploadError(
- const tracked_objects::Location& from_here,
- const std::string& message) OVERRIDE;
-
- // Default copy and assign welcome (and safe due to refcounted-ness).
-
- private:
- scoped_refptr<browser_sync::SharedChangeProcessor> change_processor_;
-};
-
-} // namespace browser_sync
-
-#endif // CHROME_BROWSER_SYNC_GLUE_SHARED_CHANGE_PROCESSOR_REF_H_
diff --git a/chrome/browser/sync/glue/shared_change_processor_unittest.cc b/chrome/browser/sync/glue/shared_change_processor_unittest.cc
deleted file mode 100644
index 46190b1a72..0000000000
--- a/chrome/browser/sync/glue/shared_change_processor_unittest.cc
+++ /dev/null
@@ -1,145 +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/shared_change_processor.h"
-
-#include <cstddef>
-
-#include "base/bind.h"
-#include "base/bind_helpers.h"
-#include "base/compiler_specific.h"
-#include "base/message_loop/message_loop.h"
-#include "chrome/browser/sync/profile_sync_components_factory_impl.h"
-#include "chrome/browser/sync/profile_sync_components_factory_mock.h"
-#include "chrome/browser/sync/profile_sync_service_mock.h"
-#include "components/sync_driver/data_type_error_handler_mock.h"
-#include "components/sync_driver/generic_change_processor.h"
-#include "components/sync_driver/generic_change_processor_factory.h"
-#include "content/public/test/test_browser_thread.h"
-#include "sync/api/fake_syncable_service.h"
-#include "testing/gmock/include/gmock/gmock.h"
-#include "testing/gtest/include/gtest/gtest.h"
-
-namespace browser_sync {
-
-namespace {
-
-using content::BrowserThread;
-using ::testing::NiceMock;
-using ::testing::StrictMock;
-
-ACTION_P(GetWeakPtrToSyncableService, syncable_service) {
- // Have to do this within an Action to ensure it's not evaluated on the wrong
- // thread.
- return syncable_service->AsWeakPtr();
-}
-
-class SyncSharedChangeProcessorTest : public testing::Test {
- public:
- SyncSharedChangeProcessorTest()
- : ui_thread_(BrowserThread::UI, &ui_loop_),
- db_thread_(BrowserThread::DB),
- sync_service_(&profile_) {}
-
- virtual ~SyncSharedChangeProcessorTest() {
- EXPECT_FALSE(db_syncable_service_.get());
- }
-
- protected:
- virtual void SetUp() OVERRIDE {
- shared_change_processor_ = new SharedChangeProcessor();
- db_thread_.Start();
- EXPECT_TRUE(BrowserThread::PostTask(
- BrowserThread::DB,
- FROM_HERE,
- base::Bind(&SyncSharedChangeProcessorTest::SetUpDBSyncableService,
- base::Unretained(this))));
- }
-
- virtual void TearDown() OVERRIDE {
- EXPECT_TRUE(BrowserThread::PostTask(
- BrowserThread::DB,
- FROM_HERE,
- base::Bind(&SyncSharedChangeProcessorTest::TearDownDBSyncableService,
- base::Unretained(this))));
- // This must happen before the DB thread is stopped since
- // |shared_change_processor_| may post tasks to delete its members
- // on the correct thread.
- //
- // TODO(akalin): Write deterministic tests for the destruction of
- // |shared_change_processor_| on the UI and DB threads.
- shared_change_processor_ = NULL;
- db_thread_.Stop();
- }
-
- // Connect |shared_change_processor_| on the DB thread.
- void Connect() {
- EXPECT_TRUE(BrowserThread::PostTask(
- BrowserThread::DB,
- FROM_HERE,
- base::Bind(&SyncSharedChangeProcessorTest::ConnectOnDBThread,
- base::Unretained(this),
- shared_change_processor_)));
- }
-
- private:
- // Used by SetUp().
- void SetUpDBSyncableService() {
- DCHECK(BrowserThread::CurrentlyOn(BrowserThread::DB));
- DCHECK(!db_syncable_service_.get());
- db_syncable_service_.reset(new syncer::FakeSyncableService());
- }
-
- // Used by TearDown().
- void TearDownDBSyncableService() {
- DCHECK(BrowserThread::CurrentlyOn(BrowserThread::DB));
- DCHECK(db_syncable_service_.get());
- db_syncable_service_.reset();
- }
-
- // Used by Connect(). The SharedChangeProcessor is passed in
- // because we modify |shared_change_processor_| on the main thread
- // (in TearDown()).
- void ConnectOnDBThread(
- const scoped_refptr<SharedChangeProcessor>& shared_change_processor) {
- DCHECK(BrowserThread::CurrentlyOn(BrowserThread::DB));
- EXPECT_CALL(sync_factory_, GetSyncableServiceForType(syncer::AUTOFILL)).
- WillOnce(GetWeakPtrToSyncableService(db_syncable_service_.get()));
- syncer::UserShare share;
- EXPECT_CALL(sync_service_, GetUserShare()).WillOnce(
- ::testing::Return(&share));
- EXPECT_TRUE(shared_change_processor->Connect(
- &sync_factory_,
- &processor_factory_,
- sync_service_.GetUserShare(),
- &error_handler_,
- syncer::AUTOFILL,
- base::WeakPtr<syncer::SyncMergeResult>()));
- }
-
- base::MessageLoopForUI ui_loop_;
- content::TestBrowserThread ui_thread_;
- content::TestBrowserThread db_thread_;
-
- scoped_refptr<SharedChangeProcessor> shared_change_processor_;
- NiceMock<ProfileSyncComponentsFactoryMock> sync_factory_;
- TestingProfile profile_;
- NiceMock<ProfileSyncServiceMock> sync_service_;
- StrictMock<DataTypeErrorHandlerMock> error_handler_;
-
- GenericChangeProcessorFactory processor_factory_;
-
- // Used only on DB thread.
- scoped_ptr<syncer::FakeSyncableService> db_syncable_service_;
-};
-
-// Simply connect the shared change processor. It should succeed, and
-// nothing further should happen.
-TEST_F(SyncSharedChangeProcessorTest, Basic) {
- Connect();
-}
-
-} // namespace
-
-} // namespace browser_sync
diff --git a/chrome/browser/sync/glue/sync_backend_host_impl.cc b/chrome/browser/sync/glue/sync_backend_host_impl.cc
index 915903749c..253db617d6 100644
--- a/chrome/browser/sync/glue/sync_backend_host_impl.cc
+++ b/chrome/browser/sync/glue/sync_backend_host_impl.cc
@@ -8,12 +8,12 @@
#include "base/logging.h"
#include "chrome/browser/browser_process.h"
#include "chrome/browser/chrome_notification_types.h"
-#include "chrome/browser/network_time/network_time_tracker.h"
#include "chrome/browser/profiles/profile.h"
#include "chrome/browser/sync/glue/sync_backend_host_core.h"
#include "chrome/browser/sync/glue/sync_backend_registrar.h"
#include "chrome/common/chrome_switches.h"
#include "components/invalidation/invalidation_service.h"
+#include "components/network_time/network_time_tracker.h"
#include "components/sync_driver/sync_frontend.h"
#include "components/sync_driver/sync_prefs.h"
#include "content/public/browser/browser_thread.h"
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 6148be96c3..dfccb18eac 100644
--- a/chrome/browser/sync/glue/sync_backend_host_impl_unittest.cc
+++ b/chrome/browser/sync/glue/sync_backend_host_impl_unittest.cc
@@ -28,6 +28,7 @@
#include "content/public/test/test_utils.h"
#include "google/cacheinvalidation/include/types.h"
#include "net/url_request/test_url_fetcher_factory.h"
+#include "sync/internal_api/public/base/invalidator_state.h"
#include "sync/internal_api/public/base/model_type.h"
#include "sync/internal_api/public/engine/model_safe_worker.h"
#include "sync/internal_api/public/http_bridge_network_resources.h"
@@ -38,7 +39,6 @@
#include "sync/internal_api/public/sync_manager_factory.h"
#include "sync/internal_api/public/test/fake_sync_manager.h"
#include "sync/internal_api/public/util/experiments.h"
-#include "sync/notifier/invalidator_state.h"
#include "sync/protocol/encryption.pb.h"
#include "sync/protocol/sync_protocol_error.h"
#include "sync/util/test_unrecoverable_error_handler.h"
diff --git a/chrome/browser/sync/glue/synced_device_tracker.cc b/chrome/browser/sync/glue/synced_device_tracker.cc
index fa4770f098..bf7fa9274f 100644
--- a/chrome/browser/sync/glue/synced_device_tracker.cc
+++ b/chrome/browser/sync/glue/synced_device_tracker.cc
@@ -104,8 +104,7 @@ void SyncedDeviceTracker::GetAllSyncedDeviceInfo(
syncer::ReadTransaction trans(FROM_HERE, user_share_);
syncer::ReadNode root_node(&trans);
- if (root_node.InitByTagLookup(
- syncer::ModelTypeToRootTag(syncer::DEVICE_INFO)) !=
+ if (root_node.InitTypeRoot(syncer::DEVICE_INFO) !=
syncer::BaseNode::INIT_OK) {
return;
}
@@ -182,7 +181,7 @@ void SyncedDeviceTracker::WriteDeviceInfo(
} else {
syncer::ReadNode type_root(&trans);
syncer::BaseNode::InitByLookupResult type_root_lookup_result =
- type_root.InitByTagLookup(ModelTypeToRootTag(syncer::DEVICE_INFO));
+ type_root.InitTypeRoot(syncer::DEVICE_INFO);
DCHECK_EQ(syncer::BaseNode::INIT_OK, type_root_lookup_result);
syncer::WriteNode new_node(&trans);
diff --git a/chrome/browser/sync/glue/typed_url_change_processor.cc b/chrome/browser/sync/glue/typed_url_change_processor.cc
index 75f79303c0..0cb1ab28d6 100644
--- a/chrome/browser/sync/glue/typed_url_change_processor.cc
+++ b/chrome/browser/sync/glue/typed_url_change_processor.cc
@@ -111,7 +111,7 @@ bool TypedUrlChangeProcessor::CreateOrUpdateSyncNode(
}
syncer::ReadNode typed_url_root(trans);
- if (typed_url_root.InitByTagLookup(kTypedUrlTag) !=
+ if (typed_url_root.InitTypeRoot(syncer::TYPED_URLS) !=
syncer::BaseNode::INIT_OK) {
error_handler()->OnSingleDatatypeUnrecoverableError(FROM_HERE,
"Server did not create the top-level typed_url node. We "
@@ -189,7 +189,7 @@ void TypedUrlChangeProcessor::HandleURLsDeleted(
// a bad clock setting won't go on an archival rampage and delete all
// history from every client). The server will gracefully age out the sync DB
// entries when they've been idle for long enough.
- if (details->archived)
+ if (details->expired)
return;
if (details->all_history) {
@@ -252,7 +252,7 @@ void TypedUrlChangeProcessor::ApplyChangesFromSyncModel(
return;
syncer::ReadNode typed_url_root(trans);
- if (typed_url_root.InitByTagLookup(kTypedUrlTag) !=
+ if (typed_url_root.InitTypeRoot(syncer::TYPED_URLS) !=
syncer::BaseNode::INIT_OK) {
error_handler()->OnSingleDatatypeUnrecoverableError(FROM_HERE,
"TypedUrl root node lookup failed.");
diff --git a/chrome/browser/sync/glue/typed_url_model_associator.cc b/chrome/browser/sync/glue/typed_url_model_associator.cc
index 1a0503e224..8a619adfa2 100644
--- a/chrome/browser/sync/glue/typed_url_model_associator.cc
+++ b/chrome/browser/sync/glue/typed_url_model_associator.cc
@@ -37,8 +37,6 @@ static const int kMaxTypedUrlVisits = 100;
// RELOAD visits, which will be stripped.
static const int kMaxVisitsToFetch = 1000;
-const char kTypedUrlTag[] = "google_chrome_typed_urls";
-
static bool CheckVisitOrdering(const history::VisitVector& visits) {
int64 previous_visit_time = 0;
for (history::VisitVector::const_iterator visit = visits.begin();
@@ -96,6 +94,14 @@ bool TypedUrlModelAssociator::FixupURLAndGetVisits(
// This is a workaround for http://crbug.com/84258.
if (visits->empty()) {
DVLOG(1) << "Found empty visits for URL: " << url->url();
+
+ if (url->last_visit().is_null()) {
+ // If modified URL is bookmarked, history backend treats it as modified
+ // even if all its visits are deleted. Return false to stop further
+ // processing because sync expects valid visit time for modified entry.
+ return false;
+ }
+
history::VisitRow visit(
url->id(), url->last_visit(), 0, content::PAGE_TRANSITION_TYPED, 0);
visits->push_back(visit);
@@ -220,8 +226,8 @@ syncer::SyncError TypedUrlModelAssociator::DoAssociateModels() {
syncer::WriteTransaction trans(FROM_HERE, sync_service_->GetUserShare());
syncer::ReadNode typed_url_root(&trans);
- if (typed_url_root.InitByTagLookup(kTypedUrlTag) !=
- syncer::BaseNode::INIT_OK) {
+ if (typed_url_root.InitTypeRoot(syncer::TYPED_URLS) !=
+ syncer::BaseNode::INIT_OK) {
return error_handler_->CreateAndUploadError(
FROM_HERE,
"Server did not create the top-level typed_url node. We "
@@ -458,7 +464,7 @@ bool TypedUrlModelAssociator::DeleteAllNodes(
// Just walk through all our child nodes and delete them.
syncer::ReadNode typed_url_root(trans);
- if (typed_url_root.InitByTagLookup(kTypedUrlTag) !=
+ if (typed_url_root.InitTypeRoot(syncer::TYPED_URLS) !=
syncer::BaseNode::INIT_OK) {
LOG(ERROR) << "Could not lookup root node";
return false;
@@ -491,7 +497,7 @@ bool TypedUrlModelAssociator::SyncModelHasUserCreatedNodes(bool* has_nodes) {
*has_nodes = false;
syncer::ReadTransaction trans(FROM_HERE, sync_service_->GetUserShare());
syncer::ReadNode sync_node(&trans);
- if (sync_node.InitByTagLookup(kTypedUrlTag) != syncer::BaseNode::INIT_OK) {
+ if (sync_node.InitTypeRoot(syncer::TYPED_URLS) != syncer::BaseNode::INIT_OK) {
LOG(ERROR) << "Server did not create the top-level typed_url node. We "
<< "might be running against an out-of-date server.";
return false;
diff --git a/chrome/browser/sync/glue/typed_url_model_associator.h b/chrome/browser/sync/glue/typed_url_model_associator.h
index 0c2f7cfda3..b3232540c8 100644
--- a/chrome/browser/sync/glue/typed_url_model_associator.h
+++ b/chrome/browser/sync/glue/typed_url_model_associator.h
@@ -37,8 +37,6 @@ class WriteTransaction;
namespace browser_sync {
-extern const char kTypedUrlTag[];
-
// Contains all model association related logic:
// * Algorithm to associate typed_url model and sync model.
// * Persisting model associations and loading them back.
diff --git a/chrome/browser/sync/glue/ui_data_type_controller.cc b/chrome/browser/sync/glue/ui_data_type_controller.cc
index 8dab9c9731..ff9c37b46e 100644
--- a/chrome/browser/sync/glue/ui_data_type_controller.cc
+++ b/chrome/browser/sync/glue/ui_data_type_controller.cc
@@ -7,10 +7,10 @@
#include "base/logging.h"
#include "base/memory/weak_ptr.h"
#include "chrome/browser/profiles/profile.h"
-#include "chrome/browser/sync/glue/shared_change_processor_ref.h"
#include "chrome/browser/sync/profile_sync_components_factory.h"
#include "chrome/browser/sync/profile_sync_service.h"
#include "components/sync_driver/generic_change_processor_factory.h"
+#include "components/sync_driver/shared_change_processor_ref.h"
#include "content/public/browser/browser_thread.h"
#include "sync/api/sync_error.h"
#include "sync/api/syncable_service.h"
diff --git a/chrome/browser/sync/glue/ui_data_type_controller.h b/chrome/browser/sync/glue/ui_data_type_controller.h
index 1552f3f325..256a7e1e33 100644
--- a/chrome/browser/sync/glue/ui_data_type_controller.h
+++ b/chrome/browser/sync/glue/ui_data_type_controller.h
@@ -11,8 +11,8 @@
#include "base/compiler_specific.h"
#include "base/memory/ref_counted.h"
#include "base/memory/weak_ptr.h"
-#include "chrome/browser/sync/glue/shared_change_processor.h"
#include "components/sync_driver/data_type_controller.h"
+#include "components/sync_driver/shared_change_processor.h"
class Profile;
class ProfileSyncService;