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

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

Issue 14304004: Convert a bunch of test_shell_tests to content_browsertests. These are tests that depend on loading… (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: sync Created 7 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 | Annotate | Revision Log
« no previous file with comments | « content/browser/renderer_host/render_process_host_impl.h ('k') | content/content_tests.gypi » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 126 matching lines...) Expand 10 before | Expand all | Expand 10 after
137 137
138 #include "third_party/skia/include/core/SkBitmap.h" 138 #include "third_party/skia/include/core/SkBitmap.h"
139 139
140 extern bool g_exited_main_message_loop; 140 extern bool g_exited_main_message_loop;
141 141
142 static const char* kSiteProcessMapKeyName = "content_site_process_map"; 142 static const char* kSiteProcessMapKeyName = "content_site_process_map";
143 143
144 namespace content { 144 namespace content {
145 namespace { 145 namespace {
146 146
147 base::MessageLoop* g_in_process_thread;
148
147 void CacheShaderInfo(int32 id, base::FilePath path) { 149 void CacheShaderInfo(int32 id, base::FilePath path) {
148 ShaderCacheFactory::GetInstance()->SetCacheInfo(id, path); 150 ShaderCacheFactory::GetInstance()->SetCacheInfo(id, path);
149 } 151 }
150 152
151 void RemoveShaderInfo(int32 id) { 153 void RemoveShaderInfo(int32 id) {
152 ShaderCacheFactory::GetInstance()->RemoveCacheInfo(id); 154 ShaderCacheFactory::GetInstance()->RemoveCacheInfo(id);
153 } 155 }
154 156
155 } // namespace 157 } // namespace
156 158
157 // This class creates the IO thread for the renderer when running in 159 // This class creates the IO thread for the renderer when running in
158 // single-process mode. It's not used in multi-process mode. 160 // single-process mode. It's not used in multi-process mode.
159 class RendererMainThread : public base::Thread { 161 class RendererMainThread : public base::Thread {
160 public: 162 public:
161 explicit RendererMainThread(const std::string& channel_id) 163 explicit RendererMainThread(const std::string& channel_id)
162 : Thread("Chrome_InProcRendererThread"), 164 : Thread("Chrome_InProcRendererThread"),
163 channel_id_(channel_id) { 165 channel_id_(channel_id) {
164 } 166 }
165 167
166 virtual ~RendererMainThread() { 168 virtual ~RendererMainThread() {
167 Stop(); 169 Stop();
168 } 170 }
169 171
170 protected: 172 protected:
171 virtual void Init() OVERRIDE { 173 virtual void Init() OVERRIDE {
172 render_process_.reset(new RenderProcessImpl()); 174 render_process_.reset(new RenderProcessImpl());
173 new RenderThreadImpl(channel_id_); 175 new RenderThreadImpl(channel_id_);
176 g_in_process_thread = message_loop();
174 } 177 }
175 178
176 virtual void CleanUp() OVERRIDE { 179 virtual void CleanUp() OVERRIDE {
180 g_in_process_thread = NULL;
177 render_process_.reset(); 181 render_process_.reset();
178 182
179 // It's a little lame to manually set this flag. But the single process 183 // It's a little lame to manually set this flag. But the single process
180 // RendererThread will receive the WM_QUIT. We don't need to assert on 184 // RendererThread will receive the WM_QUIT. We don't need to assert on
181 // this thread, so just force the flag manually. 185 // this thread, so just force the flag manually.
182 // If we want to avoid this, we could create the InProcRendererThread 186 // If we want to avoid this, we could create the InProcRendererThread
183 // directly with _beginthreadex() rather than using the Thread class. 187 // directly with _beginthreadex() rather than using the Thread class.
184 // We used to set this flag in the Init function above. However there 188 // We used to set this flag in the Init function above. However there
185 // other threads like WebThread which are created by this thread 189 // other threads like WebThread which are created by this thread
186 // which resets this flag. Please see Thread::StartWithOptions. Setting 190 // which resets this flag. Please see Thread::StartWithOptions. Setting
(...skipping 303 matching lines...) Expand 10 before | Expand all | Expand 10 after
490 if (run_renderer_in_process()) { 494 if (run_renderer_in_process()) {
491 // Crank up a thread and run the initialization there. With the way that 495 // Crank up a thread and run the initialization there. With the way that
492 // messages flow between the browser and renderer, this thread is required 496 // messages flow between the browser and renderer, this thread is required
493 // to prevent a deadlock in single-process mode. Since the primordial 497 // to prevent a deadlock in single-process mode. Since the primordial
494 // thread in the renderer process runs the WebKit code and can sometimes 498 // thread in the renderer process runs the WebKit code and can sometimes
495 // make blocking calls to the UI thread (i.e. this thread), they need to run 499 // make blocking calls to the UI thread (i.e. this thread), they need to run
496 // on separate threads. 500 // on separate threads.
497 in_process_renderer_.reset(new RendererMainThread(channel_id)); 501 in_process_renderer_.reset(new RendererMainThread(channel_id));
498 502
499 base::Thread::Options options; 503 base::Thread::Options options;
500 #if !defined(TOOLKIT_GTK) && !defined(OS_ANDROID) 504 #if defined(OS_WIN) && !defined(OS_MACOSX)
501 // In-process plugins require this to be a UI message loop. 505 // In-process plugins require this to be a UI message loop.
502 options.message_loop_type = MessageLoop::TYPE_UI; 506 options.message_loop_type = MessageLoop::TYPE_UI;
503 #else 507 #else
504 // We can't have multiple UI loops on GTK and Android, so we don't support 508 // We can't have multiple UI loops on Linux and Android, so we don't support
505 // in-process plugins. 509 // in-process plugins.
506 options.message_loop_type = MessageLoop::TYPE_DEFAULT; 510 options.message_loop_type = MessageLoop::TYPE_DEFAULT;
507 #endif 511 #endif
508 in_process_renderer_->StartWithOptions(options); 512 in_process_renderer_->StartWithOptions(options);
509 513
510 OnProcessLaunched(); // Fake a callback that the process is ready. 514 OnProcessLaunched(); // Fake a callback that the process is ready.
511 } else { 515 } else {
512 // Build command line for renderer. We call AppendRendererCommandLine() 516 // Build command line for renderer. We call AppendRendererCommandLine()
513 // first so the process type argument will appear first. 517 // first so the process type argument will appear first.
514 CommandLine* cmd_line = new CommandLine(renderer_path); 518 CommandLine* cmd_line = new CommandLine(renderer_path);
(...skipping 1017 matching lines...) Expand 10 before | Expand all | Expand 10 after
1532 1536
1533 // Only register valid, non-empty sites. Empty or invalid sites will not 1537 // Only register valid, non-empty sites. Empty or invalid sites will not
1534 // use process-per-site mode. We cannot check whether the process has 1538 // use process-per-site mode. We cannot check whether the process has
1535 // appropriate bindings here, because the bindings have not yet been granted. 1539 // appropriate bindings here, because the bindings have not yet been granted.
1536 std::string site = SiteInstance::GetSiteForURL(browser_context, url) 1540 std::string site = SiteInstance::GetSiteForURL(browser_context, url)
1537 .possibly_invalid_spec(); 1541 .possibly_invalid_spec();
1538 if (!site.empty()) 1542 if (!site.empty())
1539 map->RegisterProcess(site, process); 1543 map->RegisterProcess(site, process);
1540 } 1544 }
1541 1545
1546 base::MessageLoop*
1547 RenderProcessHostImpl::GetInProcessRendererThreadForTesting() {
1548 return g_in_process_thread;
1549 }
1550
1542 void RenderProcessHostImpl::ProcessDied(bool already_dead) { 1551 void RenderProcessHostImpl::ProcessDied(bool already_dead) {
1543 // Our child process has died. If we didn't expect it, it's a crash. 1552 // Our child process has died. If we didn't expect it, it's a crash.
1544 // In any case, we need to let everyone know it's gone. 1553 // In any case, we need to let everyone know it's gone.
1545 // The OnChannelError notification can fire multiple times due to nested sync 1554 // The OnChannelError notification can fire multiple times due to nested sync
1546 // calls to a renderer. If we don't have a valid channel here it means we 1555 // calls to a renderer. If we don't have a valid channel here it means we
1547 // already handled the error. 1556 // already handled the error.
1548 1557
1549 // child_process_launcher_ can be NULL in single process mode or if fast 1558 // child_process_launcher_ can be NULL in single process mode or if fast
1550 // termination happened. 1559 // termination happened.
1551 int exit_code = 0; 1560 int exit_code = 0;
(...skipping 176 matching lines...) Expand 10 before | Expand all | Expand 10 after
1728 TRACE_EVENT0("renderer_host", 1737 TRACE_EVENT0("renderer_host",
1729 "RenderWidgetHostImpl::OnCompositorSurfaceBuffersSwappedNoHost"); 1738 "RenderWidgetHostImpl::OnCompositorSurfaceBuffersSwappedNoHost");
1730 AcceleratedSurfaceMsg_BufferPresented_Params ack_params; 1739 AcceleratedSurfaceMsg_BufferPresented_Params ack_params;
1731 ack_params.sync_point = 0; 1740 ack_params.sync_point = 0;
1732 RenderWidgetHostImpl::AcknowledgeBufferPresent(route_id, 1741 RenderWidgetHostImpl::AcknowledgeBufferPresent(route_id,
1733 gpu_process_host_id, 1742 gpu_process_host_id,
1734 ack_params); 1743 ack_params);
1735 } 1744 }
1736 1745
1737 } // namespace content 1746 } // namespace content
OLDNEW
« no previous file with comments | « content/browser/renderer_host/render_process_host_impl.h ('k') | content/content_tests.gypi » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698