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

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

Issue 10830072: Browser Plugin: New Implementation (Renderer Side) (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Fixed according to comments by creis@. Moved postMessage stuff out for another cl Created 8 years, 4 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
(Empty)
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
3 // found in the LICENSE file.
4
5 #include "content/renderer/browser_plugin/mock_browser_plugin_manager.h"
6
7 #include "ipc/ipc_message.h"
8 #include "content/renderer/browser_plugin/mock_browser_plugin.h"
9
10 namespace content {
11 namespace browser_plugin {
12
13 MockBrowserPluginManager::MockBrowserPluginManager() {
14 }
15
16 MockBrowserPluginManager::~MockBrowserPluginManager() {
17 }
18
19 BrowserPlugin* MockBrowserPluginManager::CreateBrowserPlugin(
20 RenderViewImpl* render_view,
21 WebKit::WebFrame* frame,
22 const WebKit::WebPluginParams& params) {
23 return new MockBrowserPlugin(browser_plugin_counter_++,
24 render_view,
25 frame,
26 params);
27 }
28
29 void MockBrowserPluginManager::Cleanup() {
30 IDMap<BrowserPlugin>::iterator iter(&instances_);
31 while (!iter.IsAtEnd()) {
32 iter.GetCurrentValue()->Cleanup();
33 iter.Advance();
34 }
35 }
36
37 bool MockBrowserPluginManager::Send(IPC::Message* msg) {
38 // This is a copy-and-paste from MockRenderThread::Send.
39 // We need to simulate a synchronous channel, thus we are going to receive
40 // through this function messages, messages with reply and reply messages.
41 // We can only handle one synchronous message at a time.
42 if (msg->is_reply()) {
43 if (reply_deserializer_.get()) {
44 reply_deserializer_->SerializeOutputParameters(*msg);
45 reply_deserializer_.reset();
46 }
47 } else {
48 if (msg->is_sync()) {
49 // We actually need to handle deleting the reply deserializer for sync
50 // messages.
51 reply_deserializer_.reset(
52 static_cast<IPC::SyncMessage*>(msg)->GetReplyDeserializer());
53 }
54 OnControlMessageReceived(*msg);
55 }
56 delete msg;
57 return true;
58 }
59
60 bool MockBrowserPluginManager::OnControlMessageReceived(
61 const IPC::Message& message) {
62 // Save the message in the sink.
63 sink_.OnMessageReceived(message);
64 return false;
65 }
66
67 } // namespace browser_plugin
68 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698