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

Side by Side Diff: sync/engine/directory_update_handler.cc

Issue 1273303002: Measuring data use of different ModelTypes in Sync Service. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@NewServices
Patch Set: Removing extra spaces Created 5 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 "sync/engine/directory_update_handler.h" 5 #include "sync/engine/directory_update_handler.h"
6 6
7 #include "base/metrics/sparse_histogram.h"
7 #include "sync/engine/conflict_resolver.h" 8 #include "sync/engine/conflict_resolver.h"
8 #include "sync/engine/process_updates_util.h" 9 #include "sync/engine/process_updates_util.h"
9 #include "sync/engine/update_applicator.h" 10 #include "sync/engine/update_applicator.h"
10 #include "sync/sessions/directory_type_debug_info_emitter.h" 11 #include "sync/sessions/directory_type_debug_info_emitter.h"
11 #include "sync/syncable/directory.h" 12 #include "sync/syncable/directory.h"
12 #include "sync/syncable/model_neutral_mutable_entry.h" 13 #include "sync/syncable/model_neutral_mutable_entry.h"
13 #include "sync/syncable/syncable_model_neutral_write_transaction.h" 14 #include "sync/syncable/syncable_model_neutral_write_transaction.h"
14 #include "sync/syncable/syncable_write_transaction.h" 15 #include "sync/syncable/syncable_write_transaction.h"
15 16
17 #define UMA_HISTOGRAM_SPARSE_SLOWLY_WITH_VALUE(name, sample, value) \
18 do { \
19 base::HistogramBase* histogram = base::SparseHistogram::FactoryGet( \
20 name, base::HistogramBase::kUmaTargetedHistogramFlag); \
21 histogram->AddCount(sample, value); \
22 } while (0)
23
16 namespace syncer { 24 namespace syncer {
17 25
18 using syncable::SYNCER; 26 using syncable::SYNCER;
19 27
20 DirectoryUpdateHandler::DirectoryUpdateHandler( 28 DirectoryUpdateHandler::DirectoryUpdateHandler(
21 syncable::Directory* dir, 29 syncable::Directory* dir,
22 ModelType type, 30 ModelType type,
23 scoped_refptr<ModelSafeWorker> worker, 31 scoped_refptr<ModelSafeWorker> worker,
24 DirectoryTypeDebugInfoEmitter* debug_info_emitter) 32 DirectoryTypeDebugInfoEmitter* debug_info_emitter)
25 : dir_(dir), 33 : dir_(dir),
(...skipping 13 matching lines...) Expand all
39 syncable::ModelNeutralWriteTransaction trans(FROM_HERE, SYNCER, dir_); 47 syncable::ModelNeutralWriteTransaction trans(FROM_HERE, SYNCER, dir_);
40 dir_->GetDataTypeContext(&trans, type_, context); 48 dir_->GetDataTypeContext(&trans, type_, context);
41 } 49 }
42 50
43 SyncerError DirectoryUpdateHandler::ProcessGetUpdatesResponse( 51 SyncerError DirectoryUpdateHandler::ProcessGetUpdatesResponse(
44 const sync_pb::DataTypeProgressMarker& progress_marker, 52 const sync_pb::DataTypeProgressMarker& progress_marker,
45 const sync_pb::DataTypeContext& mutated_context, 53 const sync_pb::DataTypeContext& mutated_context,
46 const SyncEntityList& applicable_updates, 54 const SyncEntityList& applicable_updates,
47 sessions::StatusController* status) { 55 sessions::StatusController* status) {
48 syncable::ModelNeutralWriteTransaction trans(FROM_HERE, SYNCER, dir_); 56 syncable::ModelNeutralWriteTransaction trans(FROM_HERE, SYNCER, dir_);
57 if (progress_marker.ByteSize() > 0) {
58 UMA_HISTOGRAM_SPARSE_SLOWLY_WITH_VALUE("DataUse.Sync.ProgressMarker.Bytes",
59 ModelTypeToHistogramInt(type_),
60 progress_marker.ByteSize());
61 }
49 if (mutated_context.has_context()) { 62 if (mutated_context.has_context()) {
50 sync_pb::DataTypeContext local_context; 63 sync_pb::DataTypeContext local_context;
51 dir_->GetDataTypeContext(&trans, type_, &local_context); 64 dir_->GetDataTypeContext(&trans, type_, &local_context);
52 65
53 // Only update the local context if it is still relevant. If the local 66 // 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 67 // version is higher, it means a local change happened while the mutation
55 // was in flight, and the local context takes priority. 68 // was in flight, and the local context takes priority.
56 if (mutated_context.version() >= local_context.version() && 69 if (mutated_context.version() >= local_context.version() &&
57 local_context.context() != mutated_context.context()) { 70 local_context.context() != mutated_context.context()) {
58 dir_->SetDataTypeContext(&trans, type_, mutated_context); 71 dir_->SetDataTypeContext(&trans, type_, mutated_context);
(...skipping 223 matching lines...) Expand 10 before | Expand all | Expand 10 after
282 new_gc_directive.version_watermark())) { 295 new_gc_directive.version_watermark())) {
283 ExpireEntriesByVersion(dir_, trans, type_, 296 ExpireEntriesByVersion(dir_, trans, type_,
284 new_gc_directive.version_watermark()); 297 new_gc_directive.version_watermark());
285 } 298 }
286 299
287 cached_gc_directive_.reset( 300 cached_gc_directive_.reset(
288 new sync_pb::GarbageCollectionDirective(new_gc_directive)); 301 new sync_pb::GarbageCollectionDirective(new_gc_directive));
289 } 302 }
290 303
291 } // namespace syncer 304 } // namespace syncer
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698