OLD | NEW |
1 // Copyright (c) 2006-2008 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2006-2008 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 "chrome/browser/renderer_host/browser_render_process_host.h" | 8 #include "chrome/browser/renderer_host/browser_render_process_host.h" |
9 | 9 |
10 #include "build/build_config.h" | 10 #include "build/build_config.h" |
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
64 #include "chrome/common/temp_scaffolding_stubs.h" | 64 #include "chrome/common/temp_scaffolding_stubs.h" |
65 #endif | 65 #endif |
66 | 66 |
67 #include "skia/include/SkBitmap.h" | 67 #include "skia/include/SkBitmap.h" |
68 | 68 |
69 | 69 |
70 namespace { | 70 namespace { |
71 | 71 |
72 // ---------------------------------------------------------------------------- | 72 // ---------------------------------------------------------------------------- |
73 | 73 |
| 74 // This class creates the IO thread for the renderer when running in |
| 75 // single-process mode. It's not used in multi-process mode. |
74 class RendererMainThread : public base::Thread { | 76 class RendererMainThread : public base::Thread { |
75 public: | 77 public: |
76 explicit RendererMainThread(const std::wstring& channel_id) | 78 explicit RendererMainThread(const std::wstring& channel_id) |
77 : base::Thread("Chrome_InProcRendererThread"), | 79 : base::Thread("Chrome_InProcRendererThread"), |
78 channel_id_(channel_id) { | 80 channel_id_(channel_id), |
| 81 render_process_(NULL) { |
79 } | 82 } |
80 | 83 |
81 protected: | 84 protected: |
82 virtual void Init() { | 85 virtual void Init() { |
83 #if defined(OS_WIN) | 86 #if defined(OS_WIN) |
84 CoInitialize(NULL); | 87 CoInitialize(NULL); |
85 #endif | 88 #endif |
86 | 89 |
87 render_process_.reset(new RenderProcess(channel_id_)); | 90 render_process_ = new RenderProcess(channel_id_); |
88 // It's a little lame to manually set this flag. But the single process | 91 // It's a little lame to manually set this flag. But the single process |
89 // RendererThread will receive the WM_QUIT. We don't need to assert on | 92 // RendererThread will receive the WM_QUIT. We don't need to assert on |
90 // this thread, so just force the flag manually. | 93 // this thread, so just force the flag manually. |
91 // If we want to avoid this, we could create the InProcRendererThread | 94 // If we want to avoid this, we could create the InProcRendererThread |
92 // directly with _beginthreadex() rather than using the Thread class. | 95 // directly with _beginthreadex() rather than using the Thread class. |
93 base::Thread::SetThreadWasQuitProperly(true); | 96 base::Thread::SetThreadWasQuitProperly(true); |
94 } | 97 } |
95 | 98 |
96 virtual void CleanUp() { | 99 virtual void CleanUp() { |
97 render_process_.reset(); | 100 delete render_process_; |
98 | 101 |
99 #if defined(OS_WIN) | 102 #if defined(OS_WIN) |
100 CoUninitialize(); | 103 CoUninitialize(); |
101 #endif | 104 #endif |
102 } | 105 } |
103 | 106 |
104 private: | 107 private: |
105 std::wstring channel_id_; | 108 std::wstring channel_id_; |
106 scoped_ptr<RenderProcess> render_process_; | 109 // Deleted in CleanUp() on the renderer thread, so don't use a smart pointer. |
| 110 RenderProcess* render_process_; |
107 }; | 111 }; |
108 | 112 |
109 // Used for a View_ID where the renderer has not been attached yet | 113 // Used for a View_ID where the renderer has not been attached yet |
110 const int32 kInvalidViewID = -1; | 114 const int32 kInvalidViewID = -1; |
111 | 115 |
112 // Get the path to the renderer executable, which is the same as the | 116 // Get the path to the renderer executable, which is the same as the |
113 // current executable. | 117 // current executable. |
114 bool GetRendererPath(std::wstring* cmd_line) { | 118 bool GetRendererPath(std::wstring* cmd_line) { |
115 return PathService::Get(base::FILE_EXE, cmd_line); | 119 return PathService::Get(base::FILE_EXE, cmd_line); |
116 } | 120 } |
(...skipping 758 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
875 SendUserScriptsUpdate(shared_memory); | 879 SendUserScriptsUpdate(shared_memory); |
876 } | 880 } |
877 break; | 881 break; |
878 } | 882 } |
879 default: { | 883 default: { |
880 NOTREACHED(); | 884 NOTREACHED(); |
881 break; | 885 break; |
882 } | 886 } |
883 } | 887 } |
884 } | 888 } |
OLD | NEW |