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

Unified Diff: components/previews/previews_experiments.cc

Issue 2179863003: Adding a new component, Previews. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: macro change Created 4 years, 5 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/previews/previews_experiments.cc
diff --git a/components/previews/previews_experiments.cc b/components/previews/previews_experiments.cc
new file mode 100644
index 0000000000000000000000000000000000000000..6dbde967b0caab5fcc39b6d5b44e3fc946b9ba4d
--- /dev/null
+++ b/components/previews/previews_experiments.cc
@@ -0,0 +1,47 @@
+// Copyright 2016 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include "components/previews/previews_experiments.h"
+
+#include <map>
+#include <string>
+
+#include "base/metrics/field_trial.h"
+#include "components/variations/variations_associated_data.h"
+
+namespace {
+
+// The group of client side previews experiments.
+const char kClientSideExperimentsFieldTrial[] =
+ "DataReductionProxyClientSideExperimentsFieldTrial";
tbansal1 2016/07/26 20:11:37 I do not think that the field trial name should co
RyanSturm 2016/07/26 21:56:52 Done.
+
+const char kEnabled[] = "Enabled";
+
+// Allow offline pages to show for prohibitively slow networks.
+const char kOfflinePagesSlowNetwork[] = "show_offline_pages";
+
+} // namespace
+
+namespace previews {
+
+bool IsIncludedInClientSidePreviewsExperimentsFieldTrial() {
+ return base::FieldTrialList::FindFullName(kClientSideExperimentsFieldTrial) ==
tbansal1 2016/07/26 20:11:37 Check if prefix is kEnabled (instead of exact matc
RyanSturm 2016/07/26 21:56:52 Done.
+ kEnabled;
+}
+
+bool IsIncludedInOfflinePagesSlowConnectionFieldTrial() {
+ if (!IsIncludedInClientSidePreviewsExperimentsFieldTrial())
+ return false;
+ std::map<std::string, std::string> client_side_params;
+ if (!variations::GetVariationParams(kClientSideExperimentsFieldTrial,
+ &client_side_params))
tbansal1 2016/07/26 20:11:37 Add braces
RyanSturm 2016/07/26 21:56:52 Done.
+ return false;
+ std::map<std::string, std::string>::const_iterator it =
+ client_side_params.find(kOfflinePagesSlowNetwork);
+ if (it == client_side_params.end())
+ return false;
+ return it->second == "1";
tbansal1 2016/07/26 20:11:37 s/"1"/"true"/
tbansal1 2016/07/26 20:11:37 nit: May be combine with above: return it != ..end
RyanSturm 2016/07/26 21:56:52 Done.
RyanSturm 2016/07/26 21:56:52 Done.
+}
+
+} // namespace previews

Powered by Google App Engine
This is Rietveld 408576698