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/trace_event/trace_event.h" | 7 #include "base/trace_event/trace_event.h" |
8 #include "sync/engine/commit_contribution.h" | 8 #include "sync/engine/commit_contribution.h" |
9 #include "sync/engine/commit_processor.h" | 9 #include "sync/engine/commit_processor.h" |
10 #include "sync/engine/commit_util.h" | 10 #include "sync/engine/commit_util.h" |
11 #include "sync/engine/syncer.h" | 11 #include "sync/engine/syncer.h" |
12 #include "sync/engine/syncer_proto_util.h" | 12 #include "sync/engine/syncer_proto_util.h" |
13 #include "sync/internal_api/public/events/commit_request_event.h" | 13 #include "sync/internal_api/public/events/commit_request_event.h" |
14 #include "sync/internal_api/public/events/commit_response_event.h" | 14 #include "sync/internal_api/public/events/commit_response_event.h" |
15 #include "sync/sessions/sync_session.h" | 15 #include "sync/sessions/sync_session.h" |
16 #include "sync/util/data_type_histogram.h" | |
16 | 17 |
17 namespace syncer { | 18 namespace syncer { |
18 | 19 |
19 Commit::Commit(ContributionMap contributions, | 20 Commit::Commit(ContributionMap contributions, |
20 const sync_pb::ClientToServerMessage& message, | 21 const sync_pb::ClientToServerMessage& message, |
21 ExtensionsActivity::Records extensions_activity_buffer) | 22 ExtensionsActivity::Records extensions_activity_buffer) |
22 : contributions_(contributions.Pass()), | 23 : contributions_(contributions.Pass()), |
23 message_(message), | 24 message_(message), |
24 extensions_activity_buffer_(extensions_activity_buffer), | 25 extensions_activity_buffer_(extensions_activity_buffer), |
25 cleaned_up_(false) { | 26 cleaned_up_(false) { |
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
63 extensions_activity, | 64 extensions_activity, |
64 &extensions_activity_buffer, | 65 &extensions_activity_buffer, |
65 commit_message); | 66 commit_message); |
66 } | 67 } |
67 | 68 |
68 // Set the client config params. | 69 // Set the client config params. |
69 commit_util::AddClientConfigParamsToMessage( | 70 commit_util::AddClientConfigParamsToMessage( |
70 enabled_types, | 71 enabled_types, |
71 commit_message); | 72 commit_message); |
72 | 73 |
74 int previous_message_size = message.ByteSize(); | |
73 // Finally, serialize all our contributions. | 75 // Finally, serialize all our contributions. |
74 for (std::map<ModelType, CommitContribution*>::const_iterator it = | 76 for (std::map<ModelType, CommitContribution*>::const_iterator it = |
75 contributions.begin(); | 77 contributions.begin(); |
76 it != contributions.end(); ++it) { | 78 it != contributions.end(); ++it) { |
Alexei Svitkine (slow)
2015/08/24 21:27:00
Nit: Switch to C++11 for loop
amohammadkhan
2015/08/24 22:52:40
Done.
| |
77 it->second->AddToCommitMessage(&message); | 79 it->second->AddToCommitMessage(&message); |
80 int current_entry_size = message.ByteSize() - previous_message_size; | |
81 previous_message_size = message.ByteSize(); | |
82 if (current_entry_size > 0) { | |
83 SyncRecordDatatypeBin("DataUse.Sync.Upload.Bytes", | |
84 ModelTypeToHistogramInt(it->first), | |
85 current_entry_size); | |
86 } | |
87 UMA_HISTOGRAM_SPARSE_SLOWLY("DataUse.Sync.Upload.Count", | |
88 ModelTypeToHistogramInt(it->first)); | |
Alexei Svitkine (slow)
2015/08/24 21:27:00
Nit: Since you use ModelTypeToHistogramInt() twice
amohammadkhan
2015/08/24 22:52:40
Done.
| |
78 } | 89 } |
79 | 90 |
80 // If we made it this far, then we've successfully prepared a commit message. | 91 // If we made it this far, then we've successfully prepared a commit message. |
81 return new Commit(contributions.Pass(), message, extensions_activity_buffer); | 92 return new Commit(contributions.Pass(), message, extensions_activity_buffer); |
82 } | 93 } |
83 | 94 |
84 SyncerError Commit::PostAndProcessResponse( | 95 SyncerError Commit::PostAndProcessResponse( |
85 sessions::NudgeTracker* nudge_tracker, | 96 sessions::NudgeTracker* nudge_tracker, |
86 sessions::SyncSession* session, | 97 sessions::SyncSession* session, |
87 sessions::StatusController* status, | 98 sessions::StatusController* status, |
(...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
172 | 183 |
173 void Commit::CleanUp() { | 184 void Commit::CleanUp() { |
174 for (ContributionMap::const_iterator it = contributions_.begin(); | 185 for (ContributionMap::const_iterator it = contributions_.begin(); |
175 it != contributions_.end(); ++it) { | 186 it != contributions_.end(); ++it) { |
176 it->second->CleanUp(); | 187 it->second->CleanUp(); |
177 } | 188 } |
178 cleaned_up_ = true; | 189 cleaned_up_ = true; |
179 } | 190 } |
180 | 191 |
181 } // namespace syncer | 192 } // namespace syncer |
OLD | NEW |