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

Side by Side Diff: content/renderer/in_process_renderer_thread.cc

Issue 1900513003: Try to diagnose blink reinitialisation in WebView. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Allow InProcessRendererThread to die if BrowserMainLoop is dying, to avoid breaking tests Created 4 years, 7 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
« no previous file with comments | « content/browser/browser_main_loop.cc ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 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 #include "content/renderer/in_process_renderer_thread.h" 5 #include "content/renderer/in_process_renderer_thread.h"
6 6
7 #include "build/build_config.h" 7 #include "build/build_config.h"
8 #include "content/renderer/render_process.h" 8 #include "content/renderer/render_process.h"
9 #include "content/renderer/render_process_impl.h" 9 #include "content/renderer/render_process_impl.h"
10 #include "content/renderer/render_thread_impl.h" 10 #include "content/renderer/render_thread_impl.h"
11 11
12 #if defined(OS_ANDROID) 12 #if defined(OS_ANDROID)
13 #include "base/android/jni_android.h" 13 #include "base/android/jni_android.h"
14 #endif 14 #endif
15 15
16 namespace content { 16 namespace content {
17 17
18 #if defined(OS_ANDROID)
19 extern bool g_browser_main_loop_shutting_down;
20 #endif
21
18 InProcessRendererThread::InProcessRendererThread( 22 InProcessRendererThread::InProcessRendererThread(
19 const InProcessChildThreadParams& params) 23 const InProcessChildThreadParams& params)
20 : Thread("Chrome_InProcRendererThread"), params_(params) { 24 : Thread("Chrome_InProcRendererThread"), params_(params) {
21 } 25 }
22 26
23 InProcessRendererThread::~InProcessRendererThread() { 27 InProcessRendererThread::~InProcessRendererThread() {
28 #if defined(OS_ANDROID)
29 // Don't allow the render thread to be shut down in single process mode on
30 // Android unless the browser is shutting down.
31 // Temporary CHECK() to debug http://crbug.com/514141
32 CHECK(g_browser_main_loop_shutting_down);
33 #endif
34
24 Stop(); 35 Stop();
25 } 36 }
26 37
27 void InProcessRendererThread::Init() { 38 void InProcessRendererThread::Init() {
28 // Call AttachCurrentThreadWithName, before any other AttachCurrentThread() 39 // Call AttachCurrentThreadWithName, before any other AttachCurrentThread()
29 // calls. The latter causes Java VM to assign Thread-??? to the thread name. 40 // calls. The latter causes Java VM to assign Thread-??? to the thread name.
30 // Please note calls to AttachCurrentThreadWithName after AttachCurrentThread 41 // Please note calls to AttachCurrentThreadWithName after AttachCurrentThread
31 // will not change the thread name kept in Java VM. 42 // will not change the thread name kept in Java VM.
32 #if defined(OS_ANDROID) 43 #if defined(OS_ANDROID)
33 base::android::AttachCurrentThreadWithName(thread_name()); 44 base::android::AttachCurrentThreadWithName(thread_name());
45 // Make sure we aren't somehow reinitialising the inprocess renderer thread on
46 // Android. Temporary CHECK() to debug http://crbug.com/514141
47 CHECK(!render_process_);
34 #endif 48 #endif
35 render_process_.reset(new RenderProcessImpl()); 49 render_process_.reset(new RenderProcessImpl());
36 RenderThreadImpl::Create(params_); 50 RenderThreadImpl::Create(params_);
37 } 51 }
38 52
39 void InProcessRendererThread::CleanUp() { 53 void InProcessRendererThread::CleanUp() {
54 #if defined(OS_ANDROID)
55 // Don't allow the render thread to be shut down in single process mode on
56 // Android unless the browser is shutting down.
57 // Temporary CHECK() to debug http://crbug.com/514141
58 CHECK(g_browser_main_loop_shutting_down);
59 #endif
60
40 render_process_.reset(); 61 render_process_.reset();
41 62
42 // It's a little lame to manually set this flag. But the single process 63 // It's a little lame to manually set this flag. But the single process
43 // RendererThread will receive the WM_QUIT. We don't need to assert on 64 // RendererThread will receive the WM_QUIT. We don't need to assert on
44 // this thread, so just force the flag manually. 65 // this thread, so just force the flag manually.
45 // If we want to avoid this, we could create the InProcRendererThread 66 // If we want to avoid this, we could create the InProcRendererThread
46 // directly with _beginthreadex() rather than using the Thread class. 67 // directly with _beginthreadex() rather than using the Thread class.
47 // We used to set this flag in the Init function above. However there 68 // We used to set this flag in the Init function above. However there
48 // other threads like WebThread which are created by this thread 69 // other threads like WebThread which are created by this thread
49 // which resets this flag. Please see Thread::StartWithOptions. Setting 70 // which resets this flag. Please see Thread::StartWithOptions. Setting
50 // this flag to true in Cleanup works around these problems. 71 // this flag to true in Cleanup works around these problems.
51 SetThreadWasQuitProperly(true); 72 SetThreadWasQuitProperly(true);
52 } 73 }
53 74
54 base::Thread* CreateInProcessRendererThread( 75 base::Thread* CreateInProcessRendererThread(
55 const InProcessChildThreadParams& params) { 76 const InProcessChildThreadParams& params) {
56 return new InProcessRendererThread(params); 77 return new InProcessRendererThread(params);
57 } 78 }
58 79
59 } // namespace content 80 } // namespace content
OLDNEW
« no previous file with comments | « content/browser/browser_main_loop.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698