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

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: merges PostTask 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::PostTaskAndReplyWithResult(
87 content::BrowserThread::IO, FROM_HERE,
88 base::Bind(&net::URLRequestContextGetter::GetURLRequestContext,
89 base::Unretained(
90 url_request_context_factory_->GetSystemGetter())),
91 base::Bind(&CastContentBrowserClient::AddNetworkHintsMessageFilter,
92 base::Unretained(this), host->GetID()));
93
87 auto extra_filters = PlatformGetBrowserMessageFilters(); 94 auto extra_filters = PlatformGetBrowserMessageFilters();
88 for (auto const& filter : extra_filters) { 95 for (auto const& filter : extra_filters) {
89 host->AddFilter(filter.get()); 96 host->AddFilter(filter.get());
90 } 97 }
91 } 98 }
92 99
100 void CastContentBrowserClient::AddNetworkHintsMessageFilter(
101 int render_process_id, net::URLRequestContext* context) {
102 DCHECK_CURRENTLY_ON(content::BrowserThread::UI);
103
104 content::RenderProcessHost* host =
105 content::RenderProcessHost::FromID(render_process_id);
106 if (!host)
107 return;
108
109 scoped_refptr<content::BrowserMessageFilter> network_hints_message_filter(
110 new network_hints::NetworkHintsMessageFilter(
111 url_request_context_factory_->host_resolver()));
112 host->AddFilter(network_hints_message_filter.get());
113 }
114
93 net::URLRequestContextGetter* CastContentBrowserClient::CreateRequestContext( 115 net::URLRequestContextGetter* CastContentBrowserClient::CreateRequestContext(
94 content::BrowserContext* browser_context, 116 content::BrowserContext* browser_context,
95 content::ProtocolHandlerMap* protocol_handlers, 117 content::ProtocolHandlerMap* protocol_handlers,
96 content::URLRequestInterceptorScopedVector request_interceptors) { 118 content::URLRequestInterceptorScopedVector request_interceptors) {
97 return url_request_context_factory_->CreateMainGetter( 119 return url_request_context_factory_->CreateMainGetter(
98 browser_context, 120 browser_context,
99 protocol_handlers, 121 protocol_handlers,
100 request_interceptors.Pass()); 122 request_interceptors.Pass());
101 } 123 }
102 124
(...skipping 295 matching lines...) Expand 10 before | Expand all | Expand 10 after
398 process_type, dumps_path, false /* upload */); 420 process_type, dumps_path, false /* upload */);
399 // StartUploaderThread() even though upload is diferred. 421 // StartUploaderThread() even though upload is diferred.
400 // Breakpad-related memory is freed in the uploader thread. 422 // Breakpad-related memory is freed in the uploader thread.
401 crash_handler->StartUploaderThread(); 423 crash_handler->StartUploaderThread();
402 return crash_handler; 424 return crash_handler;
403 } 425 }
404 #endif // !defined(OS_ANDROID) 426 #endif // !defined(OS_ANDROID)
405 427
406 } // namespace shell 428 } // namespace shell
407 } // namespace chromecast 429 } // 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