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

Side by Side Diff: sync/engine/commit.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: Changing the initialization of vectors in syncer_unittest.cc Created 5 years, 3 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
« no previous file with comments | « sync/BUILD.gn ('k') | sync/engine/directory_update_handler.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2012 The Chromium Authors. All rights reserved. 1 // Copyright 2012 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/commit.h" 5 #include "sync/engine/commit.h"
6 6
7 #include "base/metrics/sparse_histogram.h"
7 #include "base/trace_event/trace_event.h" 8 #include "base/trace_event/trace_event.h"
8 #include "sync/engine/commit_contribution.h" 9 #include "sync/engine/commit_contribution.h"
9 #include "sync/engine/commit_processor.h" 10 #include "sync/engine/commit_processor.h"
10 #include "sync/engine/commit_util.h" 11 #include "sync/engine/commit_util.h"
11 #include "sync/engine/syncer.h" 12 #include "sync/engine/syncer.h"
12 #include "sync/engine/syncer_proto_util.h" 13 #include "sync/engine/syncer_proto_util.h"
13 #include "sync/internal_api/public/events/commit_request_event.h" 14 #include "sync/internal_api/public/events/commit_request_event.h"
14 #include "sync/internal_api/public/events/commit_response_event.h" 15 #include "sync/internal_api/public/events/commit_response_event.h"
15 #include "sync/sessions/sync_session.h" 16 #include "sync/sessions/sync_session.h"
17 #include "sync/util/data_type_histogram.h"
16 18
17 namespace syncer { 19 namespace syncer {
18 20
19 Commit::Commit(ContributionMap contributions, 21 Commit::Commit(ContributionMap contributions,
20 const sync_pb::ClientToServerMessage& message, 22 const sync_pb::ClientToServerMessage& message,
21 ExtensionsActivity::Records extensions_activity_buffer) 23 ExtensionsActivity::Records extensions_activity_buffer)
22 : contributions_(contributions.Pass()), 24 : contributions_(contributions.Pass()),
23 message_(message), 25 message_(message),
24 extensions_activity_buffer_(extensions_activity_buffer), 26 extensions_activity_buffer_(extensions_activity_buffer),
25 cleaned_up_(false) { 27 cleaned_up_(false) {
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after
63 extensions_activity, 65 extensions_activity,
64 &extensions_activity_buffer, 66 &extensions_activity_buffer,
65 commit_message); 67 commit_message);
66 } 68 }
67 69
68 // Set the client config params. 70 // Set the client config params.
69 commit_util::AddClientConfigParamsToMessage( 71 commit_util::AddClientConfigParamsToMessage(
70 enabled_types, 72 enabled_types,
71 commit_message); 73 commit_message);
72 74
75 int previous_message_size = message.ByteSize();
73 // Finally, serialize all our contributions. 76 // Finally, serialize all our contributions.
74 for (std::map<ModelType, CommitContribution*>::const_iterator it = 77 for (const auto& contribution : contributions) {
75 contributions.begin(); 78 contribution.second->AddToCommitMessage(&message);
76 it != contributions.end(); ++it) { 79 int current_entry_size = message.ByteSize() - previous_message_size;
77 it->second->AddToCommitMessage(&message); 80 previous_message_size = message.ByteSize();
81 int local_integer_model_type = ModelTypeToHistogramInt(contribution.first);
82 if (current_entry_size > 0) {
83 SyncRecordDatatypeBin("DataUse.Sync.Upload.Bytes",
84 local_integer_model_type, current_entry_size);
85 }
86 UMA_HISTOGRAM_SPARSE_SLOWLY("DataUse.Sync.Upload.Count",
87 local_integer_model_type);
78 } 88 }
79 89
80 // If we made it this far, then we've successfully prepared a commit message. 90 // If we made it this far, then we've successfully prepared a commit message.
81 return new Commit(contributions.Pass(), message, extensions_activity_buffer); 91 return new Commit(contributions.Pass(), message, extensions_activity_buffer);
82 } 92 }
83 93
84 SyncerError Commit::PostAndProcessResponse( 94 SyncerError Commit::PostAndProcessResponse(
85 sessions::NudgeTracker* nudge_tracker, 95 sessions::NudgeTracker* nudge_tracker,
86 sessions::SyncSession* session, 96 sessions::SyncSession* session,
87 sessions::StatusController* status, 97 sessions::StatusController* status,
(...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after
172 182
173 void Commit::CleanUp() { 183 void Commit::CleanUp() {
174 for (ContributionMap::const_iterator it = contributions_.begin(); 184 for (ContributionMap::const_iterator it = contributions_.begin();
175 it != contributions_.end(); ++it) { 185 it != contributions_.end(); ++it) {
176 it->second->CleanUp(); 186 it->second->CleanUp();
177 } 187 }
178 cleaned_up_ = true; 188 cleaned_up_ = true;
179 } 189 }
180 190
181 } // namespace syncer 191 } // namespace syncer
OLDNEW
« no previous file with comments | « sync/BUILD.gn ('k') | sync/engine/directory_update_handler.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698