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

Unified Diff: components/data_reduction_proxy/content/browser/data_reduction_proxy_message_filter.cc

Issue 966443002: Add DataReductionProxy IPC to determine if the Data Reduction Proxy was used. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Rebase to head Created 5 years, 10 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/browser/data_reduction_proxy_message_filter.cc
diff --git a/components/data_reduction_proxy/content/browser/data_reduction_proxy_message_filter.cc b/components/data_reduction_proxy/content/browser/data_reduction_proxy_message_filter.cc
new file mode 100644
index 0000000000000000000000000000000000000000..e01c4998d715aba61b5cd09f2f383ca892531dc8
--- /dev/null
+++ b/components/data_reduction_proxy/content/browser/data_reduction_proxy_message_filter.cc
@@ -0,0 +1,54 @@
+// 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/browser/data_reduction_proxy_message_filter.h"
+
+#include "components/data_reduction_proxy/content/common/data_reduction_proxy_messages.h"
+#include "components/data_reduction_proxy/core/browser/data_reduction_proxy_config.h"
+#include "components/data_reduction_proxy/core/browser/data_reduction_proxy_settings.h"
+#include "content/public/browser/browser_thread.h"
+#include "ipc/ipc_message_macros.h"
+#include "net/base/host_port_pair.h"
+
+namespace data_reduction_proxy {
+
+DataReductionProxyMessageFilter::DataReductionProxyMessageFilter(
+ DataReductionProxySettings* settings)
+ : BrowserMessageFilter(DataReductionProxyStart),
+ config_(nullptr) {
+ DCHECK(settings);
+ config_ = settings->Config();
+}
+
+DataReductionProxyMessageFilter::~DataReductionProxyMessageFilter() {
+}
+
+bool DataReductionProxyMessageFilter::OnMessageReceived(
+ const IPC::Message& message) {
+ bool handled = true;
+ IPC_BEGIN_MESSAGE_MAP(DataReductionProxyMessageFilter, message)
+ IPC_MESSAGE_HANDLER(DataReductionProxyViewHostMsg_IsDataReductionProxy,
+ OnIsDataReductionProxy)
+ IPC_MESSAGE_UNHANDLED(handled = false)
+ IPC_END_MESSAGE_MAP()
+ return handled;
+}
+
+void DataReductionProxyMessageFilter::OverrideThreadForMessage(
+ const IPC::Message& message, content::BrowserThread::ID* thread) {
+ if (message.type() ==
+ DataReductionProxyViewHostMsg_IsDataReductionProxy::ID) {
+ *thread = content::BrowserThread::IO;
+ }
+}
+
+void DataReductionProxyMessageFilter::OnIsDataReductionProxy(
+ const net::HostPortPair& proxy_server, bool* response) {
+ if (config_)
+ *response = config_->IsDataReductionProxy(proxy_server, nullptr);
+ else
+ *response = false;
+}
+
+} // namespace data_reduction_proxy

Powered by Google App Engine
This is Rietveld 408576698