Commit 8a7ab212 authored by Matt Menke's avatar Matt Menke Committed by Commit Bot

Remove use of g_browser_process->net_log() in CastTransportHostFilter.

I'm removing all use of NetLog except through URLRequestContext, as part
of servicification. Eventually URLRequestContexts, will be out of
process, too, but that's quite a ways off.

Bug: 767450
Change-Id: If905f1cf7f5737ecb55f5b1ac9433ed4f14a85c8
Reviewed-on: https://chromium-review.googlesource.com/677232Reviewed-by: default avatarSergey Ulanov <sergeyu@chromium.org>
Commit-Queue: Matt Menke <mmenke@chromium.org>
Cr-Commit-Position: refs/heads/master@{#504219}
parent cb6cf75d
...@@ -1017,7 +1017,7 @@ void ChromeContentBrowserClient::RenderProcessWillLaunch( ...@@ -1017,7 +1017,7 @@ void ChromeContentBrowserClient::RenderProcessWillLaunch(
Profile* profile = Profile::FromBrowserContext(host->GetBrowserContext()); Profile* profile = Profile::FromBrowserContext(host->GetBrowserContext());
host->AddFilter(new ChromeRenderMessageFilter(id, profile)); host->AddFilter(new ChromeRenderMessageFilter(id, profile));
#if BUILDFLAG(ENABLE_EXTENSIONS) #if BUILDFLAG(ENABLE_EXTENSIONS)
host->AddFilter(new cast::CastTransportHostFilter); host->AddFilter(new cast::CastTransportHostFilter(profile));
#endif #endif
#if BUILDFLAG(ENABLE_PRINTING) #if BUILDFLAG(ENABLE_PRINTING)
host->AddFilter(new printing::PrintingMessageFilter(id, profile)); host->AddFilter(new printing::PrintingMessageFilter(id, profile));
......
...@@ -8,13 +8,14 @@ ...@@ -8,13 +8,14 @@
#include "base/memory/ptr_util.h" #include "base/memory/ptr_util.h"
#include "base/threading/thread_task_runner_handle.h" #include "base/threading/thread_task_runner_handle.h"
#include "chrome/browser/browser_process.h" #include "chrome/browser/profiles/profile.h"
#include "chrome/common/cast_messages.h" #include "chrome/common/cast_messages.h"
#include "components/net_log/chrome_net_log.h" #include "components/net_log/chrome_net_log.h"
#include "content/public/browser/browser_thread.h" #include "content/public/browser/browser_thread.h"
#include "content/public/common/service_manager_connection.h" #include "content/public/common/service_manager_connection.h"
#include "media/cast/net/cast_transport.h" #include "media/cast/net/cast_transport.h"
#include "mojo/public/cpp/bindings/interface_request.h" #include "mojo/public/cpp/bindings/interface_request.h"
#include "net/url_request/url_request_context.h"
#include "services/device/public/interfaces/constants.mojom.h" #include "services/device/public/interfaces/constants.mojom.h"
#include "services/device/public/interfaces/wake_lock_provider.mojom.h" #include "services/device/public/interfaces/wake_lock_provider.mojom.h"
#include "services/service_manager/public/cpp/connector.h" #include "services/service_manager/public/cpp/connector.h"
...@@ -118,8 +119,9 @@ void BindConnectorRequest( ...@@ -118,8 +119,9 @@ void BindConnectorRequest(
namespace cast { namespace cast {
CastTransportHostFilter::CastTransportHostFilter() CastTransportHostFilter::CastTransportHostFilter(Profile* profile)
: BrowserMessageFilter(CastMsgStart), : BrowserMessageFilter(CastMsgStart),
url_request_context_getter_(profile->GetRequestContext()),
weak_factory_(this) {} weak_factory_(this) {}
CastTransportHostFilter::~CastTransportHostFilter() {} CastTransportHostFilter::~CastTransportHostFilter() {}
...@@ -174,8 +176,9 @@ void CastTransportHostFilter::OnNew(int32_t channel_id, ...@@ -174,8 +176,9 @@ void CastTransportHostFilter::OnNew(int32_t channel_id,
std::unique_ptr<media::cast::UdpTransport> udp_transport( std::unique_ptr<media::cast::UdpTransport> udp_transport(
new media::cast::UdpTransport( new media::cast::UdpTransport(
g_browser_process->net_log(), base::ThreadTaskRunnerHandle::Get(), url_request_context_getter_->GetURLRequestContext()->net_log(),
local_end_point, remote_end_point, base::ThreadTaskRunnerHandle::Get(), local_end_point,
remote_end_point,
base::Bind(&CastTransportHostFilter::OnStatusChanged, base::Bind(&CastTransportHostFilter::OnStatusChanged,
weak_factory_.GetWeakPtr(), channel_id))); weak_factory_.GetWeakPtr(), channel_id)));
udp_transport->SetUdpOptions(options); udp_transport->SetUdpOptions(options);
......
...@@ -11,6 +11,7 @@ ...@@ -11,6 +11,7 @@
#include "base/containers/id_map.h" #include "base/containers/id_map.h"
#include "base/macros.h" #include "base/macros.h"
#include "base/memory/ref_counted.h"
#include "base/memory/weak_ptr.h" #include "base/memory/weak_ptr.h"
#include "base/time/default_tick_clock.h" #include "base/time/default_tick_clock.h"
#include "chrome/browser/media/cast_remoting_sender.h" #include "chrome/browser/media/cast_remoting_sender.h"
...@@ -19,13 +20,16 @@ ...@@ -19,13 +20,16 @@
#include "media/cast/logging/logging_defines.h" #include "media/cast/logging/logging_defines.h"
#include "media/cast/net/cast_transport.h" #include "media/cast/net/cast_transport.h"
#include "media/cast/net/udp_transport.h" #include "media/cast/net/udp_transport.h"
#include "net/url_request/url_request_context_getter.h"
#include "services/device/public/interfaces/wake_lock.mojom.h" #include "services/device/public/interfaces/wake_lock.mojom.h"
class Profile;
namespace cast { namespace cast {
class CastTransportHostFilter : public content::BrowserMessageFilter { class CastTransportHostFilter : public content::BrowserMessageFilter {
public: public:
CastTransportHostFilter(); explicit CastTransportHostFilter(Profile* profile);
// Used by unit test only. // Used by unit test only.
void InitializeNoOpWakeLockForTesting(); void InitializeNoOpWakeLockForTesting();
...@@ -114,6 +118,8 @@ class CastTransportHostFilter : public content::BrowserMessageFilter { ...@@ -114,6 +118,8 @@ class CastTransportHostFilter : public content::BrowserMessageFilter {
// channel ID as the key. // channel ID as the key.
std::multimap<int32_t, int32_t> stream_id_map_; std::multimap<int32_t, int32_t> stream_id_map_;
scoped_refptr<net::URLRequestContextGetter> url_request_context_getter_;
base::WeakPtrFactory<CastTransportHostFilter> weak_factory_; base::WeakPtrFactory<CastTransportHostFilter> weak_factory_;
DISALLOW_COPY_AND_ASSIGN(CastTransportHostFilter); DISALLOW_COPY_AND_ASSIGN(CastTransportHostFilter);
......
...@@ -9,6 +9,7 @@ ...@@ -9,6 +9,7 @@
#include "base/time/default_tick_clock.h" #include "base/time/default_tick_clock.h"
#include "chrome/browser/media/cast_transport_host_filter.h" #include "chrome/browser/media/cast_transport_host_filter.h"
#include "chrome/common/cast_messages.h" #include "chrome/common/cast_messages.h"
#include "chrome/test/base/testing_profile.h"
#include "content/public/test/test_browser_thread_bundle.h" #include "content/public/test/test_browser_thread_bundle.h"
#include "media/cast/logging/logging_defines.h" #include "media/cast/logging/logging_defines.h"
#include "net/base/ip_address.h" #include "net/base/ip_address.h"
...@@ -21,7 +22,7 @@ class CastTransportHostFilterTest : public testing::Test { ...@@ -21,7 +22,7 @@ class CastTransportHostFilterTest : public testing::Test {
CastTransportHostFilterTest() CastTransportHostFilterTest()
: browser_thread_bundle_( : browser_thread_bundle_(
content::TestBrowserThreadBundle::IO_MAINLOOP) { content::TestBrowserThreadBundle::IO_MAINLOOP) {
filter_ = new cast::CastTransportHostFilter(); filter_ = new cast::CastTransportHostFilter(&profile_);
static_cast<cast::CastTransportHostFilter*>(filter_.get()) static_cast<cast::CastTransportHostFilter*>(filter_.get())
->InitializeNoOpWakeLockForTesting(); ->InitializeNoOpWakeLockForTesting();
// 127.0.0.1:7 is the local echo service port, which // 127.0.0.1:7 is the local echo service port, which
...@@ -38,6 +39,7 @@ class CastTransportHostFilterTest : public testing::Test { ...@@ -38,6 +39,7 @@ class CastTransportHostFilterTest : public testing::Test {
base::DictionaryValue options_; base::DictionaryValue options_;
content::TestBrowserThreadBundle browser_thread_bundle_; content::TestBrowserThreadBundle browser_thread_bundle_;
TestingProfile profile_;
scoped_refptr<content::BrowserMessageFilter> filter_; scoped_refptr<content::BrowserMessageFilter> filter_;
net::IPEndPoint receive_endpoint_; net::IPEndPoint receive_endpoint_;
}; };
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment