OLD | NEW |
---|---|
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" |
16 | 17 |
18 #define UMA_HISTOGRAM_SPARSE_SLOWLY_WITH_VALUE(name, sample, value) \ | |
19 do { \ | |
20 base::HistogramBase* histogram = base::SparseHistogram::FactoryGet( \ | |
21 name, base::HistogramBase::kUmaTargetedHistogramFlag); \ | |
22 histogram->AddCount(sample, value); \ | |
23 } while (0) | |
24 | |
17 namespace syncer { | 25 namespace syncer { |
18 | 26 |
19 Commit::Commit(ContributionMap contributions, | 27 Commit::Commit(ContributionMap contributions, |
20 const sync_pb::ClientToServerMessage& message, | 28 const sync_pb::ClientToServerMessage& message, |
21 ExtensionsActivity::Records extensions_activity_buffer) | 29 ExtensionsActivity::Records extensions_activity_buffer) |
22 : contributions_(contributions.Pass()), | 30 : contributions_(contributions.Pass()), |
23 message_(message), | 31 message_(message), |
24 extensions_activity_buffer_(extensions_activity_buffer), | 32 extensions_activity_buffer_(extensions_activity_buffer), |
25 cleaned_up_(false) { | 33 cleaned_up_(false) { |
26 } | 34 } |
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
63 extensions_activity, | 71 extensions_activity, |
64 &extensions_activity_buffer, | 72 &extensions_activity_buffer, |
65 commit_message); | 73 commit_message); |
66 } | 74 } |
67 | 75 |
68 // Set the client config params. | 76 // Set the client config params. |
69 commit_util::AddClientConfigParamsToMessage( | 77 commit_util::AddClientConfigParamsToMessage( |
70 enabled_types, | 78 enabled_types, |
71 commit_message); | 79 commit_message); |
72 | 80 |
81 int previous_message_size = message.ByteSize(); | |
73 // Finally, serialize all our contributions. | 82 // Finally, serialize all our contributions. |
74 for (std::map<ModelType, CommitContribution*>::const_iterator it = | 83 for (std::map<ModelType, CommitContribution*>::const_iterator it = |
75 contributions.begin(); | 84 contributions.begin(); |
76 it != contributions.end(); ++it) { | 85 it != contributions.end(); ++it) { |
77 it->second->AddToCommitMessage(&message); | 86 it->second->AddToCommitMessage(&message); |
87 int current_entry_size = message.ByteSize() - previous_message_size; | |
88 previous_message_size = message.ByteSize(); | |
89 if (current_entry_size > 0) { | |
90 UMA_HISTOGRAM_SPARSE_SLOWLY_WITH_VALUE("DataUse.Sync.Upload.Bytes", | |
91 ModelTypeToHistogramInt(it->first), | |
92 current_entry_size); | |
93 } | |
94 UMA_HISTOGRAM_SPARSE_SLOWLY("DataUse.Sync.Upload.Count", | |
95 ModelTypeToHistogramInt(it->first)); | |
96 //NOTREACHED(); | |
sclittle
2015/08/14 19:10:59
Can you remove this?
amohammadkhan
2015/08/17 17:56:16
Done.
| |
78 } | 97 } |
79 | 98 |
80 // If we made it this far, then we've successfully prepared a commit message. | 99 // If we made it this far, then we've successfully prepared a commit message. |
81 return new Commit(contributions.Pass(), message, extensions_activity_buffer); | 100 return new Commit(contributions.Pass(), message, extensions_activity_buffer); |
82 } | 101 } |
83 | 102 |
84 SyncerError Commit::PostAndProcessResponse( | 103 SyncerError Commit::PostAndProcessResponse( |
85 sessions::NudgeTracker* nudge_tracker, | 104 sessions::NudgeTracker* nudge_tracker, |
86 sessions::SyncSession* session, | 105 sessions::SyncSession* session, |
87 sessions::StatusController* status, | 106 sessions::StatusController* status, |
(...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
172 | 191 |
173 void Commit::CleanUp() { | 192 void Commit::CleanUp() { |
174 for (ContributionMap::const_iterator it = contributions_.begin(); | 193 for (ContributionMap::const_iterator it = contributions_.begin(); |
175 it != contributions_.end(); ++it) { | 194 it != contributions_.end(); ++it) { |
176 it->second->CleanUp(); | 195 it->second->CleanUp(); |
177 } | 196 } |
178 cleaned_up_ = true; | 197 cleaned_up_ = true; |
179 } | 198 } |
180 | 199 |
181 } // namespace syncer | 200 } // namespace syncer |
OLD | NEW |