Chromium Code Reviews| 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 51% |
| copy from chrome/browser/sync/glue/frontend_data_type_controller.h |
| copy to chrome/browser/sync/glue/ui_data_type_controller.h |
| index cafb939374c7ba7f32ec58fed3e7b9953d94499f..bdc5a9f07c3b5683e5d0b80af5a13fae34fbec9f 100644 |
| --- a/chrome/browser/sync/glue/frontend_data_type_controller.h |
| +++ b/chrome/browser/sync/glue/ui_data_type_controller.h |
| @@ -1,9 +1,9 @@ |
| -// Copyright (c) 2011 The Chromium Authors. All rights reserved. |
| +// 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_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,6 +11,8 @@ |
| #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/api/syncable_service.h" |
|
akalin
2012/02/24 23:54:02
can you get away with forward-declaring SyncableSe
Nicolas Zea
2012/03/01 20:50:26
Done.
|
| #include "chrome/browser/sync/glue/data_type_controller.h" |
| class Profile; |
| @@ -21,25 +23,18 @@ 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. |
| +// 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. |
| // Derived classes must implement (at least): |
| // syncable::ModelType type() const |
| -// void CreateSyncComponents(); |
| -class FrontendDataTypeController : public DataTypeController { |
| +// Note: RefCountedThreadSafe by way of DataTypeController. |
| +class UIDataTypeController : public DataTypeController { |
| public: |
| - FrontendDataTypeController( |
| + UIDataTypeController( |
| ProfileSyncComponentsFactory* profile_sync_factory, |
| Profile* profile, |
| ProfileSyncService* sync_service); |
| - virtual ~FrontendDataTypeController(); |
| // DataTypeController interface. |
| virtual void Start(const StartCallback& start_callback) OVERRIDE; |
| @@ -54,36 +49,31 @@ class FrontendDataTypeController : public DataTypeController { |
| const std::string& message) OVERRIDE; |
| protected: |
| + // DataTypeController is RefCounted. |
| + virtual ~UIDataTypeController(); |
| // For testing only. |
| - FrontendDataTypeController(); |
| + 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, |
| @@ -93,11 +83,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_; |
| @@ -105,14 +90,14 @@ 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); |
| + // 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__ |