Commit f4bc69c5 authored by Pavel Yatsuk's avatar Pavel Yatsuk Committed by Commit Bot

[Sync] Skeleton implementation of USS Bookmarks processor and DTC

In this change:
- added a feature to control USS bookmarks throug finch.
- Added skeleton implementation of BookmarkModelTypeController
- Added skeleton implementation of BookmarkModelTypeProcessor

BUG=516866
R=skym@chromium.org

Change-Id: I90aab77d4aa44523d937eb039d93ad69a6132788
Reviewed-on: https://chromium-review.googlesource.com/609109
Commit-Queue: Pavel Yatsuk <pavely@chromium.org>
Reviewed-by: default avatarSky Malice <skym@chromium.org>
Cr-Commit-Position: refs/heads/master@{#493230}
parent b907d9b5
......@@ -45,6 +45,7 @@
#include "components/sync_bookmarks/bookmark_change_processor.h"
#include "components/sync_bookmarks/bookmark_data_type_controller.h"
#include "components/sync_bookmarks/bookmark_model_associator.h"
#include "components/sync_bookmarks/bookmark_model_type_controller.h"
#include "components/sync_sessions/session_data_type_controller.h"
#include "google_apis/gaia/oauth2_token_service.h"
#include "google_apis/gaia/oauth2_token_service_request.h"
......@@ -204,9 +205,14 @@ void ProfileSyncComponentsFactoryImpl::RegisterCommonDataTypes(
// Bookmark sync is enabled by default. Register unless explicitly
// disabled.
if (!disabled_types.Has(syncer::BOOKMARKS)) {
sync_service->RegisterDataTypeController(
base::MakeUnique<BookmarkDataTypeController>(error_callback,
sync_client_));
if (FeatureList::IsEnabled(switches::kSyncUSSBookmarks)) {
sync_service->RegisterDataTypeController(
base::MakeUnique<sync_bookmarks::BookmarkModelTypeController>());
} else {
sync_service->RegisterDataTypeController(
base::MakeUnique<BookmarkDataTypeController>(error_callback,
sync_client_));
}
}
// These features are enabled only if history is not disabled.
......
......@@ -144,11 +144,6 @@ void AsyncDirectoryTypeController::Stop() {
state_ = NOT_RUNNING;
}
std::string AsyncDirectoryTypeController::name() const {
// For logging only.
return ModelTypeToString(type());
}
DataTypeController::State AsyncDirectoryTypeController::state() const {
return state_;
}
......
......@@ -39,7 +39,6 @@ class AsyncDirectoryTypeController : public DirectoryDataTypeController {
void StartAssociating(const StartCallback& start_callback) override;
void Stop() override;
ChangeProcessor* GetChangeProcessor() const override;
std::string name() const override;
State state() const override;
// Used by tests to override the factory used to create
......
......@@ -137,7 +137,7 @@ class DataTypeController : public base::SupportsWeakPtr<DataTypeController> {
virtual void Stop() = 0;
// Name of this data type. For logging purposes only.
virtual std::string name() const = 0;
std::string name() const { return ModelTypeToString(type()); }
// Current state of the data type controller.
virtual State state() const = 0;
......
......@@ -112,10 +112,6 @@ void FakeDataTypeController::Stop() {
state_ = NOT_RUNNING;
}
std::string FakeDataTypeController::name() const {
return ModelTypeToString(type());
}
ChangeProcessor* FakeDataTypeController::GetChangeProcessor() const {
return nullptr;
}
......
......@@ -34,7 +34,6 @@ class FakeDataTypeController : public DirectoryDataTypeController {
ModelTypeConfigurer* configurer) override;
void StartAssociating(const StartCallback& start_callback) override;
void Stop() override;
std::string name() const override;
ChangeProcessor* GetChangeProcessor() const override;
State state() const override;
bool ReadyForStart() const override;
......
......@@ -106,11 +106,6 @@ void FrontendDataTypeController::Stop() {
state_ = NOT_RUNNING;
}
std::string FrontendDataTypeController::name() const {
// For logging only.
return ModelTypeToString(type());
}
DataTypeController::State FrontendDataTypeController::state() const {
return state_;
}
......
......@@ -46,7 +46,6 @@ class FrontendDataTypeController : public DirectoryDataTypeController {
void LoadModels(const ModelLoadCallback& model_load_callback) override;
void StartAssociating(const StartCallback& start_callback) override;
void Stop() override;
std::string name() const override;
State state() const override;
protected:
......
......@@ -217,11 +217,6 @@ void ModelTypeController::Stop() {
state_ = NOT_RUNNING;
}
std::string ModelTypeController::name() const {
// For logging only.
return ModelTypeToString(type());
}
DataTypeController::State ModelTypeController::state() const {
return state_;
}
......
......@@ -46,7 +46,6 @@ class ModelTypeController : public DataTypeController {
void ActivateDataType(ModelTypeConfigurer* configurer) override;
void DeactivateDataType(ModelTypeConfigurer* configurer) override;
void Stop() override;
std::string name() const override;
State state() const override;
void GetAllNodes(const AllNodesCallback& callback) override;
void GetStatusCounters(const StatusCountersCallback& callback) override;
......
......@@ -58,11 +58,6 @@ void ProxyDataTypeController::Stop() {
state_ = NOT_RUNNING;
}
std::string ProxyDataTypeController::name() const {
// For logging only.
return ModelTypeToString(type());
}
DataTypeController::State ProxyDataTypeController::state() const {
return state_;
}
......
......@@ -29,7 +29,6 @@ class ProxyDataTypeController : public DataTypeController {
ModelTypeConfigurer* configurer) override;
void StartAssociating(const StartCallback& start_callback) override;
void Stop() override;
std::string name() const override;
State state() const override;
void ActivateDataType(ModelTypeConfigurer* configurer) override;
void DeactivateDataType(ModelTypeConfigurer* configurer) override;
......
......@@ -53,6 +53,10 @@ const base::Feature kSyncUserTranslationEvents{
const base::Feature kSyncUSSAutocomplete{"SyncUSSAutocomplete",
base::FEATURE_DISABLED_BY_DEFAULT};
// Enable USS implementation of Bookmarks datatype.
const base::Feature kSyncUSSBookmarks{"SyncUSSBookmarks",
base::FEATURE_DISABLED_BY_DEFAULT};
// Enables USS implementation of DeviceInfo datatype. This flag controls whether
// SyncableService based or ModelTypeSyncBridge based implementation is used for
// DeviceInfo type.
......
......@@ -24,8 +24,9 @@ extern const base::Feature kSyncUserEvents;
extern const base::Feature kSyncUserLanguageDetectionEvents;
extern const base::Feature kSyncUserTranslationEvents;
extern const base::Feature kSyncUSSAutocomplete;
extern const base::Feature kSyncUSSTypedURL;
extern const base::Feature kSyncUSSBookmarks;
extern const base::Feature kSyncUSSDeviceInfo;
extern const base::Feature kSyncUSSTypedURL;
} // namespace switches
......
......@@ -12,6 +12,10 @@ static_library("sync_bookmarks") {
"bookmark_data_type_controller.h",
"bookmark_model_associator.cc",
"bookmark_model_associator.h",
"bookmark_model_type_controller.cc",
"bookmark_model_type_controller.h",
"bookmark_model_type_processor.cc",
"bookmark_model_type_processor.h",
]
deps = [
......@@ -30,6 +34,7 @@ source_set("unit_tests") {
sources = [
"bookmark_data_type_controller_unittest.cc",
"bookmark_model_type_processor_unittest.cc",
]
deps = [
......
......@@ -7,7 +7,6 @@
#include <string>
#include "base/compiler_specific.h"
#include "base/macros.h"
#include "base/scoped_observer.h"
#include "components/bookmarks/browser/base_bookmark_model_observer.h"
......
// Copyright 2017 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 "components/sync_bookmarks/bookmark_model_type_controller.h"
namespace sync_bookmarks {
BookmarkModelTypeController::BookmarkModelTypeController()
: DataTypeController(syncer::BOOKMARKS) {}
bool BookmarkModelTypeController::ShouldLoadModelBeforeConfigure() const {
NOTIMPLEMENTED();
return false;
}
void BookmarkModelTypeController::BeforeLoadModels(
syncer::ModelTypeConfigurer* configurer) {
NOTIMPLEMENTED();
}
void BookmarkModelTypeController::LoadModels(
const ModelLoadCallback& model_load_callback) {
NOTIMPLEMENTED();
}
void BookmarkModelTypeController::RegisterWithBackend(
base::Callback<void(bool)> set_downloaded,
syncer::ModelTypeConfigurer* configurer) {
NOTIMPLEMENTED();
}
void BookmarkModelTypeController::StartAssociating(
const StartCallback& start_callback) {
NOTIMPLEMENTED();
}
void BookmarkModelTypeController::ActivateDataType(
syncer::ModelTypeConfigurer* configurer) {
NOTIMPLEMENTED();
}
void BookmarkModelTypeController::DeactivateDataType(
syncer::ModelTypeConfigurer* configurer) {
NOTIMPLEMENTED();
}
void BookmarkModelTypeController::Stop() {
NOTIMPLEMENTED();
}
syncer::DataTypeController::State BookmarkModelTypeController::state() const {
NOTIMPLEMENTED();
return NOT_RUNNING;
}
void BookmarkModelTypeController::GetAllNodes(
const AllNodesCallback& callback) {
NOTIMPLEMENTED();
}
void BookmarkModelTypeController::GetStatusCounters(
const StatusCountersCallback& callback) {
NOTIMPLEMENTED();
}
void BookmarkModelTypeController::RecordMemoryUsageHistogram() {
NOTIMPLEMENTED();
}
} // namespace sync_bookmarks
// Copyright 2017 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 COMPONENTS_SYNC_BOOKMARKS_BOOKMARK_MODEL_TYPE_CONTROLLER_H_
#define COMPONENTS_SYNC_BOOKMARKS_BOOKMARK_MODEL_TYPE_CONTROLLER_H_
#include "base/macros.h"
#include "components/sync/driver/data_type_controller.h"
namespace sync_bookmarks {
// A class that manages the startup and shutdown of bookmark sync implemented
// through USS APIs.
class BookmarkModelTypeController : public syncer::DataTypeController {
public:
BookmarkModelTypeController();
// syncer::DataTypeController implementation.
bool ShouldLoadModelBeforeConfigure() const override;
void BeforeLoadModels(syncer::ModelTypeConfigurer* configurer) override;
void LoadModels(const ModelLoadCallback& model_load_callback) override;
void RegisterWithBackend(base::Callback<void(bool)> set_downloaded,
syncer::ModelTypeConfigurer* configurer) override;
void StartAssociating(const StartCallback& start_callback) override;
void ActivateDataType(syncer::ModelTypeConfigurer* configurer) override;
void DeactivateDataType(syncer::ModelTypeConfigurer* configurer) override;
void Stop() override;
State state() const override;
void GetAllNodes(const AllNodesCallback& callback) override;
void GetStatusCounters(const StatusCountersCallback& callback) override;
void RecordMemoryUsageHistogram() override;
private:
DISALLOW_COPY_AND_ASSIGN(BookmarkModelTypeController);
};
} // namespace sync_bookmarks
#endif // COMPONENTS_SYNC_BOOKMARKS_BOOKMARK_MODEL_TYPE_CONTROLLER_H_
// Copyright 2017 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 "components/sync_bookmarks/bookmark_model_type_processor.h"
#include "components/sync/base/model_type.h"
#include "components/sync/engine/commit_queue.h"
namespace sync_bookmarks {
BookmarkModelTypeProcessor::BookmarkModelTypeProcessor() = default;
BookmarkModelTypeProcessor::~BookmarkModelTypeProcessor() = default;
void BookmarkModelTypeProcessor::ConnectSync(
std::unique_ptr<syncer::CommitQueue> worker) {
NOTIMPLEMENTED();
}
void BookmarkModelTypeProcessor::DisconnectSync() {
NOTIMPLEMENTED();
}
void BookmarkModelTypeProcessor::GetLocalChanges(
size_t max_entries,
const GetLocalChangesCallback& callback) {
NOTIMPLEMENTED();
}
void BookmarkModelTypeProcessor::OnCommitCompleted(
const sync_pb::ModelTypeState& type_state,
const syncer::CommitResponseDataList& response_list) {
NOTIMPLEMENTED();
}
void BookmarkModelTypeProcessor::OnUpdateReceived(
const sync_pb::ModelTypeState& model_type_state,
const syncer::UpdateResponseDataList& updates) {
NOTIMPLEMENTED();
}
} // namespace sync_bookmarks
// Copyright 2017 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 COMPONENTS_SYNC_BOOKMARKS_BOOKMARK_MODEL_TYPE_PROCESSOR_H_
#define COMPONENTS_SYNC_BOOKMARKS_BOOKMARK_MODEL_TYPE_PROCESSOR_H_
#include <memory>
#include "base/macros.h"
#include "components/sync/engine/model_type_processor.h"
namespace sync_bookmarks {
class BookmarkModelTypeProcessor : public syncer::ModelTypeProcessor {
public:
BookmarkModelTypeProcessor();
~BookmarkModelTypeProcessor() override;
// ModelTypeProcessor implementation.
void ConnectSync(std::unique_ptr<syncer::CommitQueue> worker) override;
void DisconnectSync() override;
void GetLocalChanges(size_t max_entries,
const GetLocalChangesCallback& callback) override;
void OnCommitCompleted(
const sync_pb::ModelTypeState& type_state,
const syncer::CommitResponseDataList& response_list) override;
void OnUpdateReceived(const sync_pb::ModelTypeState& type_state,
const syncer::UpdateResponseDataList& updates) override;
private:
DISALLOW_COPY_AND_ASSIGN(BookmarkModelTypeProcessor);
};
} // namespace sync_bookmarks
#endif // COMPONENTS_SYNC_BOOKMARKS_BOOKMARK_MODEL_TYPE_PROCESSOR_H_
// Copyright 2017 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 "components/sync_bookmarks/bookmark_model_type_processor.h"
#include "testing/gtest/include/gtest/gtest.h"
namespace sync_bookmarks {
namespace {
class BookmarkModelTypeProcessorTest : public testing::Test {};
TEST_F(BookmarkModelTypeProcessorTest, CreateInstance) {
BookmarkModelTypeProcessor processor;
}
} // namespace
} // namespace sync_bookmarks
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment