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

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: 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 21 matching lines...) Expand all
32 #include "content/public/browser/certificate_request_result_type.h" 32 #include "content/public/browser/certificate_request_result_type.h"
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 "media/base/bind_to_current_loop.h"
42 #include "net/ssl/ssl_cert_request_info.h" 43 #include "net/ssl/ssl_cert_request_info.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)
(...skipping 15 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 content::BrowserThread::PostTaskAndReplyWithResult(
85 content::BrowserThread::IO, FROM_HERE,
86 base::Bind(&URLRequestContextFactory::host_resolver,
87 base::Unretained(url_request_context_factory_.get())),
88 base::Bind(&CastContentBrowserClient::AddExtraFilter,
89 base::Unretained(this), host->GetID()));
byungchul 2015/04/17 00:22:20 It changes the order of message filter. Is it okay
gunsch 2015/04/17 01:06:27 Changing order is okay. Order was not so important
90
87 auto extra_filters = PlatformGetBrowserMessageFilters(); 91 auto extra_filters = PlatformGetBrowserMessageFilters();
88 for (auto const& filter : extra_filters) { 92 for (auto const& filter : extra_filters) {
89 host->AddFilter(filter.get()); 93 host->AddFilter(filter.get());
90 } 94 }
91 } 95 }
92 96
97 void CastContentBrowserClient::AddExtraFilter(
98 int render_process_id, net::HostResolver* host_resolver) {
99 DCHECK_CURRENTLY_ON(content::BrowserThread::UI);
100
101 content::RenderProcessHost* host =
102 content::RenderProcessHost::FromID(render_process_id);
103 if (!host)
104 return;
105
106 scoped_refptr<content::BrowserMessageFilter> network_hints_message_filter(
107 new network_hints::NetworkHintsMessageFilter(host_resolver));
108 host->AddFilter(network_hints_message_filter.get());
109 }
110
93 net::URLRequestContextGetter* CastContentBrowserClient::CreateRequestContext( 111 net::URLRequestContextGetter* CastContentBrowserClient::CreateRequestContext(
94 content::BrowserContext* browser_context, 112 content::BrowserContext* browser_context,
95 content::ProtocolHandlerMap* protocol_handlers, 113 content::ProtocolHandlerMap* protocol_handlers,
96 content::URLRequestInterceptorScopedVector request_interceptors) { 114 content::URLRequestInterceptorScopedVector request_interceptors) {
97 return url_request_context_factory_->CreateMainGetter( 115 return url_request_context_factory_->CreateMainGetter(
98 browser_context, 116 browser_context,
99 protocol_handlers, 117 protocol_handlers,
100 request_interceptors.Pass()); 118 request_interceptors.Pass());
101 } 119 }
102 120
(...skipping 295 matching lines...) Expand 10 before | Expand all | Expand 10 after
398 process_type, dumps_path, false /* upload */); 416 process_type, dumps_path, false /* upload */);
399 // StartUploaderThread() even though upload is diferred. 417 // StartUploaderThread() even though upload is diferred.
400 // Breakpad-related memory is freed in the uploader thread. 418 // Breakpad-related memory is freed in the uploader thread.
401 crash_handler->StartUploaderThread(); 419 crash_handler->StartUploaderThread();
402 return crash_handler; 420 return crash_handler;
403 } 421 }
404 #endif // !defined(OS_ANDROID) 422 #endif // !defined(OS_ANDROID)
405 423
406 } // namespace shell 424 } // namespace shell
407 } // namespace chromecast 425 } // 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