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..d19889862594118be60238bef130eeb6324bb251 |
--- /dev/null |
+++ b/components/data_reduction_proxy/content/browser/data_reduction_proxy_message_filter.cc |
@@ -0,0 +1,53 @@ |
+// 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) { |
+ if (settings != nullptr) |
bengr
2015/02/26 22:52:52
Why is this not a DCHECK?
jeremyim
2015/02/27 04:38:40
Done.
|
+ config_ = settings->Config(); |
+} |
+ |
+DataReductionProxyMessageFilter::~DataReductionProxyMessageFilter() {} |
bengr
2015/02/26 22:52:52
Move close curly to next line.
jeremyim
2015/02/27 04:38:40
Done.
|
+ |
+bool DataReductionProxyMessageFilter::OnMessageReceived( |
+ const IPC::Message& message) { |
+ bool handled = true; |
+ IPC_BEGIN_MESSAGE_MAP(DataReductionProxyMessageFilter, message) |
+ IPC_MESSAGE_HANDLER(DataReductionProxyViewHostMsg_WasDataReductionProxyUsed, |
+ OnWasDataReductionProxyUsed) |
+ 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_WasDataReductionProxyUsed::ID) |
bengr
2015/02/26 22:52:52
Indent 4 and enclose the next line in braces.
jeremyim
2015/02/27 04:38:40
Done.
|
+ *thread = content::BrowserThread::IO; |
+} |
+ |
+void DataReductionProxyMessageFilter::OnWasDataReductionProxyUsed( |
+ const net::HostPortPair& proxy_server, bool* response) { |
+ if (config_) { |
bengr
2015/02/26 22:52:52
These don't need curly braces.
jeremyim
2015/02/27 04:38:40
Done.
|
+ *response = config_->IsDataReductionProxy(proxy_server, nullptr); |
+ } else { |
+ *response = false; |
+ } |
+} |
+ |
+} // namespace data_reduction_proxy |