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_WORKER_IMPL_H_ | 5 #ifndef SYNC_ENGINE_MODEL_TYPE_SYNC_WORKER_IMPL_H_ |
6 #define SYNC_ENGINE_MODEL_TYPE_SYNC_WORKER_IMPL_H_ | 6 #define SYNC_ENGINE_MODEL_TYPE_SYNC_WORKER_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/engine/commit_contributor.h" | 13 #include "sync/engine/commit_contributor.h" |
13 #include "sync/engine/model_type_sync_worker.h" | 14 #include "sync/engine/model_type_sync_worker.h" |
14 #include "sync/engine/nudge_handler.h" | 15 #include "sync/engine/nudge_handler.h" |
15 #include "sync/engine/update_handler.h" | 16 #include "sync/engine/update_handler.h" |
16 #include "sync/internal_api/public/base/model_type.h" | 17 #include "sync/internal_api/public/base/model_type.h" |
17 #include "sync/internal_api/public/non_blocking_sync_common.h" | 18 #include "sync/internal_api/public/non_blocking_sync_common.h" |
18 #include "sync/internal_api/public/sync_encryption_handler.h" | 19 #include "sync/internal_api/public/sync_encryption_handler.h" |
19 #include "sync/protocol/sync.pb.h" | 20 #include "sync/protocol/sync.pb.h" |
(...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
83 | 84 |
84 // CommitContributor implementation. | 85 // CommitContributor implementation. |
85 scoped_ptr<CommitContribution> GetContribution(size_t max_entries) override; | 86 scoped_ptr<CommitContribution> GetContribution(size_t max_entries) override; |
86 | 87 |
87 // Callback for when our contribution gets a response. | 88 // Callback for when our contribution gets a response. |
88 void OnCommitResponse(const CommitResponseDataList& response_list); | 89 void OnCommitResponse(const CommitResponseDataList& response_list); |
89 | 90 |
90 base::WeakPtr<ModelTypeSyncWorkerImpl> AsWeakPtr(); | 91 base::WeakPtr<ModelTypeSyncWorkerImpl> AsWeakPtr(); |
91 | 92 |
92 private: | 93 private: |
93 typedef std::map<std::string, EntityTracker*> EntityMap; | 94 typedef base::ScopedPtrMap<std::string, scoped_ptr<EntityTracker>> EntityMap; |
94 typedef std::map<std::string, UpdateResponseData*> UpdateMap; | |
95 | 95 |
96 // Stores a single commit request in this object's internal state. | 96 // Stores a single commit request in this object's internal state. |
97 void StorePendingCommit(const CommitRequestData& request); | 97 void StorePendingCommit(const CommitRequestData& request); |
98 | 98 |
99 // Returns true if this type has successfully fetched all available updates | 99 // Returns true if this type has successfully fetched all available updates |
100 // from the server at least once. Our state may or may not be stale, but at | 100 // from the server at least once. Our state may or may not be stale, but at |
101 // least we know that it was valid at some point in the past. | 101 // least we know that it was valid at some point in the past. |
102 bool IsTypeInitialized() const; | 102 bool IsTypeInitialized() const; |
103 | 103 |
104 // Returns true if this type is prepared to commit items. Currently, this | 104 // Returns true if this type is prepared to commit items. Currently, this |
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
153 // When commits are pending, their information is stored here. This | 153 // When commits are pending, their information is stored here. This |
154 // information is dropped from memory when the commit succeeds or gets | 154 // information is dropped from memory when the commit succeeds or gets |
155 // cancelled. | 155 // cancelled. |
156 // | 156 // |
157 // This also stores some information related to received server state in | 157 // This also stores some information related to received server state in |
158 // order to implement reflection blocking and conflict detection. This | 158 // order to implement reflection blocking and conflict detection. This |
159 // information is kept in memory indefinitely. With a bit more coordination | 159 // information is kept in memory indefinitely. With a bit more coordination |
160 // with the model thread, we could optimize this to reduce memory usage in | 160 // with the model thread, we could optimize this to reduce memory usage in |
161 // the steady state. | 161 // the steady state. |
162 EntityMap entities_; | 162 EntityMap entities_; |
163 STLValueDeleter<EntityMap> entities_deleter_; | |
164 | 163 |
165 base::WeakPtrFactory<ModelTypeSyncWorkerImpl> weak_ptr_factory_; | 164 base::WeakPtrFactory<ModelTypeSyncWorkerImpl> weak_ptr_factory_; |
166 }; | 165 }; |
167 | 166 |
168 } // namespace syncer | 167 } // namespace syncer |
169 | 168 |
170 #endif // SYNC_ENGINE_MODEL_TYPE_SYNC_WORKER_IMPL_H_ | 169 #endif // SYNC_ENGINE_MODEL_TYPE_SYNC_WORKER_IMPL_H_ |
OLD | NEW |