Chromium Code Reviews| 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 "components/sync/engine_impl/commit.h" | 5 #include "components/sync/engine_impl/commit.h" |
| 6 | 6 |
| 7 #include <utility> | 7 #include <utility> |
| 8 | 8 |
| 9 #include "base/metrics/sparse_histogram.h" | 9 #include "base/metrics/sparse_histogram.h" |
| 10 #include "base/rand_util.h" | |
| 10 #include "base/trace_event/trace_event.h" | 11 #include "base/trace_event/trace_event.h" |
| 11 #include "components/sync/base/data_type_histogram.h" | 12 #include "components/sync/base/data_type_histogram.h" |
| 12 #include "components/sync/engine/events/commit_request_event.h" | 13 #include "components/sync/engine/events/commit_request_event.h" |
| 13 #include "components/sync/engine/events/commit_response_event.h" | 14 #include "components/sync/engine/events/commit_response_event.h" |
| 15 #include "components/sync/engine/net/http_bridge.h" | |
| 14 #include "components/sync/engine_impl/commit_processor.h" | 16 #include "components/sync/engine_impl/commit_processor.h" |
| 15 #include "components/sync/engine_impl/commit_util.h" | 17 #include "components/sync/engine_impl/commit_util.h" |
| 16 #include "components/sync/engine_impl/cycle/sync_cycle.h" | 18 #include "components/sync/engine_impl/cycle/sync_cycle.h" |
| 17 #include "components/sync/engine_impl/syncer.h" | 19 #include "components/sync/engine_impl/syncer.h" |
| 18 #include "components/sync/engine_impl/syncer_proto_util.h" | 20 #include "components/sync/engine_impl/syncer_proto_util.h" |
| 19 | 21 |
| 20 namespace syncer { | 22 namespace syncer { |
| 21 | 23 |
| 22 Commit::Commit(ContributionMap contributions, | 24 Commit::Commit(ContributionMap contributions, |
| 23 const sync_pb::ClientToServerMessage& message, | 25 const sync_pb::ClientToServerMessage& message, |
| (...skipping 25 matching lines...) Expand all Loading... | |
| 49 // Give up if no one had anything to commit. | 51 // Give up if no one had anything to commit. |
| 50 if (contributions.empty()) | 52 if (contributions.empty()) |
| 51 return NULL; | 53 return NULL; |
| 52 | 54 |
| 53 sync_pb::ClientToServerMessage message; | 55 sync_pb::ClientToServerMessage message; |
| 54 message.set_message_contents(sync_pb::ClientToServerMessage::COMMIT); | 56 message.set_message_contents(sync_pb::ClientToServerMessage::COMMIT); |
| 55 message.set_share(account_name); | 57 message.set_share(account_name); |
| 56 | 58 |
| 57 sync_pb::CommitMessage* commit_message = message.mutable_commit(); | 59 sync_pb::CommitMessage* commit_message = message.mutable_commit(); |
| 58 commit_message->set_cache_guid(cache_guid); | 60 commit_message->set_cache_guid(cache_guid); |
| 61 if (base::FeatureList::IsEnabled(syncer::kSyncClientToServerCompression)) { | |
| 62 commit_message->set_padding(base::RandBytesAsString(256)); | |
|
Nicolas Zea
2016/10/18 20:23:08
prefer having the length defined at the top of fil
Gang Wu
2016/10/19 00:06:13
Done.
| |
| 63 } | |
| 59 | 64 |
| 60 // Set extensions activity if bookmark commits are present. | 65 // Set extensions activity if bookmark commits are present. |
| 61 ExtensionsActivity::Records extensions_activity_buffer; | 66 ExtensionsActivity::Records extensions_activity_buffer; |
| 62 ContributionMap::const_iterator it = contributions.find(BOOKMARKS); | 67 ContributionMap::const_iterator it = contributions.find(BOOKMARKS); |
| 63 if (it != contributions.end() && it->second->GetNumEntries() != 0) { | 68 if (it != contributions.end() && it->second->GetNumEntries() != 0) { |
| 64 commit_util::AddExtensionsActivityToMessage( | 69 commit_util::AddExtensionsActivityToMessage( |
| 65 extensions_activity, &extensions_activity_buffer, commit_message); | 70 extensions_activity, &extensions_activity_buffer, commit_message); |
| 66 } | 71 } |
| 67 | 72 |
| 68 // Set the client config params. | 73 // Set the client config params. |
| (...skipping 106 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 175 | 180 |
| 176 void Commit::CleanUp() { | 181 void Commit::CleanUp() { |
| 177 for (ContributionMap::const_iterator it = contributions_.begin(); | 182 for (ContributionMap::const_iterator it = contributions_.begin(); |
| 178 it != contributions_.end(); ++it) { | 183 it != contributions_.end(); ++it) { |
| 179 it->second->CleanUp(); | 184 it->second->CleanUp(); |
| 180 } | 185 } |
| 181 cleaned_up_ = true; | 186 cleaned_up_ = true; |
| 182 } | 187 } |
| 183 | 188 |
| 184 } // namespace syncer | 189 } // namespace syncer |
| OLD | NEW |