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