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