| OLD | NEW |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 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 | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #ifndef SYNC_INTERNAL_API_PUBLIC_SYNC_CONTEXT_H_ | 5 #ifndef SYNC_INTERNAL_API_PUBLIC_SYNC_CONTEXT_H_ |
| 6 #define SYNC_INTERNAL_API_PUBLIC_SYNC_CONTEXT_H_ | 6 #define SYNC_INTERNAL_API_PUBLIC_SYNC_CONTEXT_H_ |
| 7 | 7 |
| 8 #include "base/memory/scoped_ptr.h" | 8 #include <memory> |
| 9 |
| 9 #include "sync/internal_api/public/base/model_type.h" | 10 #include "sync/internal_api/public/base/model_type.h" |
| 10 | 11 |
| 11 namespace syncer_v2 { | 12 namespace syncer_v2 { |
| 12 struct ActivationContext; | 13 struct ActivationContext; |
| 13 | 14 |
| 14 // An interface of the core parts of sync. | 15 // An interface of the core parts of sync. |
| 15 // | 16 // |
| 16 // In theory, this is the component that provides off-thread sync types with | 17 // In theory, this is the component that provides off-thread sync types with |
| 17 // functionality to schedule and execute communication with the sync server. In | 18 // functionality to schedule and execute communication with the sync server. In |
| 18 // practice, this class delegates most of the responsibilty of implemeting this | 19 // practice, this class delegates most of the responsibilty of implemeting this |
| 19 // functionality to other classes, and most of the interface is exposed not | 20 // functionality to other classes, and most of the interface is exposed not |
| 20 // directly here but instead through a per-ModelType class that this class helps | 21 // directly here but instead through a per-ModelType class that this class helps |
| 21 // instantiate. | 22 // instantiate. |
| 22 class SYNC_EXPORT SyncContext { | 23 class SYNC_EXPORT SyncContext { |
| 23 public: | 24 public: |
| 24 SyncContext(); | 25 SyncContext(); |
| 25 virtual ~SyncContext(); | 26 virtual ~SyncContext(); |
| 26 | 27 |
| 27 // Initializes the connection between the sync context on the sync thread and | 28 // Initializes the connection between the sync context on the sync thread and |
| 28 // a proxy for the specified non-blocking sync type that lives on the data | 29 // a proxy for the specified non-blocking sync type that lives on the data |
| 29 // type's thread. | 30 // type's thread. |
| 30 virtual void ConnectSyncTypeToWorker( | 31 virtual void ConnectSyncTypeToWorker( |
| 31 syncer::ModelType type, | 32 syncer::ModelType type, |
| 32 scoped_ptr<ActivationContext> activation_context) = 0; | 33 std::unique_ptr<ActivationContext> activation_context) = 0; |
| 33 | 34 |
| 34 // Disconnects the syncer from the model and stops syncing the type. | 35 // Disconnects the syncer from the model and stops syncing the type. |
| 35 // | 36 // |
| 36 // By the time this is called, the model thread should have already | 37 // By the time this is called, the model thread should have already |
| 37 // invalidated the WeakPtr it sent to us in the connect request. Any | 38 // invalidated the WeakPtr it sent to us in the connect request. Any |
| 38 // messages sent to that ModelTypeProcessor will not be recived. | 39 // messages sent to that ModelTypeProcessor will not be recived. |
| 39 // | 40 // |
| 40 // This is the sync thread's chance to clear state associated with the type. | 41 // This is the sync thread's chance to clear state associated with the type. |
| 41 // It also causes the syncer to stop requesting updates for this type, and to | 42 // It also causes the syncer to stop requesting updates for this type, and to |
| 42 // abort any in-progress commit requests. | 43 // abort any in-progress commit requests. |
| 43 virtual void DisconnectSyncWorker(syncer::ModelType type) = 0; | 44 virtual void DisconnectSyncWorker(syncer::ModelType type) = 0; |
| 44 }; | 45 }; |
| 45 | 46 |
| 46 } // namespace syncer_v2 | 47 } // namespace syncer_v2 |
| 47 | 48 |
| 48 #endif // SYNC_INTERNAL_API_PUBLIC_SYNC_CONTEXT_H_ | 49 #endif // SYNC_INTERNAL_API_PUBLIC_SYNC_CONTEXT_H_ |
| OLD | NEW |