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

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

Powered by Google App Engine
This is Rietveld 408576698