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 new_message_part_size = message.ByteSize()-previous_message_size; | |
bengr
2015/08/07 17:13:37
I have no idea what new_message_part_size means. U
amohammadkhan
2015/08/07 18:52:30
Done.
| |
88 if (new_message_part_size > 0) | |
bengr
2015/08/07 17:13:37
Add curly braces.
amohammadkhan
2015/08/07 18:52:30
Done.
| |
89 UMA_HISTOGRAM_SPARSE_SLOWLY_WITH_VALUE("DataUse.Sync.Upload.Bytes", | |
90 it->first, | |
91 new_message_part_size); | |
92 UMA_HISTOGRAM_SPARSE_SLOWLY_WITH_VALUE("DataUse.Sync.Upload.Bytes", | |
93 it->first, 1); | |
78 } | 94 } |
79 | 95 |
80 // If we made it this far, then we've successfully prepared a commit message. | 96 // If we made it this far, then we've successfully prepared a commit message. |
81 return new Commit(contributions.Pass(), message, extensions_activity_buffer); | 97 return new Commit(contributions.Pass(), message, extensions_activity_buffer); |
82 } | 98 } |
83 | 99 |
84 SyncerError Commit::PostAndProcessResponse( | 100 SyncerError Commit::PostAndProcessResponse( |
85 sessions::NudgeTracker* nudge_tracker, | 101 sessions::NudgeTracker* nudge_tracker, |
86 sessions::SyncSession* session, | 102 sessions::SyncSession* session, |
87 sessions::StatusController* status, | 103 sessions::StatusController* status, |
(...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
172 | 188 |
173 void Commit::CleanUp() { | 189 void Commit::CleanUp() { |
174 for (ContributionMap::const_iterator it = contributions_.begin(); | 190 for (ContributionMap::const_iterator it = contributions_.begin(); |
175 it != contributions_.end(); ++it) { | 191 it != contributions_.end(); ++it) { |
176 it->second->CleanUp(); | 192 it->second->CleanUp(); |
177 } | 193 } |
178 cleaned_up_ = true; | 194 cleaned_up_ = true; |
179 } | 195 } |
180 | 196 |
181 } // namespace syncer | 197 } // namespace syncer |
OLD | NEW |