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 COMPONENTS_SYNC_CORE_IMPL_MODEL_TYPE_CONNECTOR_PROXY_H_ | |
6 #define COMPONENTS_SYNC_CORE_IMPL_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 "components/sync/base/model_type.h" | |
13 #include "components/sync/core/model_type_connector.h" | |
14 | |
15 namespace syncer { | |
16 | |
17 // Proxies all ModelTypeConnector calls to another thread. Typically used by | |
18 // the SyncBackend to call from the UI thread to the real ModelTypeConnector on | |
19 // the sync thread. | |
20 class ModelTypeConnectorProxy : public ModelTypeConnector { | |
21 public: | |
22 ModelTypeConnectorProxy( | |
23 const scoped_refptr<base::SequencedTaskRunner>& task_runner, | |
24 const base::WeakPtr<ModelTypeConnector>& model_type_connector); | |
25 ~ModelTypeConnectorProxy() override; | |
26 | |
27 // ModelTypeConnector implementation | |
28 void ConnectType( | |
29 ModelType type, | |
30 std::unique_ptr<ActivationContext> activation_context) override; | |
31 void DisconnectType(ModelType type) override; | |
32 | |
33 private: | |
34 // A SequencedTaskRunner representing the thread where the ModelTypeConnector | |
35 // lives. | |
36 scoped_refptr<base::SequencedTaskRunner> task_runner_; | |
37 | |
38 // The ModelTypeConnector this object is wrapping. | |
39 base::WeakPtr<ModelTypeConnector> model_type_connector_; | |
40 }; | |
41 | |
42 } // namespace syncer | |
43 | |
44 #endif // COMPONENTS_SYNC_CORE_IMPL_MODEL_TYPE_CONNECTOR_PROXY_H_ | |
OLD | NEW |