| OLD | NEW |
| (Empty) |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | |
| 2 // Use of this source code is governed by a BSD-style license that can be | |
| 3 // found in the LICENSE file. | |
| 4 | |
| 5 #ifndef SYNC_INTERNAL_API_MODEL_TYPE_CONNECTOR_PROXY_H_ | |
| 6 #define SYNC_INTERNAL_API_MODEL_TYPE_CONNECTOR_PROXY_H_ | |
| 7 | |
| 8 #include <memory> | |
| 9 | |
| 10 #include "base/memory/weak_ptr.h" | |
| 11 #include "base/sequenced_task_runner.h" | |
| 12 #include "sync/base/sync_export.h" | |
| 13 #include "sync/internal_api/public/base/model_type.h" | |
| 14 #include "sync/internal_api/public/model_type_connector.h" | |
| 15 | |
| 16 namespace syncer_v2 { | |
| 17 | |
| 18 // Proxies all ModelTypeConnector calls to another thread. Typically used by | |
| 19 // the SyncBackend to call from the UI thread to the real ModelTypeConnector on | |
| 20 // the sync thread. | |
| 21 class SYNC_EXPORT ModelTypeConnectorProxy : public ModelTypeConnector { | |
| 22 public: | |
| 23 ModelTypeConnectorProxy( | |
| 24 const scoped_refptr<base::SequencedTaskRunner>& task_runner, | |
| 25 const base::WeakPtr<ModelTypeConnector>& model_type_connector); | |
| 26 ~ModelTypeConnectorProxy() override; | |
| 27 | |
| 28 // ModelTypeConnector implementation | |
| 29 void ConnectType( | |
| 30 syncer::ModelType type, | |
| 31 std::unique_ptr<ActivationContext> activation_context) override; | |
| 32 void DisconnectType(syncer::ModelType type) override; | |
| 33 | |
| 34 private: | |
| 35 // A SequencedTaskRunner representing the thread where the ModelTypeConnector | |
| 36 // lives. | |
| 37 scoped_refptr<base::SequencedTaskRunner> task_runner_; | |
| 38 | |
| 39 // The ModelTypeConnector this object is wrapping. | |
| 40 base::WeakPtr<ModelTypeConnector> model_type_connector_; | |
| 41 }; | |
| 42 | |
| 43 } // namespace syncer_v2 | |
| 44 | |
| 45 #endif // SYNC_INTERNAL_API_MODEL_TYPE_CONNECTOR_PROXY_H_ | |
| OLD | NEW |