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

Side by Side 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 unified diff | Download patch
« no previous file with comments | « chromecast/browser/cast_content_browser_client.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "chromecast/browser/cast_content_browser_client.h" 5 #include "chromecast/browser/cast_content_browser_client.h"
6 6
7 #include <string> 7 #include <string>
8 8
9 #include "base/base_switches.h" 9 #include "base/base_switches.h"
10 #include "base/command_line.h" 10 #include "base/command_line.h"
(...skipping 22 matching lines...) Expand all
33 #include "content/public/browser/client_certificate_delegate.h" 33 #include "content/public/browser/client_certificate_delegate.h"
34 #include "content/public/browser/render_process_host.h" 34 #include "content/public/browser/render_process_host.h"
35 #include "content/public/browser/resource_dispatcher_host.h" 35 #include "content/public/browser/resource_dispatcher_host.h"
36 #include "content/public/browser/web_contents.h" 36 #include "content/public/browser/web_contents.h"
37 #include "content/public/common/content_descriptors.h" 37 #include "content/public/common/content_descriptors.h"
38 #include "content/public/common/content_switches.h" 38 #include "content/public/common/content_switches.h"
39 #include "content/public/common/url_constants.h" 39 #include "content/public/common/url_constants.h"
40 #include "content/public/common/web_preferences.h" 40 #include "content/public/common/web_preferences.h"
41 #include "gin/v8_initializer.h" 41 #include "gin/v8_initializer.h"
42 #include "net/ssl/ssl_cert_request_info.h" 42 #include "net/ssl/ssl_cert_request_info.h"
43 #include "net/url_request/url_request_context_getter.h"
43 #include "ui/gl/gl_switches.h" 44 #include "ui/gl/gl_switches.h"
44 45
45 #if defined(OS_ANDROID) 46 #if defined(OS_ANDROID)
46 #include "chromecast/browser/android/external_video_surface_container_impl.h" 47 #include "chromecast/browser/android/external_video_surface_container_impl.h"
47 #endif // defined(OS_ANDROID) 48 #endif // defined(OS_ANDROID)
48 49
49 #if defined(OS_ANDROID) 50 #if defined(OS_ANDROID)
50 #include "components/crash/browser/crash_dump_manager_android.h" 51 #include "components/crash/browser/crash_dump_manager_android.h"
51 #endif // defined(OS_ANDROID) 52 #endif // defined(OS_ANDROID)
52 53
(...skipping 14 matching lines...) Expand all
67 } 68 }
68 69
69 content::BrowserMainParts* CastContentBrowserClient::CreateBrowserMainParts( 70 content::BrowserMainParts* CastContentBrowserClient::CreateBrowserMainParts(
70 const content::MainFunctionParams& parameters) { 71 const content::MainFunctionParams& parameters) {
71 return new CastBrowserMainParts(parameters, 72 return new CastBrowserMainParts(parameters,
72 url_request_context_factory_.get()); 73 url_request_context_factory_.get());
73 } 74 }
74 75
75 void CastContentBrowserClient::RenderProcessWillLaunch( 76 void CastContentBrowserClient::RenderProcessWillLaunch(
76 content::RenderProcessHost* host) { 77 content::RenderProcessHost* host) {
77 scoped_refptr<content::BrowserMessageFilter> network_hints_message_filter(
78 new network_hints::NetworkHintsMessageFilter(
79 url_request_context_factory_->host_resolver()));
80 host->AddFilter(network_hints_message_filter.get());
81 #if !defined(OS_ANDROID) 78 #if !defined(OS_ANDROID)
82 scoped_refptr<media::CmaMessageFilterHost> cma_message_filter( 79 scoped_refptr<media::CmaMessageFilterHost> cma_message_filter(
83 new media::CmaMessageFilterHost(host->GetID())); 80 new media::CmaMessageFilterHost(host->GetID()));
84 host->AddFilter(cma_message_filter.get()); 81 host->AddFilter(cma_message_filter.get());
85 #endif // !defined(OS_ANDROID) 82 #endif // !defined(OS_ANDROID)
86 83
84 // Forcibly trigger I/O-thread URLRequestContext initialization before
85 // getting HostResolver.
86 content::BrowserThread::PostTask(
87 content::BrowserThread::IO,
88 FROM_HERE,
89 base::Bind(base::IgnoreResult(
90 &net::URLRequestContextGetter::GetURLRequestContext),
91 base::Unretained(
92 url_request_context_factory_->GetSystemGetter())));
93 content::BrowserThread::PostTaskAndReplyWithResult(
94 content::BrowserThread::IO, FROM_HERE,
95 base::Bind(&URLRequestContextFactory::host_resolver,
96 base::Unretained(url_request_context_factory_.get())),
97 base::Bind(&CastContentBrowserClient::AddExtraFilter,
98 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.
99
87 auto extra_filters = PlatformGetBrowserMessageFilters(); 100 auto extra_filters = PlatformGetBrowserMessageFilters();
88 for (auto const& filter : extra_filters) { 101 for (auto const& filter : extra_filters) {
89 host->AddFilter(filter.get()); 102 host->AddFilter(filter.get());
90 } 103 }
91 } 104 }
92 105
106 void CastContentBrowserClient::AddExtraFilter(
107 int render_process_id, net::HostResolver* host_resolver) {
108 DCHECK_CURRENTLY_ON(content::BrowserThread::UI);
109
110 content::RenderProcessHost* host =
111 content::RenderProcessHost::FromID(render_process_id);
112 if (!host)
113 return;
114
115 scoped_refptr<content::BrowserMessageFilter> network_hints_message_filter(
116 new network_hints::NetworkHintsMessageFilter(host_resolver));
117 host->AddFilter(network_hints_message_filter.get());
118 }
119
93 net::URLRequestContextGetter* CastContentBrowserClient::CreateRequestContext( 120 net::URLRequestContextGetter* CastContentBrowserClient::CreateRequestContext(
94 content::BrowserContext* browser_context, 121 content::BrowserContext* browser_context,
95 content::ProtocolHandlerMap* protocol_handlers, 122 content::ProtocolHandlerMap* protocol_handlers,
96 content::URLRequestInterceptorScopedVector request_interceptors) { 123 content::URLRequestInterceptorScopedVector request_interceptors) {
97 return url_request_context_factory_->CreateMainGetter( 124 return url_request_context_factory_->CreateMainGetter(
98 browser_context, 125 browser_context,
99 protocol_handlers, 126 protocol_handlers,
100 request_interceptors.Pass()); 127 request_interceptors.Pass());
101 } 128 }
102 129
(...skipping 295 matching lines...) Expand 10 before | Expand all | Expand 10 after
398 process_type, dumps_path, false /* upload */); 425 process_type, dumps_path, false /* upload */);
399 // StartUploaderThread() even though upload is diferred. 426 // StartUploaderThread() even though upload is diferred.
400 // Breakpad-related memory is freed in the uploader thread. 427 // Breakpad-related memory is freed in the uploader thread.
401 crash_handler->StartUploaderThread(); 428 crash_handler->StartUploaderThread();
402 return crash_handler; 429 return crash_handler;
403 } 430 }
404 #endif // !defined(OS_ANDROID) 431 #endif // !defined(OS_ANDROID)
405 432
406 } // namespace shell 433 } // namespace shell
407 } // namespace chromecast 434 } // namespace chromecast
OLDNEW
« 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