| 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_PUBLIC_TEST_MOCK_RENDER_THREAD_H_ | 5 #ifndef CONTENT_PUBLIC_TEST_MOCK_RENDER_THREAD_H_ |
| 6 #define CONTENT_PUBLIC_TEST_MOCK_RENDER_THREAD_H_ | 6 #define CONTENT_PUBLIC_TEST_MOCK_RENDER_THREAD_H_ |
| 7 | 7 |
| 8 #include "base/memory/shared_memory.h" | 8 #include "base/memory/shared_memory.h" |
| 9 #include "base/observer_list.h" | 9 #include "base/observer_list.h" |
| 10 #include "base/strings/string16.h" | 10 #include "base/strings/string16.h" |
| (...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 93 } | 93 } |
| 94 | 94 |
| 95 bool has_widget() const { | 95 bool has_widget() const { |
| 96 return (widget_ != NULL); | 96 return (widget_ != NULL); |
| 97 } | 97 } |
| 98 | 98 |
| 99 void set_new_window_routing_id(int32 id) { | 99 void set_new_window_routing_id(int32 id) { |
| 100 new_window_routing_id_ = id; | 100 new_window_routing_id_ = id; |
| 101 } | 101 } |
| 102 | 102 |
| 103 void set_new_frame_routing_id(int32 id) { |
| 104 new_frame_routing_id_ = id; |
| 105 } |
| 106 |
| 103 // Simulates the Widget receiving a close message. This should result | 107 // Simulates the Widget receiving a close message. This should result |
| 104 // on releasing the internal reference counts and destroying the internal | 108 // on releasing the internal reference counts and destroying the internal |
| 105 // state. | 109 // state. |
| 106 void SendCloseMessage(); | 110 void SendCloseMessage(); |
| 107 | 111 |
| 108 protected: | 112 protected: |
| 109 // This function operates as a regular IPC listener. Subclasses | 113 // This function operates as a regular IPC listener. Subclasses |
| 110 // overriding this should first delegate to this implementation. | 114 // overriding this should first delegate to this implementation. |
| 111 virtual bool OnMessageReceived(const IPC::Message& msg); | 115 virtual bool OnMessageReceived(const IPC::Message& msg); |
| 112 | 116 |
| 113 // Dispatches control messages to observers. | 117 // Dispatches control messages to observers. |
| 114 bool OnControlMessageReceived(const IPC::Message& msg); | 118 bool OnControlMessageReceived(const IPC::Message& msg); |
| 115 | 119 |
| 116 // The Widget expects to be returned valid route_id. | 120 // The Widget expects to be returned valid route_id. |
| 117 void OnCreateWidget(int opener_id, | 121 void OnCreateWidget(int opener_id, |
| 118 blink::WebPopupType popup_type, | 122 blink::WebPopupType popup_type, |
| 119 int* route_id, | 123 int* route_id, |
| 120 int* surface_id); | 124 int* surface_id); |
| 121 | 125 |
| 122 // The View expects to be returned a valid route_id different from its own. | 126 // The View expects to be returned a valid route_id different from its own. |
| 123 // We do not keep track of the newly created widget in MockRenderThread, | 127 // We do not keep track of the newly created widget in MockRenderThread, |
| 124 // so it must be cleaned up on its own. | 128 // so it must be cleaned up on its own. |
| 125 void OnCreateWindow( | 129 void OnCreateWindow( |
| 126 const ViewHostMsg_CreateWindow_Params& params, | 130 const ViewHostMsg_CreateWindow_Params& params, |
| 127 int* route_id, | 131 int* route_id, |
| 128 int* main_frame_route_id, | 132 int* main_frame_route_id, |
| 129 int* surface_id, | 133 int* surface_id, |
| 130 int64* cloned_session_storage_namespace_id); | 134 int64* cloned_session_storage_namespace_id); |
| 131 | 135 |
| 136 // The Frame expects to be returned a valid route_id different from its own. |
| 137 void OnCreateChildFrame(int new_frame_routing_id, |
| 138 int64 parent_frame_id, |
| 139 int64 frame_id, |
| 140 const std::string& frame_name, |
| 141 int* new_render_frame_id); |
| 142 |
| 132 #if defined(OS_WIN) | 143 #if defined(OS_WIN) |
| 133 void OnDuplicateSection(base::SharedMemoryHandle renderer_handle, | 144 void OnDuplicateSection(base::SharedMemoryHandle renderer_handle, |
| 134 base::SharedMemoryHandle* browser_handle); | 145 base::SharedMemoryHandle* browser_handle); |
| 135 #endif | 146 #endif |
| 136 | 147 |
| 137 IPC::TestSink sink_; | 148 IPC::TestSink sink_; |
| 138 | 149 |
| 139 // Routing id what will be assigned to the Widget. | 150 // Routing id what will be assigned to the Widget. |
| 140 int32 routing_id_; | 151 int32 routing_id_; |
| 141 | 152 |
| 142 // Surface id what will be assigned to the Widget. | 153 // Surface id what will be assigned to the Widget. |
| 143 int32 surface_id_; | 154 int32 surface_id_; |
| 144 | 155 |
| 145 // Opener id reported by the Widget. | 156 // Opener id reported by the Widget. |
| 146 int32 opener_id_; | 157 int32 opener_id_; |
| 147 | 158 |
| 148 // We only keep track of one Widget, we learn its pointer when it | 159 // We only keep track of one Widget, we learn its pointer when it |
| 149 // adds a new route. We do not keep track of Widgets created with | 160 // adds a new route. We do not keep track of Widgets created with |
| 150 // OnCreateWindow. | 161 // OnCreateWindow. |
| 151 IPC::Listener* widget_; | 162 IPC::Listener* widget_; |
| 152 | 163 |
| 153 // Routing id that will be assigned to a CreateWindow Widget. | 164 // Routing id that will be assigned to a CreateWindow Widget. |
| 154 int32 new_window_routing_id_; | 165 int32 new_window_routing_id_; |
| 155 int32 new_window_main_frame_routing_id_; | 166 int32 new_window_main_frame_routing_id_; |
| 167 int32 new_frame_routing_id_; |
| 156 | 168 |
| 157 // The last known good deserializer for sync messages. | 169 // The last known good deserializer for sync messages. |
| 158 scoped_ptr<IPC::MessageReplyDeserializer> reply_deserializer_; | 170 scoped_ptr<IPC::MessageReplyDeserializer> reply_deserializer_; |
| 159 | 171 |
| 160 // A list of message filters added to this thread. | 172 // A list of message filters added to this thread. |
| 161 std::vector<scoped_refptr<IPC::ChannelProxy::MessageFilter> > filters_; | 173 std::vector<scoped_refptr<IPC::ChannelProxy::MessageFilter> > filters_; |
| 162 | 174 |
| 163 // Observers to notify. | 175 // Observers to notify. |
| 164 ObserverList<RenderProcessObserver> observers_; | 176 ObserverList<RenderProcessObserver> observers_; |
| 165 }; | 177 }; |
| 166 | 178 |
| 167 } // namespace content | 179 } // namespace content |
| 168 | 180 |
| 169 #endif // CONTENT_PUBLIC_TEST_MOCK_RENDER_THREAD_H_ | 181 #endif // CONTENT_PUBLIC_TEST_MOCK_RENDER_THREAD_H_ |
| OLD | NEW |