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

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

Issue 2063683002: Migrate components/data_reduction_proxy to Mojo interfaces. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fix unit tests 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/data_reduction_proxy/content/browser/data_reduction_proxy_host_impl.cc
diff --git a/components/data_reduction_proxy/content/browser/data_reduction_proxy_host_impl.cc b/components/data_reduction_proxy/content/browser/data_reduction_proxy_host_impl.cc
new file mode 100644
index 0000000000000000000000000000000000000000..2902737501c4d72543ae7e51d529e254d5180abf
--- /dev/null
+++ b/components/data_reduction_proxy/content/browser/data_reduction_proxy_host_impl.cc
@@ -0,0 +1,54 @@
+// 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/data_reduction_proxy/content/browser/data_reduction_proxy_host_impl.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 "content/public/browser/render_process_host.h"
+#include "net/base/host_port_pair.h"
+
+namespace data_reduction_proxy {
+
+DataReductionProxyHostImpl::DataReductionProxyHostImpl(
+ DataReductionProxySettings* settings,
+ content::RenderProcessHost* host)
+ : config_(nullptr) {
+ if (settings)
+ config_ = settings->Config();
+ // Unit tests may pass nullptr as |host|.
+ if (host)
+ host->AddObserver(this);
+}
+
+DataReductionProxyHostImpl::~DataReductionProxyHostImpl() {}
+
+void DataReductionProxyHostImpl::BindRequest(
+ mojom::DataReductionProxyHostRequest request) {
+ DCHECK_CURRENTLY_ON(content::BrowserThread::IO);
+ bindings_.AddBinding(this, std::move(request));
+}
+
+void DataReductionProxyHostImpl::IsDataReductionProxy(
+ const net::HostPortPair& proxy_server,
+ const IsDataReductionProxyCallback& callback) {
+ if (!config_) {
tbansal1 2016/07/13 17:35:18 Add DCHECK_CURRENTLY_ON(content::BrowserThread::IO
leonhsl(Using Gerrit) 2016/07/14 14:54:53 Tried to add in ps#21 but found DataReductionProxy
+ callback.Run(false);
+ return;
+ }
+
+ callback.Run(config_->IsDataReductionProxy(proxy_server, nullptr));
+}
+
+void DataReductionProxyHostImpl::RenderProcessExited(
+ content::RenderProcessHost* host,
+ base::TerminationStatus status,
+ int exit_code) {
+ host->RemoveObserver(this);
+ content::BrowserThread::DeleteSoon(content::BrowserThread::IO, FROM_HERE,
+ this);
+}
+
+} // namespace data_reduction_proxy

Powered by Google App Engine
This is Rietveld 408576698