OLD | NEW |
1 // Copyright (c) 2006-2008 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2006-2008 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 CHROME_RENDERER_RENDER_THREAD_H__ | 5 #ifndef CHROME_RENDERER_RENDER_THREAD_H__ |
6 #define CHROME_RENDERER_RENDER_THREAD_H__ | 6 #define CHROME_RENDERER_RENDER_THREAD_H__ |
7 | 7 |
8 #include "base/ref_counted.h" | 8 #include "base/ref_counted.h" |
9 #include "base/shared_memory.h" | 9 #include "base/shared_memory.h" |
10 #include "base/task.h" | 10 #include "base/task.h" |
11 #include "base/thread.h" | 11 #include "base/thread.h" |
12 #include "chrome/common/ipc_sync_channel.h" | 12 #include "chrome/common/ipc_sync_channel.h" |
13 #include "chrome/common/message_router.h" | 13 #include "chrome/common/message_router.h" |
14 | 14 |
15 class SkBitmap; | 15 class SkBitmap; |
16 class Task; | 16 class Task; |
17 class VisitedLinkSlave; | 17 class VisitedLinkSlave; |
18 struct WebPreferences; | 18 struct WebPreferences; |
19 class RenderDnsMaster; | 19 class RenderDnsMaster; |
20 class NotificationService; | 20 class NotificationService; |
| 21 class GreasemonkeySlave; |
21 | 22 |
22 // The RenderThreadBase is the minimal interface that a RenderWidget expects | 23 // The RenderThreadBase is the minimal interface that a RenderWidget expects |
23 // from a render thread. The interface basically abstracts a way to send and | 24 // from a render thread. The interface basically abstracts a way to send and |
24 // receive messages. It is currently only used for testing. | 25 // receive messages. It is currently only used for testing. |
25 class RenderThreadBase : public IPC::Message::Sender { | 26 class RenderThreadBase : public IPC::Message::Sender { |
26 public: | 27 public: |
27 virtual ~RenderThreadBase() {} | 28 virtual ~RenderThreadBase() {} |
28 | 29 |
29 // True if currently sending a message. | 30 // True if currently sending a message. |
30 virtual bool InSend() const = 0; | 31 virtual bool InSend() const = 0; |
(...skipping 26 matching lines...) Expand all Loading... |
57 | 58 |
58 // IPC::Message::Sender implementation: | 59 // IPC::Message::Sender implementation: |
59 virtual bool Send(IPC::Message* msg); | 60 virtual bool Send(IPC::Message* msg); |
60 | 61 |
61 void AddFilter(IPC::ChannelProxy::MessageFilter* filter); | 62 void AddFilter(IPC::ChannelProxy::MessageFilter* filter); |
62 void RemoveFilter(IPC::ChannelProxy::MessageFilter* filter); | 63 void RemoveFilter(IPC::ChannelProxy::MessageFilter* filter); |
63 | 64 |
64 // The RenderThread instance for the current thread. | 65 // The RenderThread instance for the current thread. |
65 static RenderThread* current(); | 66 static RenderThread* current(); |
66 | 67 |
| 68 // Gets the VisitedLinkSlave instance for this thread |
67 VisitedLinkSlave* visited_link_slave() const { return visited_link_slave_; } | 69 VisitedLinkSlave* visited_link_slave() const { return visited_link_slave_; } |
68 | 70 |
| 71 // Gets the GreasemonkeySlave instance for this thread |
| 72 GreasemonkeySlave* greasemonkey_slave() const { return greasemonkey_slave_; } |
| 73 |
69 // Do DNS prefetch resolution of a hostname. | 74 // Do DNS prefetch resolution of a hostname. |
70 void Resolve(const char* name, size_t length); | 75 void Resolve(const char* name, size_t length); |
71 | 76 |
72 // See documentation on MessageRouter for AddRoute and RemoveRoute | 77 // See documentation on MessageRouter for AddRoute and RemoveRoute |
73 virtual void AddRoute(int32 routing_id, IPC::Channel::Listener* listener); | 78 virtual void AddRoute(int32 routing_id, IPC::Channel::Listener* listener); |
74 virtual void RemoveRoute(int32 routing_id); | 79 virtual void RemoveRoute(int32 routing_id); |
75 | 80 |
76 // Invokes InformHostOfCacheStats after a short delay. Used to move this | 81 // Invokes InformHostOfCacheStats after a short delay. Used to move this |
77 // bookkeeping operation off the critical latency path. | 82 // bookkeeping operation off the critical latency path. |
78 void InformHostOfCacheStatsLater(); | 83 void InformHostOfCacheStatsLater(); |
79 | 84 |
80 MessageLoop* owner_loop() { return owner_loop_; } | 85 MessageLoop* owner_loop() { return owner_loop_; } |
81 | 86 |
82 // Indicates if RenderThread::Send() is on the call stack. | 87 // Indicates if RenderThread::Send() is on the call stack. |
83 virtual bool InSend() const { return in_send_ != 0; } | 88 virtual bool InSend() const { return in_send_ != 0; } |
84 | 89 |
85 protected: | 90 protected: |
86 // Called by the thread base class | 91 // Called by the thread base class |
87 virtual void Init(); | 92 virtual void Init(); |
88 virtual void CleanUp(); | 93 virtual void CleanUp(); |
89 | 94 |
90 private: | 95 private: |
91 void OnUpdateVisitedLinks(SharedMemoryHandle table); | 96 void OnUpdateVisitedLinks(SharedMemoryHandle table); |
| 97 void OnUpdateGreasemonkeyScripts(SharedMemoryHandle table); |
92 | 98 |
93 void OnPluginMessage(const std::wstring& dll_path, | 99 void OnPluginMessage(const std::wstring& dll_path, |
94 const std::vector<uint8>& data); | 100 const std::vector<uint8>& data); |
95 void OnSetNextPageID(int32 next_page_id); | 101 void OnSetNextPageID(int32 next_page_id); |
96 void OnCreateNewView(HWND parent_hwnd, | 102 void OnCreateNewView(HWND parent_hwnd, |
97 HANDLE modal_dialog_event, | 103 HANDLE modal_dialog_event, |
98 const WebPreferences& webkit_prefs, | 104 const WebPreferences& webkit_prefs, |
99 int32 view_id); | 105 int32 view_id); |
100 void OnTransferBitmap(const SkBitmap& bitmap, int resource_id); | 106 void OnTransferBitmap(const SkBitmap& bitmap, int resource_id); |
101 void OnSetCacheCapacities(size_t min_dead_capacity, | 107 void OnSetCacheCapacities(size_t min_dead_capacity, |
(...skipping 11 matching lines...) Expand all Loading... |
113 | 119 |
114 // Used only on the background render thread to implement message routing | 120 // Used only on the background render thread to implement message routing |
115 // functionality to the consumers of the RenderThread. | 121 // functionality to the consumers of the RenderThread. |
116 MessageRouter router_; | 122 MessageRouter router_; |
117 | 123 |
118 std::wstring channel_name_; | 124 std::wstring channel_name_; |
119 scoped_ptr<IPC::SyncChannel> channel_; | 125 scoped_ptr<IPC::SyncChannel> channel_; |
120 | 126 |
121 // These objects live solely on the render thread. | 127 // These objects live solely on the render thread. |
122 VisitedLinkSlave* visited_link_slave_; | 128 VisitedLinkSlave* visited_link_slave_; |
| 129 GreasemonkeySlave* greasemonkey_slave_; |
123 | 130 |
124 scoped_ptr<RenderDnsMaster> render_dns_master_; | 131 scoped_ptr<RenderDnsMaster> render_dns_master_; |
125 | 132 |
126 scoped_ptr<ScopedRunnableMethodFactory<RenderThread> > cache_stats_factory_; | 133 scoped_ptr<ScopedRunnableMethodFactory<RenderThread> > cache_stats_factory_; |
127 | 134 |
128 scoped_ptr<NotificationService> notification_service_; | 135 scoped_ptr<NotificationService> notification_service_; |
129 | 136 |
130 int in_send_; | 137 int in_send_; |
131 | 138 |
132 DISALLOW_EVIL_CONSTRUCTORS(RenderThread); | 139 DISALLOW_EVIL_CONSTRUCTORS(RenderThread); |
133 }; | 140 }; |
134 | 141 |
135 #endif // CHROME_RENDERER_RENDER_THREAD_H__ | 142 #endif // CHROME_RENDERER_RENDER_THREAD_H__ |
136 | 143 |
OLD | NEW |