| 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 <stddef.h> | 7 #include <stddef.h> |
| 8 | 8 |
| 9 #include "base/metrics/sparse_histogram.h" | 9 #include "base/metrics/sparse_histogram.h" |
| 10 #include "base/trace_event/trace_event.h" | 10 #include "base/trace_event/trace_event.h" |
| (...skipping 20 matching lines...) Expand all Loading... |
| 31 Commit::~Commit() { | 31 Commit::~Commit() { |
| 32 DCHECK(cleaned_up_); | 32 DCHECK(cleaned_up_); |
| 33 } | 33 } |
| 34 | 34 |
| 35 Commit* Commit::Init( | 35 Commit* Commit::Init( |
| 36 ModelTypeSet requested_types, | 36 ModelTypeSet requested_types, |
| 37 ModelTypeSet enabled_types, | 37 ModelTypeSet enabled_types, |
| 38 size_t max_entries, | 38 size_t max_entries, |
| 39 const std::string& account_name, | 39 const std::string& account_name, |
| 40 const std::string& cache_guid, | 40 const std::string& cache_guid, |
| 41 bool cookie_jar_mismatch, |
| 41 CommitProcessor* commit_processor, | 42 CommitProcessor* commit_processor, |
| 42 ExtensionsActivity* extensions_activity) { | 43 ExtensionsActivity* extensions_activity) { |
| 43 // Gather per-type contributions. | 44 // Gather per-type contributions. |
| 44 ContributionMap contributions; | 45 ContributionMap contributions; |
| 45 commit_processor->GatherCommitContributions( | 46 commit_processor->GatherCommitContributions( |
| 46 requested_types, | 47 requested_types, |
| 47 max_entries, | 48 max_entries, |
| 48 &contributions); | 49 &contributions); |
| 49 | 50 |
| 50 // Give up if no one had anything to commit. | 51 // Give up if no one had anything to commit. |
| (...skipping 13 matching lines...) Expand all Loading... |
| 64 if (it != contributions.end() && it->second->GetNumEntries() != 0) { | 65 if (it != contributions.end() && it->second->GetNumEntries() != 0) { |
| 65 commit_util::AddExtensionsActivityToMessage( | 66 commit_util::AddExtensionsActivityToMessage( |
| 66 extensions_activity, | 67 extensions_activity, |
| 67 &extensions_activity_buffer, | 68 &extensions_activity_buffer, |
| 68 commit_message); | 69 commit_message); |
| 69 } | 70 } |
| 70 | 71 |
| 71 // Set the client config params. | 72 // Set the client config params. |
| 72 commit_util::AddClientConfigParamsToMessage( | 73 commit_util::AddClientConfigParamsToMessage( |
| 73 enabled_types, | 74 enabled_types, |
| 75 cookie_jar_mismatch, |
| 74 commit_message); | 76 commit_message); |
| 75 | 77 |
| 76 int previous_message_size = message.ByteSize(); | 78 int previous_message_size = message.ByteSize(); |
| 77 // Finally, serialize all our contributions. | 79 // Finally, serialize all our contributions. |
| 78 for (const auto& contribution : contributions) { | 80 for (const auto& contribution : contributions) { |
| 79 contribution.second->AddToCommitMessage(&message); | 81 contribution.second->AddToCommitMessage(&message); |
| 80 int current_entry_size = message.ByteSize() - previous_message_size; | 82 int current_entry_size = message.ByteSize() - previous_message_size; |
| 81 previous_message_size = message.ByteSize(); | 83 previous_message_size = message.ByteSize(); |
| 82 int local_integer_model_type = ModelTypeToHistogramInt(contribution.first); | 84 int local_integer_model_type = ModelTypeToHistogramInt(contribution.first); |
| 83 if (current_entry_size > 0) { | 85 if (current_entry_size > 0) { |
| (...skipping 100 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 184 | 186 |
| 185 void Commit::CleanUp() { | 187 void Commit::CleanUp() { |
| 186 for (ContributionMap::const_iterator it = contributions_.begin(); | 188 for (ContributionMap::const_iterator it = contributions_.begin(); |
| 187 it != contributions_.end(); ++it) { | 189 it != contributions_.end(); ++it) { |
| 188 it->second->CleanUp(); | 190 it->second->CleanUp(); |
| 189 } | 191 } |
| 190 cleaned_up_ = true; | 192 cleaned_up_ = true; |
| 191 } | 193 } |
| 192 | 194 |
| 193 } // namespace syncer | 195 } // namespace syncer |
| OLD | NEW |