diff options
author | Allan Sandfeld Jensen <allan.jensen@qt.io> | 2017-01-04 14:17:57 +0100 |
---|---|---|
committer | Allan Sandfeld Jensen <allan.jensen@qt.io> | 2017-01-05 10:05:06 +0000 |
commit | 39d357e3248f80abea0159765ff39554affb40db (patch) | |
tree | aba0e6bfb76de0244bba0f5fdbd64b830dd6e621 /chromium/components/sync_bookmarks | |
parent | 87778abf5a1f89266f37d1321b92a21851d8244d (diff) | |
download | qtwebengine-chromium-39d357e3248f80abea0159765ff39554affb40db.tar.gz |
BASELINE: Update Chromium to 55.0.2883.105
And updates ninja to 1.7.2
Change-Id: I20d43c737f82764d857ada9a55586901b18b9243
Reviewed-by: Michael BrĂ¼ning <michael.bruning@qt.io>
Diffstat (limited to 'chromium/components/sync_bookmarks')
9 files changed, 139 insertions, 157 deletions
diff --git a/chromium/components/sync_bookmarks/BUILD.gn b/chromium/components/sync_bookmarks/BUILD.gn index a1eb017f43b..12b3607bff8 100644 --- a/chromium/components/sync_bookmarks/BUILD.gn +++ b/chromium/components/sync_bookmarks/BUILD.gn @@ -4,7 +4,7 @@ import("//build/config/features.gni") -source_set("sync_bookmarks") { +static_library("sync_bookmarks") { sources = [ "bookmark_change_processor.cc", "bookmark_change_processor.h", @@ -19,9 +19,8 @@ source_set("sync_bookmarks") { "//components/bookmarks/browser", "//components/favicon/core", "//components/history/core/browser", - "//components/sync_driver", + "//components/sync", "//components/undo", - "//sync", "//ui/gfx", ] } @@ -40,9 +39,8 @@ source_set("unit_tests") { "//components/bookmarks/test", "//components/history/core/browser", "//components/prefs:test_support", - "//components/sync_driver", - "//components/sync_driver:test_support", - "//sync", + "//components/sync", + "//components/sync:test_support_sync_driver", "//testing/gmock", "//testing/gtest", ] diff --git a/chromium/components/sync_bookmarks/DEPS b/chromium/components/sync_bookmarks/DEPS index 53ccb4a78c5..0d5798c76af 100644 --- a/chromium/components/sync_bookmarks/DEPS +++ b/chromium/components/sync_bookmarks/DEPS @@ -4,8 +4,7 @@ include_rules = [ "+components/favicon/core", "+components/history/core/browser", "+components/prefs", - "+components/sync_driver", + "+components/sync", "+components/undo", - "+sync", "+ui/gfx", ] diff --git a/chromium/components/sync_bookmarks/bookmark_change_processor.cc b/chromium/components/sync_bookmarks/bookmark_change_processor.cc index 5577df49210..f840fe02081 100644 --- a/chromium/components/sync_bookmarks/bookmark_change_processor.cc +++ b/chromium/components/sync_bookmarks/bookmark_change_processor.cc @@ -9,7 +9,7 @@ #include <map> #include <stack> #include <string> -#include <vector> +#include <utility> #include "base/location.h" #include "base/strings/string16.h" @@ -21,15 +21,15 @@ #include "components/bookmarks/browser/bookmark_utils.h" #include "components/favicon/core/favicon_service.h" #include "components/history/core/browser/history_service.h" -#include "components/sync_driver/sync_client.h" +#include "components/sync/core/change_record.h" +#include "components/sync/core/read_node.h" +#include "components/sync/core/write_node.h" +#include "components/sync/core/write_transaction.h" +#include "components/sync/driver/sync_client.h" +#include "components/sync/syncable/entry.h" // TODO(tim): Investigating bug 121587. +#include "components/sync/syncable/syncable_write_transaction.h" #include "components/undo/bookmark_undo_service.h" #include "components/undo/bookmark_undo_utils.h" -#include "sync/internal_api/public/change_record.h" -#include "sync/internal_api/public/read_node.h" -#include "sync/internal_api/public/write_node.h" -#include "sync/internal_api/public/write_transaction.h" -#include "sync/syncable/entry.h" // TODO(tim): Investigating bug 121587. -#include "sync/syncable/syncable_write_transaction.h" #include "ui/gfx/favicon_size.h" #include "ui/gfx/image/image_util.h" @@ -38,21 +38,21 @@ using bookmarks::BookmarkNode; using syncer::ChangeRecord; using syncer::ChangeRecordList; -namespace browser_sync { +namespace sync_bookmarks { static const char kMobileBookmarksTag[] = "synced_bookmarks"; BookmarkChangeProcessor::BookmarkChangeProcessor( - sync_driver::SyncClient* sync_client, + syncer::SyncClient* sync_client, BookmarkModelAssociator* model_associator, - syncer::DataTypeErrorHandler* error_handler) - : sync_driver::ChangeProcessor(error_handler), + std::unique_ptr<syncer::DataTypeErrorHandler> err_handler) + : syncer::ChangeProcessor(std::move(err_handler)), bookmark_model_(NULL), sync_client_(sync_client), model_associator_(model_associator) { DCHECK(model_associator); DCHECK(sync_client); - DCHECK(error_handler); + DCHECK(error_handler()); } BookmarkChangeProcessor::~BookmarkChangeProcessor() { @@ -136,7 +136,7 @@ void BookmarkChangeProcessor::RemoveSyncNodeHierarchy( syncer::SyncError::DATATYPE_ERROR, "Failed to init sync node from chrome node", syncer::BOOKMARKS); - error_handler()->OnSingleDataTypeUnrecoverableError(error); + error_handler()->OnUnrecoverableError(error); return; } RemoveSyncNodeHierarchy(&trans, &topmost_sync_node, model_associator_); @@ -310,7 +310,7 @@ int64_t BookmarkChangeProcessor::CreateSyncNode( if (!PlaceSyncNode(CREATE, parent, index, trans, &sync_child, associator)) { syncer::SyncError error(FROM_HERE, syncer::SyncError::DATATYPE_ERROR, "Failed to create sync node.", syncer::BOOKMARKS); - error_handler->OnSingleDataTypeUnrecoverableError(error); + error_handler->OnUnrecoverableError(error); return syncer::kInvalidId; } @@ -374,7 +374,7 @@ int64_t BookmarkChangeProcessor::UpdateSyncNode( syncer::SyncError::DATATYPE_ERROR, "Failed to init sync node from chrome node", syncer::BOOKMARKS); - error_handler->OnSingleDataTypeUnrecoverableError(error); + error_handler->OnUnrecoverableError(error); return syncer::kInvalidId; } UpdateSyncNodeProperties(node, model, &sync_node, error_handler); @@ -416,7 +416,7 @@ void BookmarkChangeProcessor::BookmarkNodeMoved(BookmarkModel* model, syncer::SyncError::DATATYPE_ERROR, "Failed to init sync node from chrome node", syncer::BOOKMARKS); - error_handler()->OnSingleDataTypeUnrecoverableError(error); + error_handler()->OnUnrecoverableError(error); return; } @@ -426,7 +426,7 @@ void BookmarkChangeProcessor::BookmarkNodeMoved(BookmarkModel* model, syncer::SyncError::DATATYPE_ERROR, "Failed to place sync node", syncer::BOOKMARKS); - error_handler()->OnSingleDataTypeUnrecoverableError(error); + error_handler()->OnUnrecoverableError(error); return; } } @@ -488,7 +488,7 @@ void BookmarkChangeProcessor::BookmarkNodeChildrenReordered( syncer::SyncError::DATATYPE_ERROR, "Failed to init sync node from chrome node", syncer::BOOKMARKS); - error_handler()->OnSingleDataTypeUnrecoverableError(error); + error_handler()->OnUnrecoverableError(error); return; } DCHECK_EQ(sync_child.GetParentId(), @@ -500,7 +500,7 @@ void BookmarkChangeProcessor::BookmarkNodeChildrenReordered( syncer::SyncError::DATATYPE_ERROR, "Failed to place sync node", syncer::BOOKMARKS); - error_handler()->OnSingleDataTypeUnrecoverableError(error); + error_handler()->OnUnrecoverableError(error); return; } } @@ -625,7 +625,7 @@ void BookmarkChangeProcessor::ApplyChangesFromSyncModel( syncer::SyncError::DATATYPE_ERROR, "Failed to create foster parent", syncer::BOOKMARKS); - error_handler()->OnSingleDataTypeUnrecoverableError(error); + error_handler()->OnUnrecoverableError(error); return; } } @@ -686,7 +686,7 @@ void BookmarkChangeProcessor::ApplyChangesFromSyncModel( syncer::SyncError::DATATYPE_ERROR, "Failed to load sync node", syncer::BOOKMARKS); - error_handler()->OnSingleDataTypeUnrecoverableError(error); + error_handler()->OnUnrecoverableError(error); return; } @@ -764,7 +764,7 @@ void BookmarkChangeProcessor::UpdateBookmarkWithSyncData( const syncer::BaseNode& sync_node, BookmarkModel* model, const BookmarkNode* node, - sync_driver::SyncClient* sync_client) { + syncer::SyncClient* sync_client) { DCHECK_EQ(sync_node.GetIsFolder(), node->is_folder()); const sync_pb::BookmarkSpecifics& specifics = sync_node.GetBookmarkSpecifics(); @@ -800,7 +800,7 @@ const BookmarkNode* BookmarkChangeProcessor::CreateBookmarkNode( const syncer::BaseNode* sync_node, const BookmarkNode* parent, BookmarkModel* model, - sync_driver::SyncClient* sync_client, + syncer::SyncClient* sync_client, int index) { return CreateBookmarkNode(base::UTF8ToUTF16(sync_node->GetTitle()), GURL(sync_node->GetBookmarkSpecifics().url()), @@ -816,7 +816,7 @@ const BookmarkNode* BookmarkChangeProcessor::CreateBookmarkNode( const syncer::BaseNode* sync_node, const BookmarkNode* parent, BookmarkModel* model, - sync_driver::SyncClient* sync_client, + syncer::SyncClient* sync_client, int index) { DCHECK(parent); @@ -847,7 +847,7 @@ bool BookmarkChangeProcessor::SetBookmarkFavicon( const syncer::BaseNode* sync_node, const BookmarkNode* bookmark_node, BookmarkModel* bookmark_model, - sync_driver::SyncClient* sync_client) { + syncer::SyncClient* sync_client) { const sync_pb::BookmarkSpecifics& specifics = sync_node->GetBookmarkSpecifics(); const std::string& icon_bytes_str = specifics.favicon(); @@ -936,7 +936,7 @@ void BookmarkChangeProcessor::SetSyncNodeMetaInfo( // static void BookmarkChangeProcessor::ApplyBookmarkFavicon( const BookmarkNode* bookmark_node, - sync_driver::SyncClient* sync_client, + syncer::SyncClient* sync_client, const GURL& icon_url, const scoped_refptr<base::RefCountedMemory>& bitmap_data) { history::HistoryService* history = sync_client->GetHistoryService(); @@ -977,4 +977,4 @@ bool BookmarkChangeProcessor::CanSyncNode(const BookmarkNode* node) { return bookmark_model_->client()->CanSyncNode(node); } -} // namespace browser_sync +} // namespace sync_bookmarks diff --git a/chromium/components/sync_bookmarks/bookmark_change_processor.h b/chromium/components/sync_bookmarks/bookmark_change_processor.h index 4e70d40edc7..df214019d20 100644 --- a/chromium/components/sync_bookmarks/bookmark_change_processor.h +++ b/chromium/components/sync_bookmarks/bookmark_change_processor.h @@ -8,6 +8,7 @@ #include <stdint.h> #include <memory> +#include <set> #include <vector> #include "base/compiler_specific.h" @@ -15,37 +16,35 @@ #include "base/threading/thread_checker.h" #include "components/bookmarks/browser/bookmark_model_observer.h" #include "components/bookmarks/browser/bookmark_node.h" +#include "components/sync/api/data_type_error_handler.h" +#include "components/sync/driver/change_processor.h" #include "components/sync_bookmarks/bookmark_model_associator.h" -#include "components/sync_driver/change_processor.h" -#include "sync/internal_api/public/data_type_error_handler.h" class Profile; namespace base { class RefCountedMemory; -} +} // namespace base namespace syncer { +class SyncClient; class WriteNode; class WriteTransaction; } // namespace syncer -namespace sync_driver { -class SyncClient; -} - -namespace browser_sync { +namespace sync_bookmarks { // This class is responsible for taking changes from the BookmarkModel // and applying them to the sync API 'syncable' model, and vice versa. // All operations and use of this class are from the UI thread. // This is currently bookmarks specific. class BookmarkChangeProcessor : public bookmarks::BookmarkModelObserver, - public sync_driver::ChangeProcessor { + public syncer::ChangeProcessor { public: - BookmarkChangeProcessor(sync_driver::SyncClient* sync_client, - BookmarkModelAssociator* model_associator, - syncer::DataTypeErrorHandler* error_handler); + BookmarkChangeProcessor( + syncer::SyncClient* sync_client, + BookmarkModelAssociator* model_associator, + std::unique_ptr<syncer::DataTypeErrorHandler> error_handler); ~BookmarkChangeProcessor() override; // bookmarks::BookmarkModelObserver: @@ -98,7 +97,7 @@ class BookmarkChangeProcessor : public bookmarks::BookmarkModelObserver, static void UpdateBookmarkWithSyncData(const syncer::BaseNode& sync_node, bookmarks::BookmarkModel* model, const bookmarks::BookmarkNode* node, - sync_driver::SyncClient* sync_client); + syncer::SyncClient* sync_client); // Creates a bookmark node under the given parent node from the given sync // node. Returns the newly created node. The created node is placed at the @@ -107,7 +106,7 @@ class BookmarkChangeProcessor : public bookmarks::BookmarkModelObserver, const syncer::BaseNode* sync_node, const bookmarks::BookmarkNode* parent, bookmarks::BookmarkModel* model, - sync_driver::SyncClient* sync_client, + syncer::SyncClient* sync_client, int index); // Overload of CreateBookmarkNode function above that helps to avoid @@ -118,7 +117,7 @@ class BookmarkChangeProcessor : public bookmarks::BookmarkModelObserver, const syncer::BaseNode* sync_node, const bookmarks::BookmarkNode* parent, bookmarks::BookmarkModel* model, - sync_driver::SyncClient* sync_client, + syncer::SyncClient* sync_client, int index); // Sets the favicon of the given bookmark node from the given sync node. @@ -128,14 +127,14 @@ class BookmarkChangeProcessor : public bookmarks::BookmarkModelObserver, static bool SetBookmarkFavicon(const syncer::BaseNode* sync_node, const bookmarks::BookmarkNode* bookmark_node, bookmarks::BookmarkModel* model, - sync_driver::SyncClient* sync_client); + syncer::SyncClient* sync_client); // Applies the 1x favicon |bitmap_data| and |icon_url| to |bookmark_node|. // |profile| is the profile that contains the HistoryService and BookmarkModel // for the bookmark in question. static void ApplyBookmarkFavicon( const bookmarks::BookmarkNode* bookmark_node, - sync_driver::SyncClient* sync_client, + syncer::SyncClient* sync_client, const GURL& icon_url, const scoped_refptr<base::RefCountedMemory>& bitmap_data); @@ -248,7 +247,7 @@ class BookmarkChangeProcessor : public bookmarks::BookmarkModelObserver, // |running_| is true. bookmarks::BookmarkModel* bookmark_model_; - sync_driver::SyncClient* sync_client_; + syncer::SyncClient* sync_client_; // The two models should be associated according to this ModelAssociator. BookmarkModelAssociator* model_associator_; @@ -256,6 +255,6 @@ class BookmarkChangeProcessor : public bookmarks::BookmarkModelObserver, DISALLOW_COPY_AND_ASSIGN(BookmarkChangeProcessor); }; -} // namespace browser_sync +} // namespace sync_bookmarks #endif // COMPONENTS_SYNC_BOOKMARKS_BOOKMARK_CHANGE_PROCESSOR_H_ diff --git a/chromium/components/sync_bookmarks/bookmark_data_type_controller.cc b/chromium/components/sync_bookmarks/bookmark_data_type_controller.cc index 85e71fabe1a..1a2e494eb6b 100644 --- a/chromium/components/sync_bookmarks/bookmark_data_type_controller.cc +++ b/chromium/components/sync_bookmarks/bookmark_data_type_controller.cc @@ -7,29 +7,26 @@ #include "base/metrics/histogram.h" #include "components/bookmarks/browser/bookmark_model.h" #include "components/history/core/browser/history_service.h" -#include "components/sync_driver/sync_api_component_factory.h" -#include "components/sync_driver/sync_client.h" +#include "components/sync/driver/sync_api_component_factory.h" +#include "components/sync/driver/sync_client.h" using bookmarks::BookmarkModel; -namespace browser_sync { +namespace sync_bookmarks { BookmarkDataTypeController::BookmarkDataTypeController( - const scoped_refptr<base::SingleThreadTaskRunner>& ui_thread, - const base::Closure& error_callback, - sync_driver::SyncClient* sync_client) - : FrontendDataTypeController(ui_thread, error_callback, sync_client), + const base::Closure& dump_stack, + syncer::SyncClient* sync_client) + : syncer::FrontendDataTypeController(syncer::BOOKMARKS, + dump_stack, + sync_client), history_service_observer_(this), bookmark_model_observer_(this) {} -syncer::ModelType BookmarkDataTypeController::type() const { - return syncer::BOOKMARKS; -} - -BookmarkDataTypeController::~BookmarkDataTypeController() { -} +BookmarkDataTypeController::~BookmarkDataTypeController() {} bool BookmarkDataTypeController::StartModels() { + DCHECK(CalledOnValidThread()); if (!DependentsLoaded()) { BookmarkModel* bookmark_model = sync_client_->GetBookmarkModel(); bookmark_model_observer_.Add(bookmark_model); @@ -42,14 +39,16 @@ bool BookmarkDataTypeController::StartModels() { } void BookmarkDataTypeController::CleanUpState() { + DCHECK(CalledOnValidThread()); history_service_observer_.RemoveAll(); bookmark_model_observer_.RemoveAll(); } void BookmarkDataTypeController::CreateSyncComponents() { - sync_driver::SyncApiComponentFactory::SyncComponents sync_components = + DCHECK(CalledOnValidThread()); + syncer::SyncApiComponentFactory::SyncComponents sync_components = sync_client_->GetSyncApiComponentFactory()->CreateBookmarkSyncComponents( - sync_client_->GetSyncService(), this); + sync_client_->GetSyncService(), CreateErrorHandler()); set_model_associator(sync_components.model_associator); set_change_processor(sync_components.change_processor); } @@ -59,6 +58,7 @@ void BookmarkDataTypeController::BookmarkModelChanged() { void BookmarkDataTypeController::BookmarkModelLoaded(BookmarkModel* model, bool ids_reassigned) { + DCHECK(CalledOnValidThread()); DCHECK(model->loaded()); bookmark_model_observer_.RemoveAll(); @@ -77,6 +77,7 @@ void BookmarkDataTypeController::BookmarkModelBeingDeleted( // Check that both the bookmark model and the history service (for favicons) // are loaded. bool BookmarkDataTypeController::DependentsLoaded() { + DCHECK(CalledOnValidThread()); BookmarkModel* bookmark_model = sync_client_->GetBookmarkModel(); if (!bookmark_model || !bookmark_model->loaded()) return false; @@ -91,6 +92,7 @@ bool BookmarkDataTypeController::DependentsLoaded() { void BookmarkDataTypeController::OnHistoryServiceLoaded( history::HistoryService* service) { + DCHECK(CalledOnValidThread()); DCHECK_EQ(state_, MODEL_STARTING); history_service_observer_.RemoveAll(); @@ -106,4 +108,4 @@ void BookmarkDataTypeController::HistoryServiceBeingDeleted( CleanUpState(); } -} // namespace browser_sync +} // namespace sync_bookmarks diff --git a/chromium/components/sync_bookmarks/bookmark_data_type_controller.h b/chromium/components/sync_bookmarks/bookmark_data_type_controller.h index 578e2de85d6..62c2741586d 100644 --- a/chromium/components/sync_bookmarks/bookmark_data_type_controller.h +++ b/chromium/components/sync_bookmarks/bookmark_data_type_controller.h @@ -12,27 +12,22 @@ #include "base/scoped_observer.h" #include "components/bookmarks/browser/base_bookmark_model_observer.h" #include "components/history/core/browser/history_service_observer.h" -#include "components/sync_driver/frontend_data_type_controller.h" +#include "components/sync/driver/frontend_data_type_controller.h" -namespace browser_sync { +namespace sync_bookmarks { // A class that manages the startup and shutdown of bookmark sync. -class BookmarkDataTypeController : public FrontendDataTypeController, +class BookmarkDataTypeController : public syncer::FrontendDataTypeController, public bookmarks::BaseBookmarkModelObserver, public history::HistoryServiceObserver { public: - BookmarkDataTypeController( - const scoped_refptr<base::SingleThreadTaskRunner>& ui_thread, - const base::Closure& error_callback, - sync_driver::SyncClient* sync_client); - - // FrontendDataTypeController: - syncer::ModelType type() const override; - - private: + // |dump_stack| is called when an unrecoverable error occurs. + BookmarkDataTypeController(const base::Closure& dump_stack, + syncer::SyncClient* sync_client); ~BookmarkDataTypeController() override; - // FrontendDataTypeController: + private: + // syncer::FrontendDataTypeController: bool StartModels() override; void CleanUpState() override; void CreateSyncComponents() override; @@ -60,6 +55,6 @@ class BookmarkDataTypeController : public FrontendDataTypeController, DISALLOW_COPY_AND_ASSIGN(BookmarkDataTypeController); }; -} // namespace browser_sync +} // namespace sync_bookmarks #endif // COMPONENTS_SYNC_BOOKMARKS_BOOKMARK_DATA_TYPE_CONTROLLER_H__ diff --git a/chromium/components/sync_bookmarks/bookmark_data_type_controller_unittest.cc b/chromium/components/sync_bookmarks/bookmark_data_type_controller_unittest.cc index b2d37942330..8090509e082 100644 --- a/chromium/components/sync_bookmarks/bookmark_data_type_controller_unittest.cc +++ b/chromium/components/sync_bookmarks/bookmark_data_type_controller_unittest.cc @@ -18,23 +18,23 @@ #include "components/bookmarks/test/test_bookmark_client.h" #include "components/history/core/browser/history_service.h" #include "components/prefs/testing_pref_service.h" -#include "components/sync_driver/change_processor_mock.h" -#include "components/sync_driver/data_type_controller_mock.h" -#include "components/sync_driver/fake_sync_client.h" -#include "components/sync_driver/fake_sync_service.h" -#include "components/sync_driver/model_associator_mock.h" -#include "components/sync_driver/sync_api_component_factory_mock.h" -#include "sync/api/sync_error.h" +#include "components/sync/api/sync_error.h" +#include "components/sync/driver/change_processor_mock.h" +#include "components/sync/driver/data_type_controller_mock.h" +#include "components/sync/driver/fake_sync_client.h" +#include "components/sync/driver/fake_sync_service.h" +#include "components/sync/driver/model_associator_mock.h" +#include "components/sync/driver/sync_api_component_factory_mock.h" #include "testing/gmock/include/gmock/gmock.h" #include "testing/gtest/include/gtest/gtest.h" using bookmarks::BookmarkModel; -using browser_sync::BookmarkDataTypeController; -using sync_driver::ChangeProcessorMock; -using sync_driver::DataTypeController; -using sync_driver::ModelAssociatorMock; -using sync_driver::ModelLoadCallbackMock; -using sync_driver::StartCallbackMock; +using sync_bookmarks::BookmarkDataTypeController; +using syncer::ChangeProcessorMock; +using syncer::DataTypeController; +using syncer::ModelAssociatorMock; +using syncer::ModelLoadCallbackMock; +using syncer::StartCallbackMock; using testing::_; using testing::DoAll; using testing::InvokeWithoutArgs; @@ -54,7 +54,7 @@ class HistoryMock : public history::HistoryService { } // namespace class SyncBookmarkDataTypeControllerTest : public testing::Test, - public sync_driver::FakeSyncClient { + public syncer::FakeSyncClient { public: SyncBookmarkDataTypeControllerTest() {} @@ -63,10 +63,8 @@ class SyncBookmarkDataTypeControllerTest : public testing::Test, history::HistoryService* GetHistoryService() override { return history_service_.get(); } - sync_driver::SyncService* GetSyncService() override { - return &service_; - } - sync_driver::SyncApiComponentFactory* GetSyncApiComponentFactory() override { + syncer::SyncService* GetSyncService() override { return &service_; } + syncer::SyncApiComponentFactory* GetSyncApiComponentFactory() override { return profile_sync_factory_.get(); } @@ -74,12 +72,10 @@ class SyncBookmarkDataTypeControllerTest : public testing::Test, model_associator_ = new ModelAssociatorMock(); change_processor_ = new ChangeProcessorMock(); history_service_.reset(new HistoryMock()); - profile_sync_factory_.reset( - new SyncApiComponentFactoryMock(model_associator_, - change_processor_)); - bookmark_dtc_ = - new BookmarkDataTypeController(base::ThreadTaskRunnerHandle::Get(), - base::Bind(&base::DoNothing), this); + profile_sync_factory_.reset(new syncer::SyncApiComponentFactoryMock( + model_associator_, change_processor_)); + bookmark_dtc_.reset( + new BookmarkDataTypeController(base::Bind(&base::DoNothing), this)); } protected: @@ -89,8 +85,8 @@ class SyncBookmarkDataTypeControllerTest : public testing::Test, }; void CreateBookmarkModel(BookmarkLoadPolicy bookmark_load_policy) { - bookmark_model_.reset(new BookmarkModel( - base::WrapUnique(new bookmarks::TestBookmarkClient()))); + bookmark_model_.reset( + new BookmarkModel(base::MakeUnique<bookmarks::TestBookmarkClient>())); if (bookmark_load_policy == LOAD_MODEL) { TestingPrefServiceSimple prefs; bookmark_model_->Load(&prefs, base::FilePath(), @@ -109,7 +105,6 @@ class SyncBookmarkDataTypeControllerTest : public testing::Test, void SetAssociateExpectations() { EXPECT_CALL(*model_associator_, CryptoReadyIfNecessary()). WillRepeatedly(Return(true)); - EXPECT_CALL(*profile_sync_factory_, CreateBookmarkSyncComponents(_, _)); EXPECT_CALL(*model_associator_, SyncModelHasUserCreatedNodes(_)). WillRepeatedly(DoAll(SetArgumentPointee<0>(true), Return(true))); EXPECT_CALL(*model_associator_, AssociateModels(_, _)). @@ -136,11 +131,11 @@ class SyncBookmarkDataTypeControllerTest : public testing::Test, } base::MessageLoop message_loop_; - scoped_refptr<BookmarkDataTypeController> bookmark_dtc_; - std::unique_ptr<SyncApiComponentFactoryMock> profile_sync_factory_; + std::unique_ptr<syncer::SyncApiComponentFactoryMock> profile_sync_factory_; std::unique_ptr<BookmarkModel> bookmark_model_; std::unique_ptr<HistoryMock> history_service_; - sync_driver::FakeSyncService service_; + std::unique_ptr<BookmarkDataTypeController> bookmark_dtc_; + syncer::FakeSyncService service_; ModelAssociatorMock* model_associator_; ChangeProcessorMock* change_processor_; StartCallbackMock start_callback_; @@ -244,7 +239,6 @@ TEST_F(SyncBookmarkDataTypeControllerTest, StartAssociationFailed) { CreateBookmarkModel(LOAD_MODEL); SetStartExpectations(); // Set up association to fail. - EXPECT_CALL(*profile_sync_factory_, CreateBookmarkSyncComponents(_, _)); EXPECT_CALL(*model_associator_, CryptoReadyIfNecessary()). WillRepeatedly(Return(true)); EXPECT_CALL(*model_associator_, SyncModelHasUserCreatedNodes(_)). @@ -266,7 +260,6 @@ TEST_F(SyncBookmarkDataTypeControllerTest, CreateBookmarkModel(LOAD_MODEL); SetStartExpectations(); // Set up association to fail with an unrecoverable error. - EXPECT_CALL(*profile_sync_factory_, CreateBookmarkSyncComponents(_, _)); EXPECT_CALL(*model_associator_, CryptoReadyIfNecessary()). WillRepeatedly(Return(true)); EXPECT_CALL(*model_associator_, SyncModelHasUserCreatedNodes(_)). diff --git a/chromium/components/sync_bookmarks/bookmark_model_associator.cc b/chromium/components/sync_bookmarks/bookmark_model_associator.cc index a3fbf638206..6ccdea35b42 100644 --- a/chromium/components/sync_bookmarks/bookmark_model_associator.cc +++ b/chromium/components/sync_bookmarks/bookmark_model_associator.cc @@ -4,14 +4,12 @@ #include "components/sync_bookmarks/bookmark_model_associator.h" -#include <memory> +#include <utility> #include "base/bind.h" #include "base/command_line.h" -#include "base/containers/hash_tables.h" #include "base/format_macros.h" #include "base/location.h" -#include "base/macros.h" #include "base/single_thread_task_runner.h" #include "base/strings/string_number_conversions.h" #include "base/strings/string_util.h" @@ -20,27 +18,27 @@ #include "base/threading/thread_task_runner_handle.h" #include "components/bookmarks/browser/bookmark_client.h" #include "components/bookmarks/browser/bookmark_model.h" +#include "components/sync/api/sync_error.h" +#include "components/sync/api/sync_merge_result.h" +#include "components/sync/base/cryptographer.h" +#include "components/sync/base/data_type_histogram.h" +#include "components/sync/core/delete_journal.h" +#include "components/sync/core/read_node.h" +#include "components/sync/core/read_transaction.h" +#include "components/sync/core/write_node.h" +#include "components/sync/core/write_transaction.h" +#include "components/sync/core_impl/syncapi_internal.h" +#include "components/sync/driver/sync_client.h" +#include "components/sync/syncable/entry.h" +#include "components/sync/syncable/syncable_write_transaction.h" #include "components/sync_bookmarks/bookmark_change_processor.h" -#include "components/sync_driver/sync_client.h" #include "components/undo/bookmark_undo_service.h" #include "components/undo/bookmark_undo_utils.h" -#include "sync/api/sync_error.h" -#include "sync/api/sync_merge_result.h" -#include "sync/internal_api/public/delete_journal.h" -#include "sync/internal_api/public/read_node.h" -#include "sync/internal_api/public/read_transaction.h" -#include "sync/internal_api/public/write_node.h" -#include "sync/internal_api/public/write_transaction.h" -#include "sync/internal_api/syncapi_internal.h" -#include "sync/syncable/entry.h" -#include "sync/syncable/syncable_write_transaction.h" -#include "sync/util/cryptographer.h" -#include "sync/util/data_type_histogram.h" using bookmarks::BookmarkModel; using bookmarks::BookmarkNode; -namespace browser_sync { +namespace sync_bookmarks { // The sync protocol identifies top-level entities by means of well-known tags, // which should not be confused with titles. Each tag corresponds to a @@ -308,14 +306,14 @@ void BookmarkModelAssociator::Context::MarkForVersionUpdate( BookmarkModelAssociator::BookmarkModelAssociator( BookmarkModel* bookmark_model, - sync_driver::SyncClient* sync_client, + syncer::SyncClient* sync_client, syncer::UserShare* user_share, - syncer::DataTypeErrorHandler* unrecoverable_error_handler, + std::unique_ptr<syncer::DataTypeErrorHandler> unrecoverable_error_handler, bool expect_mobile_bookmarks_folder) : bookmark_model_(bookmark_model), sync_client_(sync_client), user_share_(user_share), - unrecoverable_error_handler_(unrecoverable_error_handler), + unrecoverable_error_handler_(std::move(unrecoverable_error_handler)), expect_mobile_bookmarks_folder_(expect_mobile_bookmarks_folder), weak_factory_(this) { DCHECK(bookmark_model_); @@ -729,7 +727,7 @@ syncer::SyncError BookmarkModelAssociator::BuildAssociations( for (int i = index; i < parent_node->child_count(); ++i) { int64_t sync_child_id = BookmarkChangeProcessor::CreateSyncNode( parent_node, bookmark_model_, i, trans, this, - unrecoverable_error_handler_); + unrecoverable_error_handler_.get()); if (syncer::kInvalidId == sync_child_id) { return unrecoverable_error_handler_->CreateAndUploadError( FROM_HERE, "Failed to create sync node.", model_type()); @@ -791,7 +789,7 @@ int BookmarkModelAssociator::RemoveSyncNodeHierarchy( syncer::SyncError error(FROM_HERE, syncer::SyncError::DATATYPE_ERROR, "Could not lookup bookmark node for ID deletion.", syncer::BOOKMARKS); - unrecoverable_error_handler_->OnSingleDataTypeUnrecoverableError(error); + unrecoverable_error_handler_->OnUnrecoverableError(error); return 0; } @@ -946,7 +944,7 @@ void BookmarkModelAssociator::PersistAssociations() { syncer::SyncError::DATATYPE_ERROR, "Could not lookup bookmark node for ID persistence.", syncer::BOOKMARKS); - unrecoverable_error_handler_->OnSingleDataTypeUnrecoverableError(error); + unrecoverable_error_handler_->OnUnrecoverableError(error); return; } const BookmarkNode* node = GetChromeNodeFromSyncId(sync_id); @@ -1015,4 +1013,4 @@ syncer::SyncError BookmarkModelAssociator::CheckModelSyncState( return syncer::SyncError(); } -} // namespace browser_sync +} // namespace sync_bookmarks diff --git a/chromium/components/sync_bookmarks/bookmark_model_associator.h b/chromium/components/sync_bookmarks/bookmark_model_associator.h index 28d5229efd9..926a3510037 100644 --- a/chromium/components/sync_bookmarks/bookmark_model_associator.h +++ b/chromium/components/sync_bookmarks/bookmark_model_associator.h @@ -9,6 +9,7 @@ #include <stdint.h> #include <map> +#include <memory> #include <set> #include <stack> #include <string> @@ -21,9 +22,9 @@ #include "base/memory/weak_ptr.h" #include "base/strings/string16.h" #include "base/threading/thread_checker.h" -#include "components/sync_driver/model_associator.h" -#include "sync/internal_api/public/data_type_error_handler.h" -#include "sync/internal_api/public/util/unrecoverable_error_handler.h" +#include "components/sync/api/data_type_error_handler.h" +#include "components/sync/base/unrecoverable_error_handler.h" +#include "components/sync/driver/model_associator.h" class GURL; @@ -35,23 +36,20 @@ class BookmarkNode; namespace syncer { class BaseNode; class BaseTransaction; -struct UserShare; -class WriteTransaction; -} - -namespace sync_driver { class SyncClient; +class WriteTransaction; +struct UserShare; } -namespace browser_sync { +namespace sync_bookmarks { // Contains all model association related logic: // * Algorithm to associate bookmark model and sync model. // * Methods to get a bookmark node for a given sync node and vice versa. // * Persisting model associations and loading them back. class BookmarkModelAssociator - : public sync_driver:: - PerDataTypeAssociatorInterface<bookmarks::BookmarkNode, int64_t> { + : public syncer::PerDataTypeAssociatorInterface<bookmarks::BookmarkNode, + int64_t> { public: static syncer::ModelType model_type() { return syncer::BOOKMARKS; } // |expect_mobile_bookmarks_folder| controls whether or not we @@ -59,9 +57,9 @@ class BookmarkModelAssociator // Should be set to true only by mobile clients. BookmarkModelAssociator( bookmarks::BookmarkModel* bookmark_model, - sync_driver::SyncClient* sync_client, + syncer::SyncClient* sync_client, syncer::UserShare* user_share, - syncer::DataTypeErrorHandler* unrecoverable_error_handler, + std::unique_ptr<syncer::DataTypeErrorHandler> unrecoverable_error_handler, bool expect_mobile_bookmarks_folder); ~BookmarkModelAssociator() override; @@ -292,9 +290,9 @@ class BookmarkModelAssociator base::ThreadChecker thread_checker_; bookmarks::BookmarkModel* bookmark_model_; - sync_driver::SyncClient* sync_client_; + syncer::SyncClient* sync_client_; syncer::UserShare* user_share_; - syncer::DataTypeErrorHandler* unrecoverable_error_handler_; + std::unique_ptr<syncer::DataTypeErrorHandler> unrecoverable_error_handler_; const bool expect_mobile_bookmarks_folder_; BookmarkIdToSyncIdMap id_map_; SyncIdToBookmarkNodeMap id_map_inverse_; @@ -309,6 +307,6 @@ class BookmarkModelAssociator DISALLOW_COPY_AND_ASSIGN(BookmarkModelAssociator); }; -} // namespace browser_sync +} // namespace sync_bookmarks #endif // COMPONENTS_SYNC_BOOKMARKS_BOOKMARK_MODEL_ASSOCIATOR_H_ |