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

Unified Diff: chromecast/browser/cast_content_browser_client.cc

Issue 1081673004: Chromecast startup race: don't add filter before HostResolver exists. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: logic all in CCBC Created 5 years, 8 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
« no previous file with comments | « chromecast/browser/cast_content_browser_client.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chromecast/browser/cast_content_browser_client.cc
diff --git a/chromecast/browser/cast_content_browser_client.cc b/chromecast/browser/cast_content_browser_client.cc
index 3234a597e1b5f7780aa1ac1b484feabeadba41ab..41a7f90a99695b0f4a2955eccef55d969940ceed 100644
--- a/chromecast/browser/cast_content_browser_client.cc
+++ b/chromecast/browser/cast_content_browser_client.cc
@@ -40,6 +40,7 @@
#include "content/public/common/web_preferences.h"
#include "gin/v8_initializer.h"
#include "net/ssl/ssl_cert_request_info.h"
+#include "net/url_request/url_request_context_getter.h"
#include "ui/gl/gl_switches.h"
#if defined(OS_ANDROID)
@@ -74,22 +75,48 @@ content::BrowserMainParts* CastContentBrowserClient::CreateBrowserMainParts(
void CastContentBrowserClient::RenderProcessWillLaunch(
content::RenderProcessHost* host) {
- scoped_refptr<content::BrowserMessageFilter> network_hints_message_filter(
- new network_hints::NetworkHintsMessageFilter(
- url_request_context_factory_->host_resolver()));
- host->AddFilter(network_hints_message_filter.get());
#if !defined(OS_ANDROID)
scoped_refptr<media::CmaMessageFilterHost> cma_message_filter(
new media::CmaMessageFilterHost(host->GetID()));
host->AddFilter(cma_message_filter.get());
#endif // !defined(OS_ANDROID)
+ // Forcibly trigger I/O-thread URLRequestContext initialization before
+ // getting HostResolver.
+ content::BrowserThread::PostTask(
+ content::BrowserThread::IO,
+ FROM_HERE,
+ base::Bind(base::IgnoreResult(
+ &net::URLRequestContextGetter::GetURLRequestContext),
+ base::Unretained(
+ url_request_context_factory_->GetSystemGetter())));
+ content::BrowserThread::PostTaskAndReplyWithResult(
+ content::BrowserThread::IO, FROM_HERE,
+ base::Bind(&URLRequestContextFactory::host_resolver,
+ base::Unretained(url_request_context_factory_.get())),
+ base::Bind(&CastContentBrowserClient::AddExtraFilter,
+ base::Unretained(this), host->GetID()));
byungchul 2015/04/21 00:24:30 I am fine with this, but you can merge 2 posttasks
gunsch 2015/04/21 17:10:46 I like that idea, done.
+
auto extra_filters = PlatformGetBrowserMessageFilters();
for (auto const& filter : extra_filters) {
host->AddFilter(filter.get());
}
}
+void CastContentBrowserClient::AddExtraFilter(
+ int render_process_id, net::HostResolver* host_resolver) {
+ DCHECK_CURRENTLY_ON(content::BrowserThread::UI);
+
+ content::RenderProcessHost* host =
+ content::RenderProcessHost::FromID(render_process_id);
+ if (!host)
+ return;
+
+ scoped_refptr<content::BrowserMessageFilter> network_hints_message_filter(
+ new network_hints::NetworkHintsMessageFilter(host_resolver));
+ host->AddFilter(network_hints_message_filter.get());
+}
+
net::URLRequestContextGetter* CastContentBrowserClient::CreateRequestContext(
content::BrowserContext* browser_context,
content::ProtocolHandlerMap* protocol_handlers,
« no previous file with comments | « chromecast/browser/cast_content_browser_client.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698