| 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/metrics/sparse_histogram.h" |
| 8 #include "base/trace_event/trace_event.h" | 8 #include "base/trace_event/trace_event.h" |
| 9 #include "sync/engine/commit_contribution.h" | 9 #include "sync/engine/commit_contribution.h" |
| 10 #include "sync/engine/commit_processor.h" | 10 #include "sync/engine/commit_processor.h" |
| 11 #include "sync/engine/commit_util.h" | 11 #include "sync/engine/commit_util.h" |
| 12 #include "sync/engine/syncer.h" | 12 #include "sync/engine/syncer.h" |
| 13 #include "sync/engine/syncer_proto_util.h" | 13 #include "sync/engine/syncer_proto_util.h" |
| 14 #include "sync/internal_api/public/events/commit_request_event.h" | 14 #include "sync/internal_api/public/events/commit_request_event.h" |
| 15 #include "sync/internal_api/public/events/commit_response_event.h" | 15 #include "sync/internal_api/public/events/commit_response_event.h" |
| 16 #include "sync/sessions/sync_session.h" | 16 #include "sync/sessions/sync_session.h" |
| 17 #include "sync/util/data_type_histogram.h" | 17 #include "sync/util/data_type_histogram.h" |
| 18 | 18 |
| 19 namespace syncer { | 19 namespace syncer { |
| 20 | 20 |
| 21 Commit::Commit(ContributionMap contributions, | 21 Commit::Commit(ContributionMap contributions, |
| 22 const sync_pb::ClientToServerMessage& message, | 22 const sync_pb::ClientToServerMessage& message, |
| 23 ExtensionsActivity::Records extensions_activity_buffer) | 23 ExtensionsActivity::Records extensions_activity_buffer) |
| 24 : contributions_(contributions.Pass()), | 24 : contributions_(std::move(contributions)), |
| 25 message_(message), | 25 message_(message), |
| 26 extensions_activity_buffer_(extensions_activity_buffer), | 26 extensions_activity_buffer_(extensions_activity_buffer), |
| 27 cleaned_up_(false) { | 27 cleaned_up_(false) {} |
| 28 } | |
| 29 | 28 |
| 30 Commit::~Commit() { | 29 Commit::~Commit() { |
| 31 DCHECK(cleaned_up_); | 30 DCHECK(cleaned_up_); |
| 32 } | 31 } |
| 33 | 32 |
| 34 Commit* Commit::Init( | 33 Commit* Commit::Init( |
| 35 ModelTypeSet requested_types, | 34 ModelTypeSet requested_types, |
| 36 ModelTypeSet enabled_types, | 35 ModelTypeSet enabled_types, |
| 37 size_t max_entries, | 36 size_t max_entries, |
| 38 const std::string& account_name, | 37 const std::string& account_name, |
| (...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 81 int local_integer_model_type = ModelTypeToHistogramInt(contribution.first); | 80 int local_integer_model_type = ModelTypeToHistogramInt(contribution.first); |
| 82 if (current_entry_size > 0) { | 81 if (current_entry_size > 0) { |
| 83 SyncRecordDatatypeBin("DataUse.Sync.Upload.Bytes", | 82 SyncRecordDatatypeBin("DataUse.Sync.Upload.Bytes", |
| 84 local_integer_model_type, current_entry_size); | 83 local_integer_model_type, current_entry_size); |
| 85 } | 84 } |
| 86 UMA_HISTOGRAM_SPARSE_SLOWLY("DataUse.Sync.Upload.Count", | 85 UMA_HISTOGRAM_SPARSE_SLOWLY("DataUse.Sync.Upload.Count", |
| 87 local_integer_model_type); | 86 local_integer_model_type); |
| 88 } | 87 } |
| 89 | 88 |
| 90 // If we made it this far, then we've successfully prepared a commit message. | 89 // If we made it this far, then we've successfully prepared a commit message. |
| 91 return new Commit(contributions.Pass(), message, extensions_activity_buffer); | 90 return new Commit(std::move(contributions), message, |
| 91 extensions_activity_buffer); |
| 92 } | 92 } |
| 93 | 93 |
| 94 SyncerError Commit::PostAndProcessResponse( | 94 SyncerError Commit::PostAndProcessResponse( |
| 95 sessions::NudgeTracker* nudge_tracker, | 95 sessions::NudgeTracker* nudge_tracker, |
| 96 sessions::SyncSession* session, | 96 sessions::SyncSession* session, |
| 97 sessions::StatusController* status, | 97 sessions::StatusController* status, |
| 98 ExtensionsActivity* extensions_activity) { | 98 ExtensionsActivity* extensions_activity) { |
| 99 ModelTypeSet request_types; | 99 ModelTypeSet request_types; |
| 100 for (ContributionMap::const_iterator it = contributions_.begin(); | 100 for (ContributionMap::const_iterator it = contributions_.begin(); |
| 101 it != contributions_.end(); ++it) { | 101 it != contributions_.end(); ++it) { |
| (...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 182 | 182 |
| 183 void Commit::CleanUp() { | 183 void Commit::CleanUp() { |
| 184 for (ContributionMap::const_iterator it = contributions_.begin(); | 184 for (ContributionMap::const_iterator it = contributions_.begin(); |
| 185 it != contributions_.end(); ++it) { | 185 it != contributions_.end(); ++it) { |
| 186 it->second->CleanUp(); | 186 it->second->CleanUp(); |
| 187 } | 187 } |
| 188 cleaned_up_ = true; | 188 cleaned_up_ = true; |
| 189 } | 189 } |
| 190 | 190 |
| 191 } // namespace syncer | 191 } // namespace syncer |
| OLD | NEW |