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 #ifndef CONTENT_RENDERER_RENDER_THREAD_IMPL_H_ | 5 #ifndef CONTENT_RENDERER_RENDER_THREAD_IMPL_H_ |
6 #define CONTENT_RENDERER_RENDER_THREAD_IMPL_H_ | 6 #define CONTENT_RENDERER_RENDER_THREAD_IMPL_H_ |
7 #pragma once | 7 #pragma once |
8 | 8 |
9 #include <set> | 9 #include <set> |
10 #include <string> | 10 #include <string> |
11 #include <vector> | 11 #include <vector> |
12 | 12 |
13 #include "base/observer_list.h" | 13 #include "base/observer_list.h" |
14 #include "base/time.h" | 14 #include "base/time.h" |
15 #include "base/timer.h" | 15 #include "base/timer.h" |
16 #include "build/build_config.h" | 16 #include "build/build_config.h" |
| 17 #include "content/common/child_process.h" |
17 #include "content/common/child_thread.h" | 18 #include "content/common/child_thread.h" |
18 #include "content/common/content_export.h" | 19 #include "content/common/content_export.h" |
19 #include "content/common/css_colors.h" | 20 #include "content/common/css_colors.h" |
20 #include "content/common/gpu/gpu_process_launch_causes.h" | 21 #include "content/common/gpu/gpu_process_launch_causes.h" |
21 #include "content/public/renderer/render_thread.h" | 22 #include "content/public/renderer/render_thread.h" |
| 23 #include "content/renderer/gpu/gpu_channel_host.h" |
22 #include "ipc/ipc_channel_proxy.h" | 24 #include "ipc/ipc_channel_proxy.h" |
23 #include "ui/gfx/native_widget_types.h" | 25 #include "ui/gfx/native_widget_types.h" |
24 | 26 |
25 class AppCacheDispatcher; | 27 class AppCacheDispatcher; |
26 class AudioInputMessageFilter; | 28 class AudioInputMessageFilter; |
27 class AudioMessageFilter; | 29 class AudioMessageFilter; |
28 class CompositorThread; | 30 class CompositorThread; |
29 class DBMessageFilter; | 31 class DBMessageFilter; |
30 class DevToolsAgentFilter; | 32 class DevToolsAgentFilter; |
31 struct DOMStorageMsg_Event_Params; | 33 struct DOMStorageMsg_Event_Params; |
(...skipping 28 matching lines...) Expand all Loading... |
60 // The RenderThreadImpl class represents a background thread where RenderView | 62 // The RenderThreadImpl class represents a background thread where RenderView |
61 // instances live. The RenderThread supports an API that is used by its | 63 // instances live. The RenderThread supports an API that is used by its |
62 // consumer to talk indirectly to the RenderViews and supporting objects. | 64 // consumer to talk indirectly to the RenderViews and supporting objects. |
63 // Likewise, it provides an API for the RenderViews to talk back to the main | 65 // Likewise, it provides an API for the RenderViews to talk back to the main |
64 // process (i.e., their corresponding TabContents). | 66 // process (i.e., their corresponding TabContents). |
65 // | 67 // |
66 // Most of the communication occurs in the form of IPC messages. They are | 68 // Most of the communication occurs in the form of IPC messages. They are |
67 // routed to the RenderThread according to the routing IDs of the messages. | 69 // routed to the RenderThread according to the routing IDs of the messages. |
68 // The routing IDs correspond to RenderView instances. | 70 // The routing IDs correspond to RenderView instances. |
69 class CONTENT_EXPORT RenderThreadImpl : public content::RenderThread, | 71 class CONTENT_EXPORT RenderThreadImpl : public content::RenderThread, |
70 public ChildThread { | 72 public ChildThread, |
| 73 public GpuChannelHostFactory { |
71 public: | 74 public: |
72 static RenderThreadImpl* current(); | 75 static RenderThreadImpl* current(); |
73 | 76 |
74 RenderThreadImpl(); | 77 RenderThreadImpl(); |
75 // Constructor that's used when running in single process mode. | 78 // Constructor that's used when running in single process mode. |
76 explicit RenderThreadImpl(const std::string& channel_name); | 79 explicit RenderThreadImpl(const std::string& channel_name); |
77 virtual ~RenderThreadImpl(); | 80 virtual ~RenderThreadImpl(); |
78 | 81 |
79 // Returns the routing ID of the RenderWidget containing the current script | 82 // Returns the routing ID of the RenderWidget containing the current script |
80 // execution context (corresponding to WebFrame::frameForCurrentContext). | 83 // execution context (corresponding to WebFrame::frameForCurrentContext). |
(...skipping 30 matching lines...) Expand all Loading... |
111 virtual void ScheduleIdleHandler(int64 initial_delay_ms) OVERRIDE; | 114 virtual void ScheduleIdleHandler(int64 initial_delay_ms) OVERRIDE; |
112 virtual void IdleHandler() OVERRIDE; | 115 virtual void IdleHandler() OVERRIDE; |
113 virtual int64 GetIdleNotificationDelayInMs() const OVERRIDE; | 116 virtual int64 GetIdleNotificationDelayInMs() const OVERRIDE; |
114 virtual void SetIdleNotificationDelayInMs( | 117 virtual void SetIdleNotificationDelayInMs( |
115 int64 idle_notification_delay_in_ms) OVERRIDE; | 118 int64 idle_notification_delay_in_ms) OVERRIDE; |
116 #if defined(OS_WIN) | 119 #if defined(OS_WIN) |
117 virtual void PreCacheFont(const LOGFONT& log_font) OVERRIDE; | 120 virtual void PreCacheFont(const LOGFONT& log_font) OVERRIDE; |
118 virtual void ReleaseCachedFonts() OVERRIDE; | 121 virtual void ReleaseCachedFonts() OVERRIDE; |
119 #endif | 122 #endif |
120 | 123 |
| 124 // GpuChannelHostFactory implementation: |
| 125 virtual bool IsMainThread() OVERRIDE; |
| 126 virtual bool IsIOThread() OVERRIDE; |
| 127 virtual MessageLoop* GetMainLoop() OVERRIDE; |
| 128 virtual base::MessageLoopProxy* GetIOLoopProxy() OVERRIDE; |
| 129 virtual base::WaitableEvent* GetShutDownEvent() OVERRIDE; |
| 130 virtual scoped_ptr<base::SharedMemory> AllocateSharedMemory( |
| 131 uint32 size) OVERRIDE; |
| 132 virtual int32 CreateViewCommandBuffer( |
| 133 int32 surface_id, |
| 134 const GPUCreateCommandBufferConfig& init_params) OVERRIDE; |
| 135 |
| 136 // Synchronously establish a channel to the GPU plugin if not previously |
| 137 // established or if it has been lost (for example if the GPU plugin crashed). |
| 138 // If there is a pending asynchronous request, it will be completed by the |
| 139 // time this routine returns. |
| 140 virtual GpuChannelHost* EstablishGpuChannelSync( |
| 141 content::CauseForGpuLaunch) OVERRIDE; |
| 142 |
| 143 |
121 // These methods modify how the next message is sent. Normally, when sending | 144 // These methods modify how the next message is sent. Normally, when sending |
122 // a synchronous message that runs a nested message loop, we need to suspend | 145 // a synchronous message that runs a nested message loop, we need to suspend |
123 // callbacks into WebKit. This involves disabling timers and deferring | 146 // callbacks into WebKit. This involves disabling timers and deferring |
124 // resource loads. However, there are exceptions when we need to customize | 147 // resource loads. However, there are exceptions when we need to customize |
125 // the behavior. | 148 // the behavior. |
126 void DoNotSuspendWebKitSharedTimer(); | 149 void DoNotSuspendWebKitSharedTimer(); |
127 void DoNotNotifyWebKitOfModalLoop(); | 150 void DoNotNotifyWebKitOfModalLoop(); |
128 | 151 |
129 // Will be NULL if threaded compositing has not been enabled. | 152 // Will be NULL if threaded compositing has not been enabled. |
130 CompositorThread* compositor_thread() const { | 153 CompositorThread* compositor_thread() const { |
(...skipping 11 matching lines...) Expand all Loading... |
142 AudioMessageFilter* audio_message_filter() { | 165 AudioMessageFilter* audio_message_filter() { |
143 return audio_message_filter_.get(); | 166 return audio_message_filter_.get(); |
144 } | 167 } |
145 | 168 |
146 VideoCaptureImplManager* video_capture_impl_manager() const { | 169 VideoCaptureImplManager* video_capture_impl_manager() const { |
147 return vc_manager_.get(); | 170 return vc_manager_.get(); |
148 } | 171 } |
149 | 172 |
150 bool plugin_refresh_allowed() const { return plugin_refresh_allowed_; } | 173 bool plugin_refresh_allowed() const { return plugin_refresh_allowed_; } |
151 | 174 |
152 // Synchronously establish a channel to the GPU plugin if not previously | |
153 // established or if it has been lost (for example if the GPU plugin crashed). | |
154 // If there is a pending asynchronous request, it will be completed by the | |
155 // time this routine returns. | |
156 GpuChannelHost* EstablishGpuChannelSync(content::CauseForGpuLaunch); | |
157 | |
158 // Get the GPU channel. Returns NULL if the channel is not established or | 175 // Get the GPU channel. Returns NULL if the channel is not established or |
159 // has been lost. | 176 // has been lost. |
160 GpuChannelHost* GetGpuChannel(); | 177 GpuChannelHost* GetGpuChannel(); |
161 | 178 |
162 // Returns a MessageLoopProxy instance corresponding to the message loop | 179 // Returns a MessageLoopProxy instance corresponding to the message loop |
163 // of the thread on which file operations should be run. Must be called | 180 // of the thread on which file operations should be run. Must be called |
164 // on the renderer's main thread. | 181 // on the renderer's main thread. |
165 scoped_refptr<base::MessageLoopProxy> GetFileThreadMessageLoopProxy(); | 182 scoped_refptr<base::MessageLoopProxy> GetFileThreadMessageLoopProxy(); |
166 | 183 |
167 // Causes the idle handler to skip sending idle notifications | 184 // Causes the idle handler to skip sending idle notifications |
(...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
239 | 256 |
240 bool compositor_initialized_; | 257 bool compositor_initialized_; |
241 scoped_ptr<CompositorThread> compositor_thread_; | 258 scoped_ptr<CompositorThread> compositor_thread_; |
242 | 259 |
243 ObserverList<content::RenderProcessObserver> observers_; | 260 ObserverList<content::RenderProcessObserver> observers_; |
244 | 261 |
245 DISALLOW_COPY_AND_ASSIGN(RenderThreadImpl); | 262 DISALLOW_COPY_AND_ASSIGN(RenderThreadImpl); |
246 }; | 263 }; |
247 | 264 |
248 #endif // CONTENT_RENDERER_RENDER_THREAD_IMPL_H_ | 265 #endif // CONTENT_RENDERER_RENDER_THREAD_IMPL_H_ |
OLD | NEW |