diff options
author | stanisc <stanisc@chromium.org> | 2015-09-28 12:28:42 -0700 |
---|---|---|
committer | Commit bot <commit-bot@chromium.org> | 2015-09-28 19:30:57 +0000 |
commit | a4e4a10e92844d0274895c1d078d9119fa76f041 (patch) | |
tree | b91de6790c80c7c1587e54860fc47052d2bb15e9 /sync/engine | |
parent | 516bee16e9437521cdd20a78d683f9dbaf35df3e (diff) | |
download | chromium_src-a4e4a10e92844d0274895c1d078d9119fa76f041.zip chromium_src-a4e4a10e92844d0274895c1d078d9119fa76f041.tar.gz chromium_src-a4e4a10e92844d0274895c1d078d9119fa76f041.tar.bz2 |
USS SyncContextProxy / data type activation refactoring
This refactoring prepares the code to introduction of
NonBlockingDataTypeController for USS datatypes. The goal
was to split the very large NonBlockingDataTypeController
change into a couple of smaller to make it easier to review
and verify.
The following changes are included here:
1) Introduced ActivationContext which is a structure that
contains all arguments needed to activate a USS datatype.
For now ActivationContext is passed via SyncContext /
SyncContextProxy, but the goal is to pass it directly
via BackendDataTypeConfigurer as an argument for
ActivateNonBlockingDataType.
ActivationContext is needed as a separate class because
NonBlockingDataTypeController will have to receive it
from the type processor's callback and temporarily hold
on to it.
2) BackendDataTypeConfigurer - two activation methods are
renamed to be directory specific and two more activation
methods for non-blocking data types are added.
3) DataTypeController cleanup - OnModelLoaded() virtual
method shouldn't be on the base class because it applies
only to some of the subclasses and is never invoked via the
base class.
BUG=515962
Review URL: https://codereview.chromium.org/1368683003
Cr-Commit-Position: refs/heads/master@{#351110}
Diffstat (limited to 'sync/engine')
-rw-r--r-- | sync/engine/model_type_processor_impl.cc | 17 | ||||
-rw-r--r-- | sync/engine/model_type_processor_impl_unittest.cc | 3 |
2 files changed, 14 insertions, 6 deletions
diff --git a/sync/engine/model_type_processor_impl.cc b/sync/engine/model_type_processor_impl.cc index 55aa73b..94e5c63 100644 --- a/sync/engine/model_type_processor_impl.cc +++ b/sync/engine/model_type_processor_impl.cc @@ -6,8 +6,10 @@ #include "base/bind.h" #include "base/location.h" +#include "base/thread_task_runner_handle.h" #include "sync/engine/commit_queue.h" #include "sync/engine/model_type_entity.h" +#include "sync/internal_api/public/activation_context.h" #include "sync/internal_api/public/sync_context_proxy.h" #include "sync/syncable/syncable_util.h" @@ -52,13 +54,16 @@ void ModelTypeProcessorImpl::Enable( data_type_state_.progress_marker.set_data_type_id( GetSpecificsFieldNumberFromModelType(type_)); - UpdateResponseDataList saved_pending_updates = GetPendingUpdates(); + scoped_ptr<ActivationContext> activation_context = + make_scoped_ptr(new ActivationContext); + activation_context->data_type_state = data_type_state_; + activation_context->saved_pending_updates = GetPendingUpdates(); + activation_context->type_task_runner = base::ThreadTaskRunnerHandle::Get(); + activation_context->type_processor = weak_ptr_factory_for_sync_.GetWeakPtr(); + sync_context_proxy_ = sync_context_proxy.Pass(); - sync_context_proxy_->ConnectTypeToSync( - GetModelType(), - data_type_state_, - saved_pending_updates, - weak_ptr_factory_for_sync_.GetWeakPtr()); + sync_context_proxy_->ConnectTypeToSync(GetModelType(), + activation_context.Pass()); } void ModelTypeProcessorImpl::Disable() { diff --git a/sync/engine/model_type_processor_impl_unittest.cc b/sync/engine/model_type_processor_impl_unittest.cc index 8f57d69..5e0bc68 100644 --- a/sync/engine/model_type_processor_impl_unittest.cc +++ b/sync/engine/model_type_processor_impl_unittest.cc @@ -4,6 +4,7 @@ #include "sync/engine/model_type_processor_impl.h" +#include "base/message_loop/message_loop.h" #include "sync/engine/commit_queue.h" #include "sync/internal_api/public/base/model_type.h" #include "sync/internal_api/public/non_blocking_sync_common.h" @@ -129,6 +130,8 @@ class ModelTypeProcessorImplTest : public ::testing::Test { scoped_ptr<ModelTypeProcessorImpl> type_processor_; DataTypeState data_type_state_; + // This sets ThreadTaskRunnerHandle on the current thread. + base::MessageLoop message_loop_; }; ModelTypeProcessorImplTest::ModelTypeProcessorImplTest() |