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