| 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 #if defined(OS_WIN) | |
| 11 #include <objbase.h> // For CoInitialize/CoUninitialize. | |
| 12 #endif | |
| 13 | |
| 14 #include <algorithm> | 10 #include <algorithm> |
| 15 #include <limits> | 11 #include <limits> |
| 16 #include <vector> | 12 #include <vector> |
| 17 | 13 |
| 18 #if defined(OS_POSIX) | 14 #if defined(OS_POSIX) |
| 19 #include <utility> // for pair<> | 15 #include <utility> // for pair<> |
| 20 #endif | 16 #endif |
| 21 | 17 |
| 22 #include "base/base_switches.h" | 18 #include "base/base_switches.h" |
| 23 #include "base/bind.h" | 19 #include "base/bind.h" |
| (...skipping 91 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 115 #include "media/base/media_switches.h" | 111 #include "media/base/media_switches.h" |
| 116 #include "net/url_request/url_request_context_getter.h" | 112 #include "net/url_request/url_request_context_getter.h" |
| 117 #include "ppapi/shared_impl/ppapi_switches.h" | 113 #include "ppapi/shared_impl/ppapi_switches.h" |
| 118 #include "ui/base/ui_base_switches.h" | 114 #include "ui/base/ui_base_switches.h" |
| 119 #include "ui/gl/gl_switches.h" | 115 #include "ui/gl/gl_switches.h" |
| 120 #include "webkit/fileapi/sandbox_mount_point_provider.h" | 116 #include "webkit/fileapi/sandbox_mount_point_provider.h" |
| 121 #include "webkit/glue/resource_type.h" | 117 #include "webkit/glue/resource_type.h" |
| 122 #include "webkit/plugins/plugin_switches.h" | 118 #include "webkit/plugins/plugin_switches.h" |
| 123 | 119 |
| 124 #if defined(OS_WIN) | 120 #if defined(OS_WIN) |
| 121 #include "base/win/scoped_com_initializer.h" |
| 125 #include "content/common/font_cache_dispatcher_win.h" | 122 #include "content/common/font_cache_dispatcher_win.h" |
| 126 #endif | 123 #endif |
| 127 | 124 |
| 128 #include "third_party/skia/include/core/SkBitmap.h" | 125 #include "third_party/skia/include/core/SkBitmap.h" |
| 129 | 126 |
| 130 extern bool g_exited_main_message_loop; | 127 extern bool g_exited_main_message_loop; |
| 131 | 128 |
| 132 static const char* kSiteProcessMapKeyName = "content_site_process_map"; | 129 static const char* kSiteProcessMapKeyName = "content_site_process_map"; |
| 133 | 130 |
| 134 namespace content { | 131 namespace content { |
| 135 | 132 |
| 136 // 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 |
| 137 // single-process mode. It's not used in multi-process mode. | 134 // single-process mode. It's not used in multi-process mode. |
| 138 class RendererMainThread : public base::Thread { | 135 class RendererMainThread : public base::Thread { |
| 139 public: | 136 public: |
| 140 explicit RendererMainThread(const std::string& channel_id) | 137 explicit RendererMainThread(const std::string& channel_id) |
| 141 : base::Thread("Chrome_InProcRendererThread"), | 138 : base::Thread("Chrome_InProcRendererThread"), |
| 142 channel_id_(channel_id) { | 139 channel_id_(channel_id) { |
| 143 } | 140 } |
| 144 | 141 |
| 145 ~RendererMainThread() { | 142 virtual ~RendererMainThread() { |
| 146 Stop(); | 143 Stop(); |
| 147 } | 144 } |
| 148 | 145 |
| 149 protected: | 146 protected: |
| 150 virtual void Init() { | 147 virtual void Init() { |
| 151 #if defined(OS_WIN) | 148 #if defined(OS_WIN) |
| 152 CoInitialize(NULL); | 149 com_initializer_.reset(new base::win::ScopedCOMInitializer()); |
| 153 #endif | 150 #endif |
| 154 | 151 |
| 155 render_process_.reset(new RenderProcessImpl()); | 152 render_process_.reset(new RenderProcessImpl()); |
| 156 new RenderThreadImpl(channel_id_); | 153 new RenderThreadImpl(channel_id_); |
| 157 } | 154 } |
| 158 | 155 |
| 159 virtual void CleanUp() { | 156 virtual void CleanUp() { |
| 160 render_process_.reset(); | 157 render_process_.reset(); |
| 161 | 158 |
| 162 #if defined(OS_WIN) | 159 #if defined(OS_WIN) |
| 163 CoUninitialize(); | 160 com_initializer_.reset(); |
| 164 #endif | 161 #endif |
| 165 // It's a little lame to manually set this flag. But the single process | 162 // It's a little lame to manually set this flag. But the single process |
| 166 // RendererThread will receive the WM_QUIT. We don't need to assert on | 163 // RendererThread will receive the WM_QUIT. We don't need to assert on |
| 167 // this thread, so just force the flag manually. | 164 // this thread, so just force the flag manually. |
| 168 // If we want to avoid this, we could create the InProcRendererThread | 165 // If we want to avoid this, we could create the InProcRendererThread |
| 169 // directly with _beginthreadex() rather than using the Thread class. | 166 // directly with _beginthreadex() rather than using the Thread class. |
| 170 // We used to set this flag in the Init function above. However there | 167 // We used to set this flag in the Init function above. However there |
| 171 // other threads like WebThread which are created by this thread | 168 // other threads like WebThread which are created by this thread |
| 172 // which resets this flag. Please see Thread::StartWithOptions. Setting | 169 // which resets this flag. Please see Thread::StartWithOptions. Setting |
| 173 // this flag to true in Cleanup works around these problems. | 170 // this flag to true in Cleanup works around these problems. |
| 174 base::Thread::SetThreadWasQuitProperly(true); | 171 base::Thread::SetThreadWasQuitProperly(true); |
| 175 } | 172 } |
| 176 | 173 |
| 177 private: | 174 private: |
| 178 std::string channel_id_; | 175 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_; | 179 scoped_ptr<RenderProcess> render_process_; |
| 180 |
| 181 DISALLOW_COPY_AND_ASSIGN(RendererMainThread); |
| 180 }; | 182 }; |
| 181 | 183 |
| 182 namespace { | 184 namespace { |
| 183 | 185 |
| 184 // Helper class that we pass to ResourceMessageFilter so that it can find the | 186 // Helper class that we pass to ResourceMessageFilter so that it can find the |
| 185 // right net::URLRequestContext for a request. | 187 // right net::URLRequestContext for a request. |
| 186 class RendererURLRequestContextSelector | 188 class RendererURLRequestContextSelector |
| 187 : public ResourceMessageFilter::URLRequestContextSelector { | 189 : public ResourceMessageFilter::URLRequestContextSelector { |
| 188 public: | 190 public: |
| 189 RendererURLRequestContextSelector(BrowserContext* browser_context, | 191 RendererURLRequestContextSelector(BrowserContext* browser_context, |
| (...skipping 1376 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1566 const gfx::Size& size, | 1568 const gfx::Size& size, |
| 1567 int32 gpu_process_host_id) { | 1569 int32 gpu_process_host_id) { |
| 1568 TRACE_EVENT0("renderer_host", | 1570 TRACE_EVENT0("renderer_host", |
| 1569 "RenderWidgetHostImpl::OnCompositorSurfaceBuffersSwappedNoHost"); | 1571 "RenderWidgetHostImpl::OnCompositorSurfaceBuffersSwappedNoHost"); |
| 1570 RenderWidgetHostImpl::AcknowledgeBufferPresent(route_id, | 1572 RenderWidgetHostImpl::AcknowledgeBufferPresent(route_id, |
| 1571 gpu_process_host_id, | 1573 gpu_process_host_id, |
| 1572 0); | 1574 0); |
| 1573 } | 1575 } |
| 1574 | 1576 |
| 1575 } // namespace content | 1577 } // namespace content |
| OLD | NEW |