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

Side by Side Diff: content/browser/renderer_host/render_process_host_impl.cc

Issue 23851010: Modify ResourceMessageFilter so that it can support attaching to PluginProcessHost. (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: sync Created 7 years, 3 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 | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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 // Represents the browser side of the browser <--> renderer communication 5 // Represents the browser side of the browser <--> renderer communication
6 // channel. There will be one RenderProcessHost per renderer process. 6 // channel. There will be one RenderProcessHost per renderer process.
7 7
8 #include "content/browser/renderer_host/render_process_host_impl.h" 8 #include "content/browser/renderer_host/render_process_host_impl.h"
9 9
10 #include <algorithm> 10 #include <algorithm>
(...skipping 146 matching lines...) Expand 10 before | Expand all | Expand 10 after
157 namespace { 157 namespace {
158 158
159 void CacheShaderInfo(int32 id, base::FilePath path) { 159 void CacheShaderInfo(int32 id, base::FilePath path) {
160 ShaderCacheFactory::GetInstance()->SetCacheInfo(id, path); 160 ShaderCacheFactory::GetInstance()->SetCacheInfo(id, path);
161 } 161 }
162 162
163 void RemoveShaderInfo(int32 id) { 163 void RemoveShaderInfo(int32 id) {
164 ShaderCacheFactory::GetInstance()->RemoveCacheInfo(id); 164 ShaderCacheFactory::GetInstance()->RemoveCacheInfo(id);
165 } 165 }
166 166
167 // Helper class that we pass to ResourceMessageFilter so that it can find the 167 net::URLRequestContext* GetRequestContext(
168 // right net::URLRequestContext for a request. 168 scoped_refptr<net::URLRequestContextGetter> request_context,
169 class RendererURLRequestContextSelector 169 scoped_refptr<net::URLRequestContextGetter> media_request_context,
170 : public ResourceMessageFilter::URLRequestContextSelector { 170 ResourceType::Type resource_type) {
171 public: 171 // If the request has resource type of ResourceType::MEDIA, we use a request
172 RendererURLRequestContextSelector(BrowserContext* browser_context, 172 // context specific to media for handling it because these resources have
173 int render_child_id) 173 // specific needs for caching.
174 : request_context_(browser_context->GetRequestContextForRenderProcess( 174 if (resource_type == ResourceType::MEDIA)
175 render_child_id)), 175 return media_request_context->GetURLRequestContext();
176 media_request_context_( 176 return request_context->GetURLRequestContext();
177 browser_context->GetMediaRequestContextForRenderProcess( 177 }
178 render_child_id)) {
179 }
180 178
181 virtual net::URLRequestContext* GetRequestContext( 179 void GetContexts(
182 ResourceType::Type resource_type) OVERRIDE { 180 ResourceContext* resource_context,
183 net::URLRequestContextGetter* request_context = request_context_.get(); 181 scoped_refptr<net::URLRequestContextGetter> request_context,
184 // If the request has resource type of ResourceType::MEDIA, we use a request 182 scoped_refptr<net::URLRequestContextGetter> media_request_context,
185 // context specific to media for handling it because these resources have 183 const ResourceHostMsg_Request& request,
186 // specific needs for caching. 184 ResourceContext** resource_context_out,
187 if (resource_type == ResourceType::MEDIA) 185 net::URLRequestContext** request_context_out) {
188 request_context = media_request_context_.get(); 186 *resource_context_out = resource_context;
189 return request_context->GetURLRequestContext(); 187 *request_context_out =
190 } 188 GetRequestContext(request_context, media_request_context,
191 189 request.resource_type);
192 private: 190 }
193 virtual ~RendererURLRequestContextSelector() {}
194
195 scoped_refptr<net::URLRequestContextGetter> request_context_;
196 scoped_refptr<net::URLRequestContextGetter> media_request_context_;
197 };
198 191
199 // the global list of all renderer processes 192 // the global list of all renderer processes
200 base::LazyInstance<IDMap<RenderProcessHost> >::Leaky 193 base::LazyInstance<IDMap<RenderProcessHost> >::Leaky
201 g_all_hosts = LAZY_INSTANCE_INITIALIZER; 194 g_all_hosts = LAZY_INSTANCE_INITIALIZER;
202 195
203 base::LazyInstance<scoped_refptr<BrowserPluginGeolocationPermissionContext> > 196 base::LazyInstance<scoped_refptr<BrowserPluginGeolocationPermissionContext> >
204 g_browser_plugin_geolocation_context = LAZY_INSTANCE_INITIALIZER; 197 g_browser_plugin_geolocation_context = LAZY_INSTANCE_INITIALIZER;
205 198
206 // Map of site to process, to ensure we only have one RenderProcessHost per 199 // Map of site to process, to ensure we only have one RenderProcessHost per
207 // site in process-per-site mode. Each map is specific to a BrowserContext. 200 // site in process-per-site mode. Each map is specific to a BrowserContext.
(...skipping 348 matching lines...) Expand 10 before | Expand all | Expand 10 after
556 GetBrowserContext(), 549 GetBrowserContext(),
557 GetBrowserContext()->GetRequestContextForRenderProcess(GetID()), 550 GetBrowserContext()->GetRequestContextForRenderProcess(GetID()),
558 widget_helper_.get(), 551 widget_helper_.get(),
559 audio_manager, 552 audio_manager,
560 media_internals, 553 media_internals,
561 storage_partition_impl_->GetDOMStorageContext())); 554 storage_partition_impl_->GetDOMStorageContext()));
562 channel_->AddFilter(render_message_filter.get()); 555 channel_->AddFilter(render_message_filter.get());
563 BrowserContext* browser_context = GetBrowserContext(); 556 BrowserContext* browser_context = GetBrowserContext();
564 ResourceContext* resource_context = browser_context->GetResourceContext(); 557 ResourceContext* resource_context = browser_context->GetResourceContext();
565 558
559 scoped_refptr<net::URLRequestContextGetter> request_context(
560 browser_context->GetRequestContextForRenderProcess(GetID()));
561 scoped_refptr<net::URLRequestContextGetter> media_request_context(
562 browser_context->GetMediaRequestContextForRenderProcess(GetID()));
563
564 ResourceMessageFilter::GetContextsCallback get_contexts_callback(
565 base::Bind(&GetContexts, browser_context->GetResourceContext(),
566 request_context, media_request_context));
567
566 ResourceMessageFilter* resource_message_filter = new ResourceMessageFilter( 568 ResourceMessageFilter* resource_message_filter = new ResourceMessageFilter(
567 GetID(), PROCESS_TYPE_RENDERER, resource_context, 569 GetID(), PROCESS_TYPE_RENDERER,
568 storage_partition_impl_->GetAppCacheService(), 570 storage_partition_impl_->GetAppCacheService(),
569 ChromeBlobStorageContext::GetFor(browser_context), 571 ChromeBlobStorageContext::GetFor(browser_context),
570 storage_partition_impl_->GetFileSystemContext(), 572 storage_partition_impl_->GetFileSystemContext(),
571 new RendererURLRequestContextSelector(browser_context, GetID())); 573 get_contexts_callback);
572 574
573 channel_->AddFilter(resource_message_filter); 575 channel_->AddFilter(resource_message_filter);
574 MediaStreamManager* media_stream_manager = 576 MediaStreamManager* media_stream_manager =
575 BrowserMainLoop::GetInstance()->media_stream_manager(); 577 BrowserMainLoop::GetInstance()->media_stream_manager();
576 channel_->AddFilter(new AudioInputRendererHost( 578 channel_->AddFilter(new AudioInputRendererHost(
577 audio_manager, 579 audio_manager,
578 media_stream_manager, 580 media_stream_manager,
579 BrowserMainLoop::GetInstance()->audio_mirroring_manager(), 581 BrowserMainLoop::GetInstance()->audio_mirroring_manager(),
580 BrowserMainLoop::GetInstance()->user_input_monitor())); 582 BrowserMainLoop::GetInstance()->user_input_monitor()));
581 channel_->AddFilter(new AudioRendererHost( 583 channel_->AddFilter(new AudioRendererHost(
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after
640 channel_->AddFilter(new FileUtilitiesMessageFilter(GetID())); 642 channel_->AddFilter(new FileUtilitiesMessageFilter(GetID()));
641 channel_->AddFilter(new MimeRegistryMessageFilter()); 643 channel_->AddFilter(new MimeRegistryMessageFilter());
642 channel_->AddFilter(new DatabaseMessageFilter( 644 channel_->AddFilter(new DatabaseMessageFilter(
643 storage_partition_impl_->GetDatabaseTracker())); 645 storage_partition_impl_->GetDatabaseTracker()));
644 #if defined(OS_MACOSX) 646 #if defined(OS_MACOSX)
645 channel_->AddFilter(new TextInputClientMessageFilter(GetID())); 647 channel_->AddFilter(new TextInputClientMessageFilter(GetID()));
646 #elif defined(OS_WIN) 648 #elif defined(OS_WIN)
647 channel_->AddFilter(new FontCacheDispatcher()); 649 channel_->AddFilter(new FontCacheDispatcher());
648 #endif 650 #endif
649 651
652 SocketStreamDispatcherHost::GetRequestContextCallback
653 request_context_callback(
654 base::Bind(&GetRequestContext, request_context,
655 media_request_context));
656
650 SocketStreamDispatcherHost* socket_stream_dispatcher_host = 657 SocketStreamDispatcherHost* socket_stream_dispatcher_host =
651 new SocketStreamDispatcherHost(GetID(), 658 new SocketStreamDispatcherHost(
652 new RendererURLRequestContextSelector(browser_context, GetID()), 659 GetID(), request_context_callback, resource_context);
653 resource_context);
654 channel_->AddFilter(socket_stream_dispatcher_host); 660 channel_->AddFilter(socket_stream_dispatcher_host);
655 661
656 channel_->AddFilter(new WorkerMessageFilter( 662 channel_->AddFilter(new WorkerMessageFilter(
657 GetID(), 663 GetID(),
658 resource_context, 664 resource_context,
659 WorkerStoragePartition( 665 WorkerStoragePartition(
660 storage_partition_impl_->GetURLRequestContext(), 666 storage_partition_impl_->GetURLRequestContext(),
661 storage_partition_impl_->GetMediaURLRequestContext(), 667 storage_partition_impl_->GetMediaURLRequestContext(),
662 storage_partition_impl_->GetAppCacheService(), 668 storage_partition_impl_->GetAppCacheService(),
663 storage_partition_impl_->GetQuotaManager(), 669 storage_partition_impl_->GetQuotaManager(),
(...skipping 171 matching lines...) Expand 10 before | Expand all | Expand 10 after
835 const CommandLine& browser_cmd, 841 const CommandLine& browser_cmd,
836 CommandLine* renderer_cmd) const { 842 CommandLine* renderer_cmd) const {
837 // Propagate the following switches to the renderer command line (along 843 // Propagate the following switches to the renderer command line (along
838 // with any associated values) if present in the browser command line. 844 // with any associated values) if present in the browser command line.
839 static const char* const kSwitchNames[] = { 845 static const char* const kSwitchNames[] = {
840 switches::kAllowFiltersOverIPC, 846 switches::kAllowFiltersOverIPC,
841 switches::kAudioBufferSize, 847 switches::kAudioBufferSize,
842 switches::kAuditAllHandles, 848 switches::kAuditAllHandles,
843 switches::kAuditHandles, 849 switches::kAuditHandles,
844 switches::kBlockCrossSiteDocuments, 850 switches::kBlockCrossSiteDocuments,
851 switches::kDirectNPAPIRequests,
845 switches::kDisable3DAPIs, 852 switches::kDisable3DAPIs,
846 switches::kDisableAcceleratedCompositing, 853 switches::kDisableAcceleratedCompositing,
847 switches::kDisableAcceleratedVideoDecode, 854 switches::kDisableAcceleratedVideoDecode,
848 switches::kDisableApplicationCache, 855 switches::kDisableApplicationCache,
849 switches::kDisableAudio, 856 switches::kDisableAudio,
850 switches::kDisableBreakpad, 857 switches::kDisableBreakpad,
851 switches::kDisableDatabases, 858 switches::kDisableDatabases,
852 switches::kDisableDelegatedRenderer, 859 switches::kDisableDelegatedRenderer,
853 switches::kDisableDesktopNotifications, 860 switches::kDisableDesktopNotifications,
854 switches::kDisableDeviceOrientation, 861 switches::kDisableDeviceOrientation,
(...skipping 914 matching lines...) Expand 10 before | Expand all | Expand 10 after
1769 // Skip widgets in other processes. 1776 // Skip widgets in other processes.
1770 if (widgets[i]->GetProcess()->GetID() != GetID()) 1777 if (widgets[i]->GetProcess()->GetID() != GetID())
1771 continue; 1778 continue;
1772 1779
1773 RenderViewHost* rvh = RenderViewHost::From(widgets[i]); 1780 RenderViewHost* rvh = RenderViewHost::From(widgets[i]);
1774 rvh->UpdateWebkitPreferences(rvh->GetWebkitPreferences()); 1781 rvh->UpdateWebkitPreferences(rvh->GetWebkitPreferences());
1775 } 1782 }
1776 } 1783 }
1777 1784
1778 } // namespace content 1785 } // namespace content
OLDNEW
« no previous file with comments | « content/browser/loader/sync_resource_handler.cc ('k') | content/browser/renderer_host/socket_stream_dispatcher_host.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698