| 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_ENGINE_MODEL_TYPE_SYNC_PROXY_IMPL_H_ | 5 #ifndef SYNC_ENGINE_MODEL_TYPE_SYNC_PROXY_IMPL_H_ |
| 6 #define SYNC_ENGINE_MODEL_TYPE_SYNC_PROXY_IMPL_H_ | 6 #define SYNC_ENGINE_MODEL_TYPE_SYNC_PROXY_IMPL_H_ |
| 7 | 7 |
| 8 #include "base/containers/scoped_ptr_map.h" |
| 9 #include "base/memory/scoped_ptr.h" |
| 8 #include "base/memory/weak_ptr.h" | 10 #include "base/memory/weak_ptr.h" |
| 9 #include "base/stl_util.h" | |
| 10 #include "base/threading/non_thread_safe.h" | 11 #include "base/threading/non_thread_safe.h" |
| 11 #include "sync/base/sync_export.h" | 12 #include "sync/base/sync_export.h" |
| 12 #include "sync/internal_api/public/base/model_type.h" | 13 #include "sync/internal_api/public/base/model_type.h" |
| 13 #include "sync/internal_api/public/non_blocking_sync_common.h" | 14 #include "sync/internal_api/public/non_blocking_sync_common.h" |
| 14 #include "sync/protocol/sync.pb.h" | 15 #include "sync/protocol/sync.pb.h" |
| 15 | 16 |
| 16 namespace syncer { | 17 namespace syncer { |
| 17 | 18 |
| 18 class SyncContextProxy; | 19 class SyncContextProxy; |
| 19 class ModelTypeEntity; | 20 class ModelTypeEntity; |
| (...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 82 // The current test harness setup doesn't allow us to test the data that the | 83 // The current test harness setup doesn't allow us to test the data that the |
| 83 // proxy sends to the worker during initialization, so we use this to inspect | 84 // proxy sends to the worker during initialization, so we use this to inspect |
| 84 // its state instead. | 85 // its state instead. |
| 85 UpdateResponseDataList GetPendingUpdates(); | 86 UpdateResponseDataList GetPendingUpdates(); |
| 86 | 87 |
| 87 // Returns the long-lived WeakPtr that is intended to be registered with the | 88 // Returns the long-lived WeakPtr that is intended to be registered with the |
| 88 // ProfileSyncService. | 89 // ProfileSyncService. |
| 89 base::WeakPtr<ModelTypeSyncProxyImpl> AsWeakPtrForUI(); | 90 base::WeakPtr<ModelTypeSyncProxyImpl> AsWeakPtrForUI(); |
| 90 | 91 |
| 91 private: | 92 private: |
| 92 typedef std::map<std::string, ModelTypeEntity*> EntityMap; | 93 typedef base::ScopedPtrMap<std::string, scoped_ptr<ModelTypeEntity>> |
| 93 typedef std::map<std::string, UpdateResponseData*> UpdateMap; | 94 EntityMap; |
| 95 typedef base::ScopedPtrMap<std::string, scoped_ptr<UpdateResponseData>> |
| 96 UpdateMap; |
| 94 | 97 |
| 95 // Sends all commit requests that are due to be sent to the sync thread. | 98 // Sends all commit requests that are due to be sent to the sync thread. |
| 96 void FlushPendingCommitRequests(); | 99 void FlushPendingCommitRequests(); |
| 97 | 100 |
| 98 // Clears any state related to outstanding communications with the | 101 // Clears any state related to outstanding communications with the |
| 99 // ModelTypeSyncWorker. Used when we want to disconnect from | 102 // ModelTypeSyncWorker. Used when we want to disconnect from |
| 100 // the current worker. | 103 // the current worker. |
| 101 void ClearTransientSyncState(); | 104 void ClearTransientSyncState(); |
| 102 | 105 |
| 103 // Clears any state related to our communications with the current sync | 106 // Clears any state related to our communications with the current sync |
| (...skipping 20 matching lines...) Expand all Loading... |
| 124 | 127 |
| 125 // Reference to the ModelTypeSyncWorker. | 128 // Reference to the ModelTypeSyncWorker. |
| 126 // | 129 // |
| 127 // The interface hides the posting of tasks across threads as well as the | 130 // The interface hides the posting of tasks across threads as well as the |
| 128 // ModelTypeSyncWorker's implementation. Both of these features are | 131 // ModelTypeSyncWorker's implementation. Both of these features are |
| 129 // useful in tests. | 132 // useful in tests. |
| 130 scoped_ptr<ModelTypeSyncWorker> worker_; | 133 scoped_ptr<ModelTypeSyncWorker> worker_; |
| 131 | 134 |
| 132 // The set of sync entities known to this object. | 135 // The set of sync entities known to this object. |
| 133 EntityMap entities_; | 136 EntityMap entities_; |
| 134 STLValueDeleter<EntityMap> entities_deleter_; | |
| 135 | 137 |
| 136 // A set of updates that can not be applied at this time. These are never | 138 // A set of updates that can not be applied at this time. These are never |
| 137 // used by the model. They are kept here only so we can save and restore | 139 // used by the model. They are kept here only so we can save and restore |
| 138 // them across restarts, and keep them in sync with our progress markers. | 140 // them across restarts, and keep them in sync with our progress markers. |
| 139 UpdateMap pending_updates_map_; | 141 UpdateMap pending_updates_map_; |
| 140 STLValueDeleter<UpdateMap> pending_updates_map_deleter_; | |
| 141 | 142 |
| 142 // We use two different WeakPtrFactories because we want the pointers they | 143 // We use two different WeakPtrFactories because we want the pointers they |
| 143 // issue to have different lifetimes. When asked to disconnect from the sync | 144 // issue to have different lifetimes. When asked to disconnect from the sync |
| 144 // thread, we want to make sure that no tasks generated as part of the | 145 // thread, we want to make sure that no tasks generated as part of the |
| 145 // now-obsolete connection to affect us. But we also want the WeakPtr we | 146 // now-obsolete connection to affect us. But we also want the WeakPtr we |
| 146 // sent to the UI thread to remain valid. | 147 // sent to the UI thread to remain valid. |
| 147 base::WeakPtrFactory<ModelTypeSyncProxyImpl> weak_ptr_factory_for_ui_; | 148 base::WeakPtrFactory<ModelTypeSyncProxyImpl> weak_ptr_factory_for_ui_; |
| 148 base::WeakPtrFactory<ModelTypeSyncProxyImpl> weak_ptr_factory_for_sync_; | 149 base::WeakPtrFactory<ModelTypeSyncProxyImpl> weak_ptr_factory_for_sync_; |
| 149 }; | 150 }; |
| 150 | 151 |
| 151 } // namespace syncer | 152 } // namespace syncer |
| 152 | 153 |
| 153 #endif // SYNC_ENGINE_MODEL_TYPE_SYNC_PROXY_IMPL_H_ | 154 #endif // SYNC_ENGINE_MODEL_TYPE_SYNC_PROXY_IMPL_H_ |
| OLD | NEW |