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 #include "sync/engine/directory_update_handler.h" | 5 #include "sync/engine/directory_update_handler.h" |
6 | 6 |
7 #include "sync/engine/conflict_resolver.h" | 7 #include "sync/engine/conflict_resolver.h" |
8 #include "sync/engine/process_updates_util.h" | 8 #include "sync/engine/process_updates_util.h" |
9 #include "sync/engine/update_applicator.h" | 9 #include "sync/engine/update_applicator.h" |
10 #include "sync/sessions/directory_type_debug_info_emitter.h" | 10 #include "sync/sessions/directory_type_debug_info_emitter.h" |
11 #include "sync/syncable/directory.h" | 11 #include "sync/syncable/directory.h" |
12 #include "sync/syncable/model_neutral_mutable_entry.h" | 12 #include "sync/syncable/model_neutral_mutable_entry.h" |
13 #include "sync/syncable/syncable_model_neutral_write_transaction.h" | 13 #include "sync/syncable/syncable_model_neutral_write_transaction.h" |
14 #include "sync/syncable/syncable_write_transaction.h" | 14 #include "sync/syncable/syncable_write_transaction.h" |
| 15 #include "sync/util/data_type_histogram.h" |
15 | 16 |
16 namespace syncer { | 17 namespace syncer { |
17 | 18 |
18 using syncable::SYNCER; | 19 using syncable::SYNCER; |
19 | 20 |
20 DirectoryUpdateHandler::DirectoryUpdateHandler( | 21 DirectoryUpdateHandler::DirectoryUpdateHandler( |
21 syncable::Directory* dir, | 22 syncable::Directory* dir, |
22 ModelType type, | 23 ModelType type, |
23 scoped_refptr<ModelSafeWorker> worker, | 24 scoped_refptr<ModelSafeWorker> worker, |
24 DirectoryTypeDebugInfoEmitter* debug_info_emitter) | 25 DirectoryTypeDebugInfoEmitter* debug_info_emitter) |
(...skipping 14 matching lines...) Expand all Loading... |
39 syncable::ModelNeutralWriteTransaction trans(FROM_HERE, SYNCER, dir_); | 40 syncable::ModelNeutralWriteTransaction trans(FROM_HERE, SYNCER, dir_); |
40 dir_->GetDataTypeContext(&trans, type_, context); | 41 dir_->GetDataTypeContext(&trans, type_, context); |
41 } | 42 } |
42 | 43 |
43 SyncerError DirectoryUpdateHandler::ProcessGetUpdatesResponse( | 44 SyncerError DirectoryUpdateHandler::ProcessGetUpdatesResponse( |
44 const sync_pb::DataTypeProgressMarker& progress_marker, | 45 const sync_pb::DataTypeProgressMarker& progress_marker, |
45 const sync_pb::DataTypeContext& mutated_context, | 46 const sync_pb::DataTypeContext& mutated_context, |
46 const SyncEntityList& applicable_updates, | 47 const SyncEntityList& applicable_updates, |
47 sessions::StatusController* status) { | 48 sessions::StatusController* status) { |
48 syncable::ModelNeutralWriteTransaction trans(FROM_HERE, SYNCER, dir_); | 49 syncable::ModelNeutralWriteTransaction trans(FROM_HERE, SYNCER, dir_); |
| 50 if (progress_marker.ByteSize() > 0) { |
| 51 SyncRecordDatatypeBin("DataUse.Sync.ProgressMarker.Bytes", |
| 52 ModelTypeToHistogramInt(type_), |
| 53 progress_marker.ByteSize()); |
| 54 } |
49 if (mutated_context.has_context()) { | 55 if (mutated_context.has_context()) { |
50 sync_pb::DataTypeContext local_context; | 56 sync_pb::DataTypeContext local_context; |
51 dir_->GetDataTypeContext(&trans, type_, &local_context); | 57 dir_->GetDataTypeContext(&trans, type_, &local_context); |
52 | 58 |
53 // Only update the local context if it is still relevant. If the local | 59 // Only update the local context if it is still relevant. If the local |
54 // version is higher, it means a local change happened while the mutation | 60 // version is higher, it means a local change happened while the mutation |
55 // was in flight, and the local context takes priority. | 61 // was in flight, and the local context takes priority. |
56 if (mutated_context.version() >= local_context.version() && | 62 if (mutated_context.version() >= local_context.version() && |
57 local_context.context() != mutated_context.context()) { | 63 local_context.context() != mutated_context.context()) { |
58 dir_->SetDataTypeContext(&trans, type_, mutated_context); | 64 dir_->SetDataTypeContext(&trans, type_, mutated_context); |
(...skipping 223 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
282 new_gc_directive.version_watermark())) { | 288 new_gc_directive.version_watermark())) { |
283 ExpireEntriesByVersion(dir_, trans, type_, | 289 ExpireEntriesByVersion(dir_, trans, type_, |
284 new_gc_directive.version_watermark()); | 290 new_gc_directive.version_watermark()); |
285 } | 291 } |
286 | 292 |
287 cached_gc_directive_.reset( | 293 cached_gc_directive_.reset( |
288 new sync_pb::GarbageCollectionDirective(new_gc_directive)); | 294 new sync_pb::GarbageCollectionDirective(new_gc_directive)); |
289 } | 295 } |
290 | 296 |
291 } // namespace syncer | 297 } // namespace syncer |
OLD | NEW |