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

Unified Diff: components/data_reduction_proxy/content/common/content_data_reduction_proxy_lofi_helper.cc

Issue 1310743003: Consistently use LoFi for an entire page (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: using UserData and adressing nasko comments Created 5 years, 3 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/data_reduction_proxy/content/common/content_data_reduction_proxy_lofi_helper.cc
diff --git a/components/data_reduction_proxy/content/common/content_data_reduction_proxy_lofi_helper.cc b/components/data_reduction_proxy/content/common/content_data_reduction_proxy_lofi_helper.cc
new file mode 100644
index 0000000000000000000000000000000000000000..52a4b9d80217e7a70434a039ebb5a768d8bfc629
--- /dev/null
+++ b/components/data_reduction_proxy/content/common/content_data_reduction_proxy_lofi_helper.cc
@@ -0,0 +1,44 @@
+// Copyright 2015 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/data_reduction_proxy/content/common/content_data_reduction_proxy_lofi_helper.h"
+
+#include "content/public/common/data_reduction_proxy_lofi_user_data.h"
+#include "net/url_request/url_request.h"
+
+namespace data_reduction_proxy {
+
+ContentDataReductionProxyLoFiHelper::ContentDataReductionProxyLoFiHelper() {}
+
+ContentDataReductionProxyLoFiHelper::~ContentDataReductionProxyLoFiHelper() {}
+
+LoFiState ContentDataReductionProxyLoFiHelper::lofi_state(
+ net::URLRequest* request) const {
+ content::DataReductionProxyLoFiUserData* lofi_user_data =
+ static_cast<content::DataReductionProxyLoFiUserData*>(
+ request->GetUserData(
+ content::DataReductionProxyLoFiUserData::kUserDataKey));
+ if (lofi_user_data)
+ return static_cast<LoFiState>(lofi_user_data->lofi_state());
+ else
+ return LOFI_DEFAULT;
+}
+
+void ContentDataReductionProxyLoFiHelper::set_lofi_state(
bengr 2015/09/21 17:56:08 These seem to be more complicated than typical get
megjablon 2015/09/22 20:35:52 Done.
+ net::URLRequest* request,
+ LoFiState lofi_state) {
+ content::DataReductionProxyLoFiUserData* lofi_user_data =
+ static_cast<content::DataReductionProxyLoFiUserData*>(
+ request->GetUserData(
+ content::DataReductionProxyLoFiUserData::kUserDataKey));
+ if (lofi_user_data) {
+ lofi_user_data->set_lofi_state(static_cast<content::LoFiState>(lofi_state));
+ } else {
+ request->SetUserData(content::DataReductionProxyLoFiUserData::kUserDataKey,
+ new content::DataReductionProxyLoFiUserData(
+ static_cast<content::LoFiState>(lofi_state)));
+ }
+}
+
+} // namespace data_reduction_roxy

Powered by Google App Engine
This is Rietveld 408576698