Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(59)

Side by Side Diff: content/public/test/mock_render_thread.cc

Issue 1303773002: Give the main frame a RenderWidget. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: plumb through surface ID *and* widget surface ID for window.open Created 5 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 #include "content/public/test/mock_render_thread.h" 5 #include "content/public/test/mock_render_thread.h"
6 6
7 #include "base/single_thread_task_runner.h" 7 #include "base/single_thread_task_runner.h"
8 #include "base/thread_task_runner_handle.h" 8 #include "base/thread_task_runner_handle.h"
9 #include "content/common/frame_messages.h" 9 #include "content/common/frame_messages.h"
10 #include "content/common/view_messages.h" 10 #include "content/common/view_messages.h"
11 #include "content/public/renderer/render_process_observer.h" 11 #include "content/public/renderer/render_process_observer.h"
12 #include "content/renderer/render_view_impl.h" 12 #include "content/renderer/render_view_impl.h"
13 #include "ipc/ipc_message_utils.h" 13 #include "ipc/ipc_message_utils.h"
14 #include "ipc/ipc_sync_message.h" 14 #include "ipc/ipc_sync_message.h"
15 #include "ipc/message_filter.h" 15 #include "ipc/message_filter.h"
16 #include "testing/gtest/include/gtest/gtest.h" 16 #include "testing/gtest/include/gtest/gtest.h"
17 #include "third_party/WebKit/public/web/WebScriptController.h" 17 #include "third_party/WebKit/public/web/WebScriptController.h"
18 18
19 namespace content { 19 namespace content {
20 20
21 MockRenderThread::MockRenderThread() 21 MockRenderThread::MockRenderThread()
22 : routing_id_(0), 22 : routing_id_(0),
23 surface_id_(0), 23 surface_id_(0),
24 opener_id_(0), 24 opener_id_(0),
25 new_window_routing_id_(0), 25 new_window_routing_id_(0),
26 new_window_main_frame_routing_id_(0), 26 new_window_main_frame_routing_id_(0),
27 new_frame_routing_id_(0) { 27 new_window_main_frame_widget_routing_id_(0),
28 } 28 new_frame_routing_id_(0) {}
29 29
30 MockRenderThread::~MockRenderThread() { 30 MockRenderThread::~MockRenderThread() {
31 while (!filters_.empty()) { 31 while (!filters_.empty()) {
32 scoped_refptr<IPC::MessageFilter> filter = filters_.back(); 32 scoped_refptr<IPC::MessageFilter> filter = filters_.back();
33 filters_.pop_back(); 33 filters_.pop_back();
34 filter->OnFilterRemoved(); 34 filter->OnFilterRemoved();
35 } 35 }
36 } 36 }
37 37
38 // Called by the Widget. Used to send messages to the browser. 38 // Called by the Widget. Used to send messages to the browser.
(...skipping 169 matching lines...) Expand 10 before | Expand all | Expand 10 after
208 int* route_id, 208 int* route_id,
209 int* surface_id) { 209 int* surface_id) {
210 opener_id_ = opener_id; 210 opener_id_ = opener_id;
211 *route_id = routing_id_; 211 *route_id = routing_id_;
212 *surface_id = surface_id_; 212 *surface_id = surface_id_;
213 } 213 }
214 214
215 // The View expects to be returned a valid route_id different from its own. 215 // The View expects to be returned a valid route_id different from its own.
216 void MockRenderThread::OnCreateWindow( 216 void MockRenderThread::OnCreateWindow(
217 const ViewHostMsg_CreateWindow_Params& params, 217 const ViewHostMsg_CreateWindow_Params& params,
218 int* route_id, 218 ViewHostMsg_CreateWindow_Reply* reply) {
219 int* main_frame_route_id, 219 reply->route_id = new_window_routing_id_;
220 int* surface_id, 220 reply->surface_id = surface_id_;
221 int64* cloned_session_storage_namespace_id) { 221 reply->main_frame_route_id = new_window_main_frame_routing_id_;
222 *route_id = new_window_routing_id_; 222 reply->main_frame_widget_route_id = new_window_main_frame_widget_routing_id_;
223 *main_frame_route_id = new_window_main_frame_routing_id_; 223 reply->widget_surface_id = surface_id_ + 1;
ncarter (slow) 2015/09/03 20:24:37 How much of a hack is this +1?
dcheng 2015/09/03 21:29:24 I'd say it's a moderate hack, but it seems to work
224 *surface_id = surface_id_; 224 reply->cloned_session_storage_namespace_id = 0;
225 *cloned_session_storage_namespace_id = 0;
226 } 225 }
227 226
228 // The Frame expects to be returned a valid route_id different from its own. 227 // The Frame expects to be returned a valid route_id different from its own.
229 void MockRenderThread::OnCreateChildFrame(int new_frame_routing_id, 228 void MockRenderThread::OnCreateChildFrame(int new_frame_routing_id,
230 blink::WebTreeScopeType scope, 229 blink::WebTreeScopeType scope,
231 const std::string& frame_name, 230 const std::string& frame_name,
232 blink::WebSandboxFlags sandbox_flags, 231 blink::WebSandboxFlags sandbox_flags,
233 int* new_render_frame_id) { 232 int* new_render_frame_id) {
234 *new_render_frame_id = new_frame_routing_id_++; 233 *new_render_frame_id = new_frame_routing_id_++;
235 } 234 }
(...skipping 26 matching lines...) Expand all
262 void MockRenderThread::OnDuplicateSection( 261 void MockRenderThread::OnDuplicateSection(
263 base::SharedMemoryHandle renderer_handle, 262 base::SharedMemoryHandle renderer_handle,
264 base::SharedMemoryHandle* browser_handle) { 263 base::SharedMemoryHandle* browser_handle) {
265 // We don't have to duplicate the input handles since RenderViewTest does not 264 // We don't have to duplicate the input handles since RenderViewTest does not
266 // separate a browser process from a renderer process. 265 // separate a browser process from a renderer process.
267 *browser_handle = renderer_handle; 266 *browser_handle = renderer_handle;
268 } 267 }
269 #endif // defined(OS_WIN) 268 #endif // defined(OS_WIN)
270 269
271 } // namespace content 270 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698