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

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

Issue 11048029: Allow Thread to initialize COM for Windows consumers who need it (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: Created 8 years, 2 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
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 15 matching lines...) Expand all
26 #include "base/metrics/field_trial.h" 26 #include "base/metrics/field_trial.h"
27 #include "base/metrics/histogram.h" 27 #include "base/metrics/histogram.h"
28 #include "base/path_service.h" 28 #include "base/path_service.h"
29 #include "base/platform_file.h" 29 #include "base/platform_file.h"
30 #include "base/process_util.h" 30 #include "base/process_util.h"
31 #include "base/rand_util.h" 31 #include "base/rand_util.h"
32 #include "base/stl_util.h" 32 #include "base/stl_util.h"
33 #include "base/string_util.h" 33 #include "base/string_util.h"
34 #include "base/supports_user_data.h" 34 #include "base/supports_user_data.h"
35 #include "base/sys_info.h" 35 #include "base/sys_info.h"
36 #include "base/threading/thread.h" 36 #include "base/threading/com_thread.h"
37 #include "base/threading/thread_restrictions.h" 37 #include "base/threading/thread_restrictions.h"
38 #include "base/tracked_objects.h" 38 #include "base/tracked_objects.h"
39 #include "content/browser/appcache/appcache_dispatcher_host.h" 39 #include "content/browser/appcache/appcache_dispatcher_host.h"
40 #include "content/browser/appcache/chrome_appcache_service.h" 40 #include "content/browser/appcache/chrome_appcache_service.h"
41 #include "content/browser/browser_main.h" 41 #include "content/browser/browser_main.h"
42 #include "content/browser/browser_main_loop.h" 42 #include "content/browser/browser_main_loop.h"
43 #include "content/browser/child_process_security_policy_impl.h" 43 #include "content/browser/child_process_security_policy_impl.h"
44 #include "content/browser/device_orientation/orientation_message_filter.h" 44 #include "content/browser/device_orientation/orientation_message_filter.h"
45 #include "content/browser/dom_storage/dom_storage_context_impl.h" 45 #include "content/browser/dom_storage/dom_storage_context_impl.h"
46 #include "content/browser/dom_storage/dom_storage_message_filter.h" 46 #include "content/browser/dom_storage/dom_storage_message_filter.h"
(...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after
125 #include "third_party/skia/include/core/SkBitmap.h" 125 #include "third_party/skia/include/core/SkBitmap.h"
126 126
127 extern bool g_exited_main_message_loop; 127 extern bool g_exited_main_message_loop;
128 128
129 static const char* kSiteProcessMapKeyName = "content_site_process_map"; 129 static const char* kSiteProcessMapKeyName = "content_site_process_map";
130 130
131 namespace content { 131 namespace content {
132 132
133 // This class creates the IO thread for the renderer when running in 133 // This class creates the IO thread for the renderer when running in
134 // single-process mode. It's not used in multi-process mode. 134 // single-process mode. It's not used in multi-process mode.
135 class RendererMainThread : public base::Thread { 135 class RendererMainThread : public base::ComThread {
136 public: 136 public:
137 explicit RendererMainThread(const std::string& channel_id) 137 explicit RendererMainThread(const std::string& channel_id)
138 : base::Thread("Chrome_InProcRendererThread"), 138 : ComThread("Chrome_InProcRendererThread", false),
139 channel_id_(channel_id) { 139 channel_id_(channel_id) {
140 } 140 }
cpu_(ooo_6.6-7.5) 2012/10/04 18:09:03 I rather not derive from base::Thread, I rather ha
141 141
142 virtual ~RendererMainThread() { 142 virtual ~RendererMainThread() {
143 Stop(); 143 Stop();
144 } 144 }
145 145
146 protected: 146 protected:
147 virtual void Init() { 147 virtual void Init() OVERRIDE {
148 #if defined(OS_WIN) 148 ComThread::Init();
149 com_initializer_.reset(new base::win::ScopedCOMInitializer());
150 #endif
151
152 render_process_.reset(new RenderProcessImpl()); 149 render_process_.reset(new RenderProcessImpl());
153 new RenderThreadImpl(channel_id_); 150 new RenderThreadImpl(channel_id_);
154 } 151 }
155 152
156 virtual void CleanUp() { 153 virtual void CleanUp() {
157 render_process_.reset(); 154 render_process_.reset();
158 155
159 #if defined(OS_WIN) 156 ComThread::CleanUp();
160 com_initializer_.reset(); 157
161 #endif
162 // It's a little lame to manually set this flag. But the single process 158 // It's a little lame to manually set this flag. But the single process
163 // RendererThread will receive the WM_QUIT. We don't need to assert on 159 // RendererThread will receive the WM_QUIT. We don't need to assert on
164 // this thread, so just force the flag manually. 160 // this thread, so just force the flag manually.
165 // If we want to avoid this, we could create the InProcRendererThread 161 // If we want to avoid this, we could create the InProcRendererThread
166 // directly with _beginthreadex() rather than using the Thread class. 162 // directly with _beginthreadex() rather than using the Thread class.
167 // We used to set this flag in the Init function above. However there 163 // We used to set this flag in the Init function above. However there
168 // other threads like WebThread which are created by this thread 164 // other threads like WebThread which are created by this thread
169 // which resets this flag. Please see Thread::StartWithOptions. Setting 165 // which resets this flag. Please see Thread::StartWithOptions. Setting
170 // this flag to true in Cleanup works around these problems. 166 // this flag to true in Cleanup works around these problems.
171 base::Thread::SetThreadWasQuitProperly(true); 167 SetThreadWasQuitProperly(true);
172 } 168 }
173 169
174 private: 170 private:
175 std::string channel_id_; 171 std::string channel_id_;
176 #if defined(OS_WIN)
177 scoped_ptr<base::win::ScopedCOMInitializer> com_initializer_;
178 #endif
179 scoped_ptr<RenderProcess> render_process_; 172 scoped_ptr<RenderProcess> render_process_;
180 173
181 DISALLOW_COPY_AND_ASSIGN(RendererMainThread); 174 DISALLOW_COPY_AND_ASSIGN(RendererMainThread);
182 }; 175 };
183 176
184 namespace { 177 namespace {
185 178
186 // Helper class that we pass to ResourceMessageFilter so that it can find the 179 // Helper class that we pass to ResourceMessageFilter so that it can find the
187 // right net::URLRequestContext for a request. 180 // right net::URLRequestContext for a request.
188 class RendererURLRequestContextSelector 181 class RendererURLRequestContextSelector
(...skipping 1379 matching lines...) Expand 10 before | Expand all | Expand 10 after
1568 const gfx::Size& size, 1561 const gfx::Size& size,
1569 int32 gpu_process_host_id) { 1562 int32 gpu_process_host_id) {
1570 TRACE_EVENT0("renderer_host", 1563 TRACE_EVENT0("renderer_host",
1571 "RenderWidgetHostImpl::OnCompositorSurfaceBuffersSwappedNoHost"); 1564 "RenderWidgetHostImpl::OnCompositorSurfaceBuffersSwappedNoHost");
1572 RenderWidgetHostImpl::AcknowledgeBufferPresent(route_id, 1565 RenderWidgetHostImpl::AcknowledgeBufferPresent(route_id,
1573 gpu_process_host_id, 1566 gpu_process_host_id,
1574 0); 1567 0);
1575 } 1568 }
1576 1569
1577 } // namespace content 1570 } // namespace content
OLDNEW
« no previous file with comments | « content/browser/renderer_host/media/media_stream_manager.cc ('k') | media/audio/audio_input_device_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698