| Index: chrome/browser/sync/glue/ui_data_type_controller.h
|
| diff --git a/chrome/browser/sync/glue/frontend_data_type_controller.h b/chrome/browser/sync/glue/ui_data_type_controller.h
|
| similarity index 50%
|
| copy from chrome/browser/sync/glue/frontend_data_type_controller.h
|
| copy to chrome/browser/sync/glue/ui_data_type_controller.h
|
| index 03d7b9a4337b24c748a18810ffc1e489e26d0a4d..cb60cfe8e209a46b0fcbc709287f775c7693bfaf 100644
|
| --- a/chrome/browser/sync/glue/frontend_data_type_controller.h
|
| +++ b/chrome/browser/sync/glue/ui_data_type_controller.h
|
| @@ -2,8 +2,8 @@
|
| // 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_FRONTEND_DATA_TYPE_CONTROLLER_H__
|
| -#define CHROME_BROWSER_SYNC_GLUE_FRONTEND_DATA_TYPE_CONTROLLER_H__
|
| +#ifndef CHROME_BROWSER_SYNC_GLUE_UI_DATA_TYPE_CONTROLLER_H__
|
| +#define CHROME_BROWSER_SYNC_GLUE_UI_DATA_TYPE_CONTROLLER_H__
|
| #pragma once
|
|
|
| #include <string>
|
| @@ -11,46 +11,39 @@
|
| #include "base/basictypes.h"
|
| #include "base/compiler_specific.h"
|
| #include "base/memory/scoped_ptr.h"
|
| +#include "base/memory/weak_ptr.h"
|
| #include "chrome/browser/sync/glue/data_type_controller.h"
|
| -#include "chrome/browser/sync/glue/data_type_error_handler.h"
|
|
|
| class Profile;
|
| class ProfileSyncService;
|
| class ProfileSyncComponentsFactory;
|
| +class SyncableService;
|
| class SyncError;
|
|
|
| namespace base { class TimeDelta; }
|
| namespace browser_sync {
|
|
|
| -class AssociatorInterface;
|
| -class ChangeProcessor;
|
| -
|
| -// TODO(zea): have naming and style match NonFrontendDataTypeController.
|
| -// TODO(zea): Rename frontend to UI (http://crbug.com/78833).
|
| -// Implementation for datatypes that reside on the frontend thread
|
| -// (UI thread). This is the same thread we perform initialization on, so we
|
| -// don't have to worry about thread safety. The main start/stop funtionality is
|
| -// implemented by default.
|
| -// Derived classes must implement (at least):
|
| -// syncable::ModelType type() const
|
| -// void CreateSyncComponents();
|
| -class FrontendDataTypeController : public DataTypeController {
|
| +// Implementation for datatypes that reside on the (UI thread). This is the same
|
| +// thread we perform initialization on, so we don't have to worry about thread
|
| +// safety. The main start/stop funtionality is implemented by default.
|
| +// Note: RefCountedThreadSafe by way of DataTypeController.
|
| +class UIDataTypeController : public DataTypeController {
|
| public:
|
| - FrontendDataTypeController(
|
| + UIDataTypeController(
|
| + syncable::ModelType type,
|
| ProfileSyncComponentsFactory* profile_sync_factory,
|
| Profile* profile,
|
| ProfileSyncService* sync_service);
|
| - virtual ~FrontendDataTypeController();
|
|
|
| // DataTypeController interface.
|
| virtual void Start(const StartCallback& start_callback) OVERRIDE;
|
| virtual void Stop() OVERRIDE;
|
| - virtual syncable::ModelType type() const = 0;
|
| + virtual syncable::ModelType type() const OVERRIDE;
|
| virtual browser_sync::ModelSafeGroup model_safe_group() const OVERRIDE;
|
| virtual std::string name() const OVERRIDE;
|
| virtual State state() const OVERRIDE;
|
|
|
| - // DataTypeErrorHandler interface.
|
| + // UnrecoverableErrorHandler interface.
|
| virtual void OnUnrecoverableError(const tracked_objects::Location& from_here,
|
| const std::string& message) OVERRIDE;
|
| virtual void OnSingleDatatypeUnrecoverableError(
|
| @@ -59,35 +52,30 @@ class FrontendDataTypeController : public DataTypeController {
|
|
|
| protected:
|
| // For testing only.
|
| - FrontendDataTypeController();
|
| + UIDataTypeController();
|
| + // DataTypeController is RefCounted.
|
| + virtual ~UIDataTypeController();
|
|
|
| - // Kick off any dependent services that need to be running before we can
|
| + // Start any dependent services that need to be running before we can
|
| // associate models. The default implementation is a no-op.
|
| // Return value:
|
| // True - if models are ready and association can proceed.
|
| // False - if models are not ready. Associate() should be called when the
|
| - // models are ready. Refer to Start(_) implementation.
|
| + // models are ready.
|
| virtual bool StartModels();
|
|
|
| - // Build sync components and associate models.
|
| - // Return value:
|
| - // True - if association was successful. FinishStart should have been
|
| - // invoked.
|
| - // False - if association failed. StartFailed should have been invoked.
|
| - virtual bool Associate();
|
| -
|
| - // Datatype specific creation of sync components.
|
| - virtual void CreateSyncComponents() = 0;
|
| + // Associate the sync model with the service's model, then start syncing.
|
| + virtual void Associate();
|
|
|
| // Perform any DataType controller specific state cleanup before stopping
|
| // the datatype controller. The default implementation is a no-op.
|
| - virtual void CleanUpState();
|
| + virtual void StopModels();
|
|
|
| - // Helper methods for cleaning up state an running the start callback.
|
| + // Helper methods for cleaning up state and invoking the start callback.
|
| virtual void StartFailed(StartResult result, const SyncError& error);
|
| - virtual void FinishStart(StartResult result);
|
| + virtual void StartDone(StartResult result);
|
|
|
| - // DataType specific histogram methods.
|
| + // Datatype specific histogram methods.
|
| // Record unrecoverable errors.
|
| virtual void RecordUnrecoverableError(
|
| const tracked_objects::Location& from_here,
|
| @@ -97,11 +85,6 @@ class FrontendDataTypeController : public DataTypeController {
|
| // Record causes of start failure.
|
| virtual void RecordStartFailure(StartResult result);
|
|
|
| - virtual AssociatorInterface* model_associator() const;
|
| - virtual void set_model_associator(AssociatorInterface* associator);
|
| - virtual ChangeProcessor* change_processor() const;
|
| - virtual void set_change_processor(ChangeProcessor* processor);
|
| -
|
| ProfileSyncComponentsFactory* const profile_sync_factory_;
|
| Profile* const profile_;
|
| ProfileSyncService* const sync_service_;
|
| @@ -109,14 +92,17 @@ class FrontendDataTypeController : public DataTypeController {
|
| State state_;
|
|
|
| StartCallback start_callback_;
|
| - // TODO(sync): transition all datatypes to SyncableService and deprecate
|
| - // AssociatorInterface.
|
| - scoped_ptr<AssociatorInterface> model_associator_;
|
| - scoped_ptr<ChangeProcessor> change_processor_;
|
|
|
| - DISALLOW_COPY_AND_ASSIGN(FrontendDataTypeController);
|
| + // The sync datatype being controlled.
|
| + syncable::ModelType type_;
|
| +
|
| + // A weak pointer to the actual local syncable service, which performs all the
|
| + // real work. We do not own the object.
|
| + base::WeakPtr<SyncableService> local_service_;
|
| +
|
| + DISALLOW_COPY_AND_ASSIGN(UIDataTypeController);
|
| };
|
|
|
| } // namespace browser_sync
|
|
|
| -#endif // CHROME_BROWSER_SYNC_GLUE_FRONTEND_DATA_TYPE_CONTROLLER_H__
|
| +#endif // CHROME_BROWSER_SYNC_GLUE_UI_DATA_TYPE_CONTROLLER_H__
|
|
|