OLD | NEW |
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 147 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
158 void CacheShaderInfo(int32 id, base::FilePath path) { | 158 void CacheShaderInfo(int32 id, base::FilePath path) { |
159 ShaderCacheFactory::GetInstance()->SetCacheInfo(id, path); | 159 ShaderCacheFactory::GetInstance()->SetCacheInfo(id, path); |
160 } | 160 } |
161 | 161 |
162 void RemoveShaderInfo(int32 id) { | 162 void RemoveShaderInfo(int32 id) { |
163 ShaderCacheFactory::GetInstance()->RemoveCacheInfo(id); | 163 ShaderCacheFactory::GetInstance()->RemoveCacheInfo(id); |
164 } | 164 } |
165 | 165 |
166 } // namespace | 166 } // namespace |
167 | 167 |
168 #if !defined(CHROME_MULTIPLE_DLL) | |
169 | |
170 // This class creates the IO thread for the renderer when running in | 168 // This class creates the IO thread for the renderer when running in |
171 // single-process mode. It's not used in multi-process mode. | 169 // single-process mode. It's not used in multi-process mode. |
172 class RendererMainThread : public base::Thread { | 170 class RendererMainThread : public base::Thread { |
173 public: | 171 public: |
174 explicit RendererMainThread(const std::string& channel_id) | 172 explicit RendererMainThread(const std::string& channel_id) |
175 : Thread("Chrome_InProcRendererThread"), | 173 : Thread("Chrome_InProcRendererThread"), |
176 channel_id_(channel_id) { | 174 channel_id_(channel_id) { |
177 } | 175 } |
178 | 176 |
179 virtual ~RendererMainThread() { | 177 virtual ~RendererMainThread() { |
(...skipping 23 matching lines...) Expand all Loading... |
203 SetThreadWasQuitProperly(true); | 201 SetThreadWasQuitProperly(true); |
204 } | 202 } |
205 | 203 |
206 private: | 204 private: |
207 std::string channel_id_; | 205 std::string channel_id_; |
208 scoped_ptr<RenderProcess> render_process_; | 206 scoped_ptr<RenderProcess> render_process_; |
209 | 207 |
210 DISALLOW_COPY_AND_ASSIGN(RendererMainThread); | 208 DISALLOW_COPY_AND_ASSIGN(RendererMainThread); |
211 }; | 209 }; |
212 | 210 |
213 #endif | |
214 | |
215 namespace { | 211 namespace { |
216 | 212 |
217 // Helper class that we pass to ResourceMessageFilter so that it can find the | 213 // Helper class that we pass to ResourceMessageFilter so that it can find the |
218 // right net::URLRequestContext for a request. | 214 // right net::URLRequestContext for a request. |
219 class RendererURLRequestContextSelector | 215 class RendererURLRequestContextSelector |
220 : public ResourceMessageFilter::URLRequestContextSelector { | 216 : public ResourceMessageFilter::URLRequestContextSelector { |
221 public: | 217 public: |
222 RendererURLRequestContextSelector(BrowserContext* browser_context, | 218 RendererURLRequestContextSelector(BrowserContext* browser_context, |
223 int render_child_id) | 219 int render_child_id) |
224 : request_context_(browser_context->GetRequestContextForRenderProcess( | 220 : request_context_(browser_context->GetRequestContextForRenderProcess( |
(...skipping 273 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
498 IPC::Channel::MODE_SERVER, | 494 IPC::Channel::MODE_SERVER, |
499 this, | 495 this, |
500 BrowserThread::GetMessageLoopProxyForThread( | 496 BrowserThread::GetMessageLoopProxyForThread( |
501 BrowserThread::IO).get())); | 497 BrowserThread::IO).get())); |
502 | 498 |
503 // Call the embedder first so that their IPC filters have priority. | 499 // Call the embedder first so that their IPC filters have priority. |
504 GetContentClient()->browser()->RenderProcessHostCreated(this); | 500 GetContentClient()->browser()->RenderProcessHostCreated(this); |
505 | 501 |
506 CreateMessageFilters(); | 502 CreateMessageFilters(); |
507 | 503 |
508 // Single-process mode not supported in multiple-dll mode currently. | 504 // Single-process mode not supported in split-dll mode. |
509 #if !defined(CHROME_MULTIPLE_DLL) | 505 #if !defined(CHROME_SPLIT_DLL) |
510 if (run_renderer_in_process()) { | 506 if (run_renderer_in_process()) { |
511 // Crank up a thread and run the initialization there. With the way that | 507 // Crank up a thread and run the initialization there. With the way that |
512 // messages flow between the browser and renderer, this thread is required | 508 // messages flow between the browser and renderer, this thread is required |
513 // to prevent a deadlock in single-process mode. Since the primordial | 509 // to prevent a deadlock in single-process mode. Since the primordial |
514 // thread in the renderer process runs the WebKit code and can sometimes | 510 // thread in the renderer process runs the WebKit code and can sometimes |
515 // make blocking calls to the UI thread (i.e. this thread), they need to run | 511 // make blocking calls to the UI thread (i.e. this thread), they need to run |
516 // on separate threads. | 512 // on separate threads. |
517 in_process_renderer_.reset(new RendererMainThread(channel_id)); | 513 in_process_renderer_.reset(new RendererMainThread(channel_id)); |
518 | 514 |
519 base::Thread::Options options; | 515 base::Thread::Options options; |
520 #if defined(OS_WIN) && !defined(OS_MACOSX) | 516 #if defined(OS_WIN) && !defined(OS_MACOSX) |
521 // In-process plugins require this to be a UI message loop. | 517 // In-process plugins require this to be a UI message loop. |
522 options.message_loop_type = base::MessageLoop::TYPE_UI; | 518 options.message_loop_type = base::MessageLoop::TYPE_UI; |
523 #else | 519 #else |
524 // We can't have multiple UI loops on Linux and Android, so we don't support | 520 // We can't have multiple UI loops on Linux and Android, so we don't support |
525 // in-process plugins. | 521 // in-process plugins. |
526 options.message_loop_type = base::MessageLoop::TYPE_DEFAULT; | 522 options.message_loop_type = base::MessageLoop::TYPE_DEFAULT; |
527 #endif | 523 #endif |
528 in_process_renderer_->StartWithOptions(options); | 524 in_process_renderer_->StartWithOptions(options); |
529 | 525 |
530 OnProcessLaunched(); // Fake a callback that the process is ready. | 526 OnProcessLaunched(); // Fake a callback that the process is ready. |
531 } else | 527 } else |
532 #endif // !CHROME_MULTIPLE_DLL | 528 #endif // !CHROME_SPLIT_DLL |
533 { | 529 { |
534 // Build command line for renderer. We call AppendRendererCommandLine() | 530 // Build command line for renderer. We call AppendRendererCommandLine() |
535 // first so the process type argument will appear first. | 531 // first so the process type argument will appear first. |
536 CommandLine* cmd_line = new CommandLine(renderer_path); | 532 CommandLine* cmd_line = new CommandLine(renderer_path); |
537 if (!renderer_prefix.empty()) | 533 if (!renderer_prefix.empty()) |
538 cmd_line->PrependWrapper(renderer_prefix); | 534 cmd_line->PrependWrapper(renderer_prefix); |
539 AppendRendererCommandLine(cmd_line); | 535 AppendRendererCommandLine(cmd_line); |
540 cmd_line->AppendSwitchASCII(switches::kProcessChannelID, channel_id); | 536 cmd_line->AppendSwitchASCII(switches::kProcessChannelID, channel_id); |
541 | 537 |
542 // Spawn the child process asynchronously to avoid blocking the UI thread. | 538 // Spawn the child process asynchronously to avoid blocking the UI thread. |
(...skipping 1250 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1793 // Skip widgets in other processes. | 1789 // Skip widgets in other processes. |
1794 if (widgets[i]->GetProcess()->GetID() != GetID()) | 1790 if (widgets[i]->GetProcess()->GetID() != GetID()) |
1795 continue; | 1791 continue; |
1796 | 1792 |
1797 RenderViewHost* rvh = RenderViewHost::From(widgets[i]); | 1793 RenderViewHost* rvh = RenderViewHost::From(widgets[i]); |
1798 rvh->UpdateWebkitPreferences(rvh->GetWebkitPreferences()); | 1794 rvh->UpdateWebkitPreferences(rvh->GetWebkitPreferences()); |
1799 } | 1795 } |
1800 } | 1796 } |
1801 | 1797 |
1802 } // namespace content | 1798 } // namespace content |
OLD | NEW |