Index: components/sync_driver/non_blocking_data_type_controller.h |
diff --git a/components/sync_driver/non_blocking_data_type_controller.h b/components/sync_driver/non_blocking_data_type_controller.h |
index e8240a2aedb3234a681a7c519a26fc08025256c6..d7369ac4a3a39c6b3275f96466e2e863c64ee17c 100644 |
--- a/components/sync_driver/non_blocking_data_type_controller.h |
+++ b/components/sync_driver/non_blocking_data_type_controller.h |
@@ -24,6 +24,7 @@ namespace sync_driver_v2 { |
// Base class for DataType controllers for Unified Sync and Storage datatypes. |
// Derived types must implement the following methods: |
// - RunOnModelThread |
+// - RunOnUIThread |
class NonBlockingDataTypeController : public sync_driver::DataTypeController { |
public: |
NonBlockingDataTypeController( |
@@ -63,19 +64,29 @@ class NonBlockingDataTypeController : public sync_driver::DataTypeController { |
// The weak pointer should be used only on the model thread. |
base::WeakPtr<syncer_v2::SharedModelTypeProcessor> type_processor() const; |
+ // Returns true if the call is made on UI thread. |
+ bool BelongsToUIThread() const; |
+ |
// Posts the given task to the model thread, i.e. the thread the |
// datatype lives on. Return value: True if task posted successfully, |
// false otherwise. |
virtual bool RunOnModelThread(const tracked_objects::Location& from_here, |
const base::Closure& task) = 0; |
- // Returns true if the call is made on UI thread. |
- bool BelongsToUIThread() const; |
- |
// Post the given task on the UI thread. If the call is made on UI thread |
// already, make a direct call without posting. |
- void RunOnUIThread(const tracked_objects::Location& from_here, |
- const base::Closure& task); |
+ virtual void RunOnUIThread(const tracked_objects::Location& from_here, |
+ const base::Closure& task) = 0; |
+ |
+ // The function will create SharedModelTypeProcessor on model thread. |
+ void InitializeProcessor(); |
+ |
+ private: |
+ void RecordStartFailure(ConfigureResult result) const; |
+ void RecordUnrecoverableError(); |
+ void ReportLoadModelError(ConfigureResult result, |
+ const syncer::SyncError& error); |
+ void InitializeProcessorOnModelThread(); |
// If the DataType controller is waiting for models to load, once the models |
// are loaded this function should be called to let the base class |
@@ -83,21 +94,17 @@ class NonBlockingDataTypeController : public sync_driver::DataTypeController { |
// The error indicates whether the loading completed successfully. |
void LoadModelsDone(ConfigureResult result, const syncer::SyncError& error); |
- // A weak pointer to the actual SharedModelTypeProcessor |
- base::WeakPtr<syncer_v2::SharedModelTypeProcessor> type_processor_; |
- |
- private: |
// Callback passed to the processor to be invoked when the processor has |
// started. This is called on the model thread. |
void OnProcessorStarted( |
syncer::SyncError error, |
scoped_ptr<syncer_v2::ActivationContext> activation_context); |
- void RecordStartFailure(ConfigureResult result) const; |
- void RecordUnrecoverableError(); |
- void ReportLoadModelError(ConfigureResult result, |
- const syncer::SyncError& error); |
- void InitializeProcessor(); |
+ // The function will do the real work when OnProcessorStarted got called. This |
+ // is called on the UI thread. |
+ void OnProcessorStartedOnUIThread( |
+ syncer::SyncError error, |
+ scoped_ptr<syncer_v2::ActivationContext> activation_context); |
// Model Type for this controller |
syncer::ModelType model_type_; |
@@ -115,6 +122,9 @@ class NonBlockingDataTypeController : public sync_driver::DataTypeController { |
// callback and must temporarily own it until ActivateDataType is called. |
scoped_ptr<syncer_v2::ActivationContext> activation_context_; |
+ // A weak pointer to the actual SharedModelTypeProcessor |
+ base::WeakPtr<syncer_v2::SharedModelTypeProcessor> type_processor_; |
+ |
DISALLOW_COPY_AND_ASSIGN(NonBlockingDataTypeController); |
}; |