OLD | NEW |
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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_H_ | 5 #ifndef CONTENT_RENDERER_RENDER_THREAD_H_ |
6 #define CONTENT_RENDERER_RENDER_THREAD_H_ | 6 #define CONTENT_RENDERER_RENDER_THREAD_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/shared_memory.h" | 14 #include "base/shared_memory.h" |
15 #include "base/time.h" | 15 #include "base/time.h" |
16 #include "base/timer.h" | 16 #include "base/timer.h" |
17 #include "build/build_config.h" | 17 #include "build/build_config.h" |
18 #include "content/common/child_thread.h" | 18 #include "content/common/child_thread.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 "ipc/ipc_channel_proxy.h" | 22 #include "ipc/ipc_channel_proxy.h" |
22 #include "ui/gfx/native_widget_types.h" | 23 #include "ui/gfx/native_widget_types.h" |
23 | 24 |
24 class AppCacheDispatcher; | 25 class AppCacheDispatcher; |
25 class AudioInputMessageFilter; | 26 class AudioInputMessageFilter; |
26 class AudioMessageFilter; | 27 class AudioMessageFilter; |
27 class DBMessageFilter; | 28 class DBMessageFilter; |
28 class DevToolsAgentFilter; | 29 class DevToolsAgentFilter; |
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
84 // It might be nice not to have the ::current() call and put all of the | 85 // It might be nice not to have the ::current() call and put all of the |
85 // functions on the abstract class so they can be mocked. However, there are | 86 // functions on the abstract class so they can be mocked. However, there are |
86 // some standalone functions like in ChromiumBridge that are not associated | 87 // some standalone functions like in ChromiumBridge that are not associated |
87 // with a view that need to access the current thread to send messages to the | 88 // with a view that need to access the current thread to send messages to the |
88 // browser process. These need the ::current() paradigm. So instead, we should | 89 // browser process. These need the ::current() paradigm. So instead, we should |
89 // probably remove the render_thread_ parameter to RenderView/Widget in | 90 // probably remove the render_thread_ parameter to RenderView/Widget in |
90 // preference to just getting the global singleton. We can make it easier to | 91 // preference to just getting the global singleton. We can make it easier to |
91 // understand by moving everything to the abstract interface and saying that | 92 // understand by moving everything to the abstract interface and saying that |
92 // there should never be a NULL RenderThread::current(). Tests would be | 93 // there should never be a NULL RenderThread::current(). Tests would be |
93 // responsible for setting up the mock one. | 94 // responsible for setting up the mock one. |
94 class RenderThreadBase { | 95 class CONTENT_EXPORT RenderThreadBase { |
95 public: | 96 public: |
96 virtual ~RenderThreadBase() {} | 97 virtual ~RenderThreadBase() {} |
97 | 98 |
98 virtual bool Send(IPC::Message* msg) = 0; | 99 virtual bool Send(IPC::Message* msg) = 0; |
99 | 100 |
100 // Called to add or remove a listener for a particular message routing ID. | 101 // Called to add or remove a listener for a particular message routing ID. |
101 // These methods normally get delegated to a MessageRouter. | 102 // These methods normally get delegated to a MessageRouter. |
102 virtual void AddRoute(int32 routing_id, IPC::Channel::Listener* listener) = 0; | 103 virtual void AddRoute(int32 routing_id, IPC::Channel::Listener* listener) = 0; |
103 virtual void RemoveRoute(int32 routing_id) = 0; | 104 virtual void RemoveRoute(int32 routing_id) = 0; |
104 | 105 |
105 virtual void AddFilter(IPC::ChannelProxy::MessageFilter* filter) = 0; | 106 virtual void AddFilter(IPC::ChannelProxy::MessageFilter* filter) = 0; |
106 virtual void RemoveFilter(IPC::ChannelProxy::MessageFilter* filter) = 0; | 107 virtual void RemoveFilter(IPC::ChannelProxy::MessageFilter* filter) = 0; |
107 | 108 |
108 // Called by a RenderWidget when it is hidden or restored. | 109 // Called by a RenderWidget when it is hidden or restored. |
109 virtual void WidgetHidden() = 0; | 110 virtual void WidgetHidden() = 0; |
110 virtual void WidgetRestored() = 0; | 111 virtual void WidgetRestored() = 0; |
111 }; | 112 }; |
112 | 113 |
113 // The RenderThread class represents a background thread where RenderView | 114 // The RenderThread class represents a background thread where RenderView |
114 // instances live. The RenderThread supports an API that is used by its | 115 // instances live. The RenderThread supports an API that is used by its |
115 // consumer to talk indirectly to the RenderViews and supporting objects. | 116 // consumer to talk indirectly to the RenderViews and supporting objects. |
116 // Likewise, it provides an API for the RenderViews to talk back to the main | 117 // Likewise, it provides an API for the RenderViews to talk back to the main |
117 // process (i.e., their corresponding TabContents). | 118 // process (i.e., their corresponding TabContents). |
118 // | 119 // |
119 // Most of the communication occurs in the form of IPC messages. They are | 120 // Most of the communication occurs in the form of IPC messages. They are |
120 // routed to the RenderThread according to the routing IDs of the messages. | 121 // routed to the RenderThread according to the routing IDs of the messages. |
121 // The routing IDs correspond to RenderView instances. | 122 // The routing IDs correspond to RenderView instances. |
122 class RenderThread : public RenderThreadBase, | 123 class CONTENT_EXPORT RenderThread : public RenderThreadBase, |
123 public ChildThread { | 124 public ChildThread { |
124 public: | 125 public: |
125 // Grabs the IPC channel name from the command line. | 126 // Grabs the IPC channel name from the command line. |
126 RenderThread(); | 127 RenderThread(); |
127 // Constructor that's used when running in single process mode. | 128 // Constructor that's used when running in single process mode. |
128 explicit RenderThread(const std::string& channel_name); | 129 explicit RenderThread(const std::string& channel_name); |
129 virtual ~RenderThread(); | 130 virtual ~RenderThread(); |
130 | 131 |
131 // Returns the one render thread for this process. Note that this should only | 132 // Returns the one render thread for this process. Note that this should only |
132 // be accessed when running on the render thread itself | 133 // be accessed when running on the render thread itself |
133 // | 134 // |
(...skipping 165 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
299 | 300 |
300 // Map of registered v8 extensions. The key is the extension name. | 301 // Map of registered v8 extensions. The key is the extension name. |
301 std::set<std::string> v8_extensions_; | 302 std::set<std::string> v8_extensions_; |
302 | 303 |
303 ObserverList<RenderProcessObserver> observers_; | 304 ObserverList<RenderProcessObserver> observers_; |
304 | 305 |
305 DISALLOW_COPY_AND_ASSIGN(RenderThread); | 306 DISALLOW_COPY_AND_ASSIGN(RenderThread); |
306 }; | 307 }; |
307 | 308 |
308 #endif // CONTENT_RENDERER_RENDER_THREAD_H_ | 309 #endif // CONTENT_RENDERER_RENDER_THREAD_H_ |
OLD | NEW |