Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1396)

Unified Diff: sync/engine/model_type_processor_impl.h

Issue 1382743004: [Sync] Move ModelTypeProcessor* and rename *Impl to Shared*. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: also the test Created 5 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: sync/engine/model_type_processor_impl.h
diff --git a/sync/engine/model_type_processor_impl.h b/sync/engine/model_type_processor_impl.h
deleted file mode 100644
index 04a31419c9e13c96c257ee76a70ce58fbc615633..0000000000000000000000000000000000000000
--- a/sync/engine/model_type_processor_impl.h
+++ /dev/null
@@ -1,162 +0,0 @@
-// Copyright 2014 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 SYNC_ENGINE_MODEL_TYPE_SYNC_PROXY_IMPL_H_
-#define SYNC_ENGINE_MODEL_TYPE_SYNC_PROXY_IMPL_H_
-
-#include "base/containers/scoped_ptr_map.h"
-#include "base/memory/scoped_ptr.h"
-#include "base/memory/weak_ptr.h"
-#include "base/threading/non_thread_safe.h"
-#include "sync/base/sync_export.h"
-#include "sync/engine/model_type_processor.h"
-#include "sync/internal_api/public/base/model_type.h"
-#include "sync/internal_api/public/non_blocking_sync_common.h"
-#include "sync/protocol/sync.pb.h"
-
-namespace syncer_v2 {
-class CommitQueue;
-class ModelTypeEntity;
-class ModelTypeStore;
-class SyncContextProxy;
-
-// A sync component embedded on the synced type's thread that helps to handle
-// communication between sync and model type threads.
-class SYNC_EXPORT_PRIVATE ModelTypeProcessorImpl : public ModelTypeProcessor,
- base::NonThreadSafe {
- public:
- ModelTypeProcessorImpl(syncer::ModelType type,
- base::WeakPtr<ModelTypeStore> store);
- ~ModelTypeProcessorImpl() override;
-
- // Returns true if this object believes that sync is preferred for this type.
- //
- // By "preferred", we mean that a policy decision has been made that this
- // type should be synced. Most of the time this is controlled by a user
- // clicking a checkbox on the settings page.
- //
- // The canonical preferred state is based on SyncPrefs on the UI thread. At
- // best, this value is stale and may lag behind the one set on the UI thread.
- // Before this type has registered with the UI thread, it's mostly just an
- // informed guess.
- bool IsPreferred() const;
-
- // Returns true if the handshake with sync thread is complete.
- bool IsConnected() const;
-
- // Returns the model type handled by this type sync proxy.
- syncer::ModelType GetModelType() const;
-
- // Starts the handshake with the sync thread.
- void Enable(scoped_ptr<SyncContextProxy> context_proxy);
-
- // Severs all ties to the sync thread and may delete local sync state.
- // Another call to Enable() can be used to re-establish this connection.
- void Disable();
-
- // Severs all ties to the sync thread.
- // Another call to Enable() can be used to re-establish this connection.
- void Disconnect();
-
- // Callback used to process the handshake response.
- void OnConnect(scoped_ptr<CommitQueue> worker) override;
-
- // Requests that an item be stored in sync.
- void Put(const std::string& client_tag,
- const sync_pb::EntitySpecifics& specifics);
-
- // Deletes an item from sync.
- void Delete(const std::string& client_tag);
-
- // Informs this object that some of its commit requests have been
- // successfully serviced.
- void OnCommitCompleted(const DataTypeState& type_state,
- const CommitResponseDataList& response_list) override;
-
- // Informs this object that there are some incoming updates is should
- // handle.
- void OnUpdateReceived(const DataTypeState& type_state,
- const UpdateResponseDataList& response_list,
- const UpdateResponseDataList& pending_updates) override;
-
- // Returns the list of pending updates.
- //
- // This is used as a helper function, but it's public mainly for testing.
- // The current test harness setup doesn't allow us to test the data that the
- // proxy sends to the worker during initialization, so we use this to inspect
- // its state instead.
- UpdateResponseDataList GetPendingUpdates();
-
- // Returns the long-lived WeakPtr that is intended to be registered with the
- // ProfileSyncService.
- base::WeakPtr<ModelTypeProcessorImpl> AsWeakPtrForUI();
-
- private:
- typedef base::ScopedPtrMap<std::string, scoped_ptr<ModelTypeEntity>>
- EntityMap;
- typedef base::ScopedPtrMap<std::string, scoped_ptr<UpdateResponseData>>
- UpdateMap;
-
- // Sends all commit requests that are due to be sent to the sync thread.
- void FlushPendingCommitRequests();
-
- // Clears any state related to outstanding communications with the
- // CommitQueue. Used when we want to disconnect from
- // the current worker.
- void ClearTransientSyncState();
-
- // Clears any state related to our communications with the current sync
- // account. Useful when a user signs out of the current account.
- void ClearSyncState();
-
- syncer::ModelType type_;
- DataTypeState data_type_state_;
-
- // Whether or not sync is preferred for this type. This is a cached copy of
- // the canonical copy information on the UI thread.
- bool is_preferred_;
-
- // Whether or not this object has completed its initial handshake with the
- // SyncContextProxy.
- bool is_connected_;
-
- // Our link to data type management on the sync thread.
- // Used for enabling and disabling sync for this type.
- //
- // Beware of NULL pointers: This object is uninitialized when we are not
- // connected to sync.
- scoped_ptr<SyncContextProxy> sync_context_proxy_;
-
- // Reference to the CommitQueue.
- //
- // The interface hides the posting of tasks across threads as well as the
- // CommitQueue's implementation. Both of these features are
- // useful in tests.
- scoped_ptr<CommitQueue> worker_;
-
- // The set of sync entities known to this object.
- EntityMap entities_;
-
- // A set of updates that can not be applied at this time. These are never
- // used by the model. They are kept here only so we can save and restore
- // them across restarts, and keep them in sync with our progress markers.
- UpdateMap pending_updates_map_;
-
- // Store is supplied by model type implementation. ModelTypeProcessorImpl
- // uses store for persisting sync related data (entity state and data type
- // state).
- base::WeakPtr<ModelTypeStore> store_;
-
- // We use two different WeakPtrFactories because we want the pointers they
- // issue to have different lifetimes. When asked to disconnect from the sync
- // thread, we want to make sure that no tasks generated as part of the
- // now-obsolete connection to affect us. But we also want the WeakPtr we
- // sent to the UI thread to remain valid.
- base::WeakPtrFactory<ModelTypeProcessorImpl> weak_ptr_factory_for_ui_;
- base::WeakPtrFactory<ModelTypeProcessorImpl> weak_ptr_factory_for_sync_;
-};
-
-} // namespace syncer
-
-#endif // SYNC_ENGINE_MODEL_TYPE_SYNC_PROXY_IMPL_H_

Powered by Google App Engine
This is Rietveld 408576698