Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(293)

Unified Diff: components/sync/engine_impl/commit.cc

Issue 2380143002: [Sync] Enable Compression from Client to Server by experiment (Closed)
Patch Set: rebase Created 4 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: components/sync/engine_impl/commit.cc
diff --git a/components/sync/engine_impl/commit.cc b/components/sync/engine_impl/commit.cc
index f8d9bf55c5418401f68f26c2cb8ef9ae6f9562b8..e6df7844ca11c8b73b79c201703778d1fc8a52fa 100644
--- a/components/sync/engine_impl/commit.cc
+++ b/components/sync/engine_impl/commit.cc
@@ -6,11 +6,14 @@
#include <utility>
+#include "base/feature_list.h"
#include "base/metrics/histogram_macros.h"
+#include "base/rand_util.h"
#include "base/trace_event/trace_event.h"
#include "components/sync/base/data_type_histogram.h"
#include "components/sync/engine/events/commit_request_event.h"
#include "components/sync/engine/events/commit_response_event.h"
+#include "components/sync/engine/net/http_bridge.h"
#include "components/sync/engine_impl/commit_processor.h"
#include "components/sync/engine_impl/commit_util.h"
#include "components/sync/engine_impl/cycle/sync_cycle.h"
@@ -19,6 +22,13 @@
namespace syncer {
+namespace {
+// The number of random ASCII bytes we'll add to CommitMessage. We choose 256
+// because it is not too large (to hurt performance and compression ratio), but
+// it is not too small to easily be canceled out using statistical analysis.
+const size_t kPaddingSize = 256;
+}
+
Commit::Commit(ContributionMap contributions,
const sync_pb::ClientToServerMessage& message,
ExtensionsActivity::Records extensions_activity_buffer)
@@ -57,6 +67,11 @@ Commit* Commit::Init(ModelTypeSet requested_types,
sync_pb::CommitMessage* commit_message = message.mutable_commit();
commit_message->set_cache_guid(cache_guid);
+ // Set padding to mitigate CRIME attack.
+ if (base::FeatureList::IsEnabled(syncer::kSyncClientToServerCompression)) {
+ commit_message->set_padding(base::RandBytesAsString(kPaddingSize));
+ }
+
// Set extensions activity if bookmark commits are present.
ExtensionsActivity::Records extensions_activity_buffer;
ContributionMap::const_iterator it = contributions.find(BOOKMARKS);

Powered by Google App Engine
This is Rietveld 408576698