| 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) | 10 #if defined(OS_WIN) |
| (...skipping 120 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 131 static const char* kSiteProcessMapKeyName = "content_site_process_map"; | 131 static const char* kSiteProcessMapKeyName = "content_site_process_map"; |
| 132 | 132 |
| 133 namespace content { | 133 namespace content { |
| 134 | 134 |
| 135 // This class creates the IO thread for the renderer when running in | 135 // This class creates the IO thread for the renderer when running in |
| 136 // single-process mode. It's not used in multi-process mode. | 136 // single-process mode. It's not used in multi-process mode. |
| 137 class RendererMainThread : public base::Thread { | 137 class RendererMainThread : public base::Thread { |
| 138 public: | 138 public: |
| 139 explicit RendererMainThread(const std::string& channel_id) | 139 explicit RendererMainThread(const std::string& channel_id) |
| 140 : base::Thread("Chrome_InProcRendererThread"), | 140 : base::Thread("Chrome_InProcRendererThread"), |
| 141 channel_id_(channel_id), | 141 channel_id_(channel_id) { |
| 142 render_process_(NULL) { | |
| 143 } | 142 } |
| 144 | 143 |
| 145 ~RendererMainThread() { | 144 ~RendererMainThread() { |
| 146 Stop(); | 145 Stop(); |
| 147 } | 146 } |
| 148 | 147 |
| 149 protected: | 148 protected: |
| 150 virtual void Init() { | 149 virtual void Init() { |
| 151 #if defined(OS_WIN) | 150 #if defined(OS_WIN) |
| 152 CoInitialize(NULL); | 151 CoInitialize(NULL); |
| 153 #endif | 152 #endif |
| 154 | 153 |
| 155 render_process_ = new RenderProcessImpl(); | 154 render_process_.reset(new RenderProcessImpl()); |
| 156 new RenderThreadImpl(channel_id_); | 155 new RenderThreadImpl(channel_id_); |
| 157 } | 156 } |
| 158 | 157 |
| 159 virtual void CleanUp() { | 158 virtual void CleanUp() { |
| 160 delete render_process_; | 159 render_process_.reset(); |
| 161 | 160 |
| 162 #if defined(OS_WIN) | 161 #if defined(OS_WIN) |
| 163 CoUninitialize(); | 162 CoUninitialize(); |
| 164 #endif | 163 #endif |
| 165 // It's a little lame to manually set this flag. But the single process | 164 // 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 | 165 // RendererThread will receive the WM_QUIT. We don't need to assert on |
| 167 // this thread, so just force the flag manually. | 166 // this thread, so just force the flag manually. |
| 168 // If we want to avoid this, we could create the InProcRendererThread | 167 // If we want to avoid this, we could create the InProcRendererThread |
| 169 // directly with _beginthreadex() rather than using the Thread class. | 168 // directly with _beginthreadex() rather than using the Thread class. |
| 170 // We used to set this flag in the Init function above. However there | 169 // We used to set this flag in the Init function above. However there |
| 171 // other threads like WebThread which are created by this thread | 170 // other threads like WebThread which are created by this thread |
| 172 // which resets this flag. Please see Thread::StartWithOptions. Setting | 171 // which resets this flag. Please see Thread::StartWithOptions. Setting |
| 173 // this flag to true in Cleanup works around these problems. | 172 // this flag to true in Cleanup works around these problems. |
| 174 base::Thread::SetThreadWasQuitProperly(true); | 173 base::Thread::SetThreadWasQuitProperly(true); |
| 175 } | 174 } |
| 176 | 175 |
| 177 private: | 176 private: |
| 178 std::string channel_id_; | 177 std::string channel_id_; |
| 179 // Deleted in CleanUp() on the renderer thread, so don't use a smart pointer. | 178 scoped_ptr<RenderProcess> render_process_; |
| 180 RenderProcess* render_process_; | |
| 181 }; | 179 }; |
| 182 | 180 |
| 183 namespace { | 181 namespace { |
| 184 | 182 |
| 185 // Helper class that we pass to ResourceMessageFilter so that it can find the | 183 // Helper class that we pass to ResourceMessageFilter so that it can find the |
| 186 // right net::URLRequestContext for a request. | 184 // right net::URLRequestContext for a request. |
| 187 class RendererURLRequestContextSelector | 185 class RendererURLRequestContextSelector |
| 188 : public ResourceMessageFilter::URLRequestContextSelector { | 186 : public ResourceMessageFilter::URLRequestContextSelector { |
| 189 public: | 187 public: |
| 190 RendererURLRequestContextSelector(BrowserContext* browser_context, | 188 RendererURLRequestContextSelector(BrowserContext* browser_context, |
| (...skipping 1376 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1567 const gfx::Size& size, | 1565 const gfx::Size& size, |
| 1568 int32 gpu_process_host_id) { | 1566 int32 gpu_process_host_id) { |
| 1569 TRACE_EVENT0("renderer_host", | 1567 TRACE_EVENT0("renderer_host", |
| 1570 "RenderWidgetHostImpl::OnCompositorSurfaceBuffersSwappedNoHost"); | 1568 "RenderWidgetHostImpl::OnCompositorSurfaceBuffersSwappedNoHost"); |
| 1571 RenderWidgetHostImpl::AcknowledgeBufferPresent(route_id, | 1569 RenderWidgetHostImpl::AcknowledgeBufferPresent(route_id, |
| 1572 gpu_process_host_id, | 1570 gpu_process_host_id, |
| 1573 0); | 1571 0); |
| 1574 } | 1572 } |
| 1575 | 1573 |
| 1576 } // namespace content | 1574 } // namespace content |
| OLD | NEW |