Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(16)

Side by Side Diff: components/sync/engine_impl/directory_update_handler.cc

Issue 2258873003: [Sync] Move sessions/ to engine/cycle/ and rename things to match. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Address comments. Created 4 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 #include "components/sync/engine_impl/directory_update_handler.h" 5 #include "components/sync/engine_impl/directory_update_handler.h"
6 6
7 #include <stdint.h> 7 #include <stdint.h>
8 8
9 #include <vector> 9 #include <vector>
10 10
11 #include "components/sync/base/data_type_histogram.h" 11 #include "components/sync/base/data_type_histogram.h"
12 #include "components/sync/engine_impl/conflict_resolver.h" 12 #include "components/sync/engine_impl/conflict_resolver.h"
13 #include "components/sync/engine_impl/cycle/directory_type_debug_info_emitter.h"
14 #include "components/sync/engine_impl/cycle/status_controller.h"
13 #include "components/sync/engine_impl/process_updates_util.h" 15 #include "components/sync/engine_impl/process_updates_util.h"
14 #include "components/sync/engine_impl/update_applicator.h" 16 #include "components/sync/engine_impl/update_applicator.h"
15 #include "components/sync/sessions_impl/directory_type_debug_info_emitter.h"
16 #include "components/sync/syncable/directory.h" 17 #include "components/sync/syncable/directory.h"
17 #include "components/sync/syncable/model_neutral_mutable_entry.h" 18 #include "components/sync/syncable/model_neutral_mutable_entry.h"
18 #include "components/sync/syncable/syncable_changes_version.h" 19 #include "components/sync/syncable/syncable_changes_version.h"
19 #include "components/sync/syncable/syncable_model_neutral_write_transaction.h" 20 #include "components/sync/syncable/syncable_model_neutral_write_transaction.h"
20 #include "components/sync/syncable/syncable_write_transaction.h" 21 #include "components/sync/syncable/syncable_write_transaction.h"
21 22
22 namespace syncer { 23 namespace syncer {
23 24
24 using syncable::SYNCER; 25 using syncable::SYNCER;
25 26
(...skipping 21 matching lines...) Expand all
47 void DirectoryUpdateHandler::GetDataTypeContext( 48 void DirectoryUpdateHandler::GetDataTypeContext(
48 sync_pb::DataTypeContext* context) const { 49 sync_pb::DataTypeContext* context) const {
49 syncable::ModelNeutralWriteTransaction trans(FROM_HERE, SYNCER, dir_); 50 syncable::ModelNeutralWriteTransaction trans(FROM_HERE, SYNCER, dir_);
50 dir_->GetDataTypeContext(&trans, type_, context); 51 dir_->GetDataTypeContext(&trans, type_, context);
51 } 52 }
52 53
53 SyncerError DirectoryUpdateHandler::ProcessGetUpdatesResponse( 54 SyncerError DirectoryUpdateHandler::ProcessGetUpdatesResponse(
54 const sync_pb::DataTypeProgressMarker& progress_marker, 55 const sync_pb::DataTypeProgressMarker& progress_marker,
55 const sync_pb::DataTypeContext& mutated_context, 56 const sync_pb::DataTypeContext& mutated_context,
56 const SyncEntityList& applicable_updates, 57 const SyncEntityList& applicable_updates,
57 sessions::StatusController* status) { 58 StatusController* status) {
58 syncable::ModelNeutralWriteTransaction trans(FROM_HERE, SYNCER, dir_); 59 syncable::ModelNeutralWriteTransaction trans(FROM_HERE, SYNCER, dir_);
59 if (progress_marker.ByteSize() > 0) { 60 if (progress_marker.ByteSize() > 0) {
60 SyncRecordDatatypeBin("DataUse.Sync.ProgressMarker.Bytes", 61 SyncRecordDatatypeBin("DataUse.Sync.ProgressMarker.Bytes",
61 ModelTypeToHistogramInt(type_), 62 ModelTypeToHistogramInt(type_),
62 progress_marker.ByteSize()); 63 progress_marker.ByteSize());
63 } 64 }
64 if (mutated_context.has_context()) { 65 if (mutated_context.has_context()) {
65 sync_pb::DataTypeContext local_context; 66 sync_pb::DataTypeContext local_context;
66 dir_->GetDataTypeContext(&trans, type_, &local_context); 67 dir_->GetDataTypeContext(&trans, type_, &local_context);
67 68
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after
110 // then the type gets re-enabled again. 111 // then the type gets re-enabled again.
111 DVLOG(1) << "Type root folder " << ModelTypeToRootTag(type_) 112 DVLOG(1) << "Type root folder " << ModelTypeToRootTag(type_)
112 << " already exists."; 113 << " already exists.";
113 return; 114 return;
114 } 115 }
115 116
116 entry.PutServerIsDir(true); 117 entry.PutServerIsDir(true);
117 entry.PutUniqueServerTag(ModelTypeToRootTag(type_)); 118 entry.PutUniqueServerTag(ModelTypeToRootTag(type_));
118 } 119 }
119 120
120 void DirectoryUpdateHandler::ApplyUpdates(sessions::StatusController* status) { 121 void DirectoryUpdateHandler::ApplyUpdates(StatusController* status) {
121 if (IsApplyUpdatesRequired()) { 122 if (IsApplyUpdatesRequired()) {
122 // This will invoke handlers that belong to the model and its thread, so we 123 // This will invoke handlers that belong to the model and its thread, so we
123 // switch to the appropriate thread before we start this work. 124 // switch to the appropriate thread before we start this work.
124 WorkCallback c = 125 WorkCallback c =
125 base::Bind(&DirectoryUpdateHandler::ApplyUpdatesImpl, 126 base::Bind(&DirectoryUpdateHandler::ApplyUpdatesImpl,
126 // We wait until the callback is executed. We can safely use 127 // We wait until the callback is executed. We can safely use
127 // Unretained. 128 // Unretained.
128 base::Unretained(this), base::Unretained(status)); 129 base::Unretained(this), base::Unretained(status));
129 worker_->DoWorkAndWaitUntilDone(c); 130 worker_->DoWorkAndWaitUntilDone(c);
130 131
131 debug_info_emitter_->EmitUpdateCountersUpdate(); 132 debug_info_emitter_->EmitUpdateCountersUpdate();
132 debug_info_emitter_->EmitStatusCountersUpdate(); 133 debug_info_emitter_->EmitStatusCountersUpdate();
133 } 134 }
134 135
135 PostApplyUpdates(); 136 PostApplyUpdates();
136 } 137 }
137 138
138 void DirectoryUpdateHandler::PassiveApplyUpdates( 139 void DirectoryUpdateHandler::PassiveApplyUpdates(StatusController* status) {
139 sessions::StatusController* status) {
140 if (IsApplyUpdatesRequired()) { 140 if (IsApplyUpdatesRequired()) {
141 // Just do the work here instead of deferring to another thread. 141 // Just do the work here instead of deferring to another thread.
142 ApplyUpdatesImpl(status); 142 ApplyUpdatesImpl(status);
143 143
144 debug_info_emitter_->EmitUpdateCountersUpdate(); 144 debug_info_emitter_->EmitUpdateCountersUpdate();
145 debug_info_emitter_->EmitStatusCountersUpdate(); 145 debug_info_emitter_->EmitStatusCountersUpdate();
146 } 146 }
147 147
148 PostApplyUpdates(); 148 PostApplyUpdates();
149 } 149 }
150 150
151 SyncerError DirectoryUpdateHandler::ApplyUpdatesImpl( 151 SyncerError DirectoryUpdateHandler::ApplyUpdatesImpl(StatusController* status) {
152 sessions::StatusController* status) {
153 syncable::WriteTransaction trans(FROM_HERE, syncable::SYNCER, dir_); 152 syncable::WriteTransaction trans(FROM_HERE, syncable::SYNCER, dir_);
154 153
155 std::vector<int64_t> handles; 154 std::vector<int64_t> handles;
156 dir_->GetUnappliedUpdateMetaHandles(&trans, FullModelTypeSet(type_), 155 dir_->GetUnappliedUpdateMetaHandles(&trans, FullModelTypeSet(type_),
157 &handles); 156 &handles);
158 157
159 // First set of update application passes. 158 // First set of update application passes.
160 UpdateApplicator applicator(dir_->GetCryptographer(&trans)); 159 UpdateApplicator applicator(dir_->GetCryptographer(&trans));
161 applicator.AttemptApplications(&trans, handles); 160 applicator.AttemptApplications(&trans, handles);
162 161
(...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after
239 if (IsControlType(type_)) { 238 if (IsControlType(type_)) {
240 return false; // We don't process control types here. 239 return false; // We don't process control types here.
241 } 240 }
242 241
243 return dir_->TypeHasUnappliedUpdates(type_); 242 return dir_->TypeHasUnappliedUpdates(type_);
244 } 243 }
245 244
246 void DirectoryUpdateHandler::UpdateSyncEntities( 245 void DirectoryUpdateHandler::UpdateSyncEntities(
247 syncable::ModelNeutralWriteTransaction* trans, 246 syncable::ModelNeutralWriteTransaction* trans,
248 const SyncEntityList& applicable_updates, 247 const SyncEntityList& applicable_updates,
249 sessions::StatusController* status) { 248 StatusController* status) {
250 UpdateCounters* counters = debug_info_emitter_->GetMutableUpdateCounters(); 249 UpdateCounters* counters = debug_info_emitter_->GetMutableUpdateCounters();
251 counters->num_updates_received += applicable_updates.size(); 250 counters->num_updates_received += applicable_updates.size();
252 ProcessDownloadedUpdates(dir_, trans, type_, applicable_updates, status, 251 ProcessDownloadedUpdates(dir_, trans, type_, applicable_updates, status,
253 counters); 252 counters);
254 } 253 }
255 254
256 bool DirectoryUpdateHandler::IsValidProgressMarker( 255 bool DirectoryUpdateHandler::IsValidProgressMarker(
257 const sync_pb::DataTypeProgressMarker& progress_marker) const { 256 const sync_pb::DataTypeProgressMarker& progress_marker) const {
258 if (progress_marker.token().empty()) { 257 if (progress_marker.token().empty()) {
259 return false; 258 return false;
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after
304 new_gc_directive.version_watermark())) { 303 new_gc_directive.version_watermark())) {
305 ExpireEntriesByVersion(dir_, trans, type_, 304 ExpireEntriesByVersion(dir_, trans, type_,
306 new_gc_directive.version_watermark()); 305 new_gc_directive.version_watermark());
307 } 306 }
308 307
309 cached_gc_directive_.reset( 308 cached_gc_directive_.reset(
310 new sync_pb::GarbageCollectionDirective(new_gc_directive)); 309 new sync_pb::GarbageCollectionDirective(new_gc_directive));
311 } 310 }
312 311
313 } // namespace syncer 312 } // namespace syncer
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698