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

Side by Side Diff: content/renderer/browser_plugin/mock_browser_plugin_manager.cc

Issue 11956022: Browser Plugin: Allocate Instance IDs in BrowserPluginEmbedder instead of BrowserPluginManager (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Diff against simplified focus Created 7 years, 11 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 | Annotate | Revision Log
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/renderer/browser_plugin/mock_browser_plugin_manager.h" 5 #include "content/renderer/browser_plugin/mock_browser_plugin_manager.h"
6 6
7 #include "base/message_loop.h"
8 #include "content/common/browser_plugin_messages.h"
9 #include "content/renderer/browser_plugin/mock_browser_plugin.h"
7 #include "ipc/ipc_message.h" 10 #include "ipc/ipc_message.h"
8 #include "content/renderer/browser_plugin/mock_browser_plugin.h"
9 11
10 namespace content { 12 namespace content {
11 13
12 MockBrowserPluginManager::MockBrowserPluginManager( 14 MockBrowserPluginManager::MockBrowserPluginManager(
13 RenderViewImpl* render_view) 15 RenderViewImpl* render_view)
14 : BrowserPluginManager(render_view) { 16 : BrowserPluginManager(render_view),
17 browser_plugin_counter_(0) {
15 } 18 }
16 19
17 MockBrowserPluginManager::~MockBrowserPluginManager() { 20 MockBrowserPluginManager::~MockBrowserPluginManager() {
18 } 21 }
19 22
20 BrowserPlugin* MockBrowserPluginManager::CreateBrowserPlugin( 23 BrowserPlugin* MockBrowserPluginManager::CreateBrowserPlugin(
21 RenderViewImpl* render_view, 24 RenderViewImpl* render_view,
22 WebKit::WebFrame* frame, 25 WebKit::WebFrame* frame,
23 const WebKit::WebPluginParams& params) { 26 const WebKit::WebPluginParams& params) {
24 return new MockBrowserPlugin(++browser_plugin_counter_, 27 return new MockBrowserPlugin(render_view, frame, params);
25 render_view, 28 }
26 frame, 29
27 params); 30 void MockBrowserPluginManager::AllocateInstanceID(
31 BrowserPlugin* browser_plugin) {
32 int instance_id = browser_plugin_counter_++;
33 MessageLoop::current()->PostTask(
34 FROM_HERE,
35 base::Bind(&MockBrowserPluginManager::AllocateInstanceIDResponse,
36 this,
37 base::Unretained(browser_plugin),
38 instance_id));
39 }
40
41 void MockBrowserPluginManager::AllocateInstanceIDResponse(
42 BrowserPlugin* browser_plugin,
43 int instance_id) {
44 BrowserPluginMsg_AllocateInstanceIDResponse instance_msg(
45 browser_plugin->render_view_routing_id(), 0, instance_id);
46 browser_plugin->OnMessageReceived(instance_msg);
28 } 47 }
29 48
30 bool MockBrowserPluginManager::Send(IPC::Message* msg) { 49 bool MockBrowserPluginManager::Send(IPC::Message* msg) {
31 // This is a copy-and-paste from MockRenderThread::Send. 50 // This is a copy-and-paste from MockRenderThread::Send.
32 // We need to simulate a synchronous channel, thus we are going to receive 51 // We need to simulate a synchronous channel, thus we are going to receive
33 // through this function messages, messages with reply and reply messages. 52 // through this function messages, messages with reply and reply messages.
34 // We can only handle one synchronous message at a time. 53 // We can only handle one synchronous message at a time.
35 if (msg->is_reply()) { 54 if (msg->is_reply()) {
36 if (reply_deserializer_.get()) { 55 if (reply_deserializer_.get()) {
37 reply_deserializer_->SerializeOutputParameters(*msg); 56 reply_deserializer_->SerializeOutputParameters(*msg);
(...skipping 13 matching lines...) Expand all
51 } 70 }
52 71
53 bool MockBrowserPluginManager::OnMessageReceived( 72 bool MockBrowserPluginManager::OnMessageReceived(
54 const IPC::Message& message) { 73 const IPC::Message& message) {
55 // Save the message in the sink. 74 // Save the message in the sink.
56 sink_.OnMessageReceived(message); 75 sink_.OnMessageReceived(message);
57 return false; 76 return false;
58 } 77 }
59 78
60 } // namespace content 79 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698