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

Unified Diff: content/renderer/browser_plugin/tests/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 leaky Persistents in BrowserPlugin Created 8 years, 5 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 side-by-side diff with in-line comments
Download patch
Index: content/renderer/browser_plugin/tests/mock_browser_plugin_manager.cc
diff --git a/content/renderer/browser_plugin/tests/mock_browser_plugin_manager.cc b/content/renderer/browser_plugin/tests/mock_browser_plugin_manager.cc
new file mode 100644
index 0000000000000000000000000000000000000000..9ed804fbf83c350c449d8c5ab9dea01a4bdc4107
--- /dev/null
+++ b/content/renderer/browser_plugin/tests/mock_browser_plugin_manager.cc
@@ -0,0 +1,69 @@
+// Copyright (c) 2012 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include "content/renderer/browser_plugin/tests/mock_browser_plugin_manager.h"
+
+#include "ipc/ipc_message.h"
+#include "content/renderer/browser_plugin/tests/mock_browser_plugin.h"
+
+namespace content {
+namespace browser_plugin {
+
+MockBrowserPluginManager::MockBrowserPluginManager() {
+}
+
+MockBrowserPluginManager::~MockBrowserPluginManager() {
+}
+
+BrowserPlugin* MockBrowserPluginManager::CreateBrowserPlugin(
+ RenderViewImpl* render_view,
+ WebKit::WebFrame* frame,
+ const WebKit::WebPluginParams& params) {
+ return new MockBrowserPlugin(browser_plugin_counter_++,
+ render_view,
+ render_view->GetRoutingID(),
+ frame,
+ params);
+}
+
+void MockBrowserPluginManager::Cleanup() {
+ IDMap<BrowserPlugin>::iterator iter(&instances_);
+ while (!iter.IsAtEnd()) {
+ iter.GetCurrentValue()->Cleanup();
+ iter.Advance();
+ }
+}
+
+bool MockBrowserPluginManager::Send(IPC::Message* msg) {
+ // This is a copy-and-paste from MockRenderThread::Send.
Charlie Reis 2012/08/01 23:20:51 I don't suppose there's a way to share this code?
Fady Samuel 2012/08/02 18:32:47 I'm not going to address this immediately, but I'l
+ // We need to simulate a synchronous channel, thus we are going to receive
+ // through this function messages, messages with reply and reply messages.
+ // We can only handle one synchronous message at a time.
+ if (msg->is_reply()) {
+ if (reply_deserializer_.get()) {
+ reply_deserializer_->SerializeOutputParameters(*msg);
+ reply_deserializer_.reset();
+ }
+ } else {
+ if (msg->is_sync()) {
+ // We actually need to handle deleting the reply deserializer for sync
+ // messages.
+ reply_deserializer_.reset(
+ static_cast<IPC::SyncMessage*>(msg)->GetReplyDeserializer());
+ }
+ OnControlMessageReceived(*msg);
+ }
+ delete msg;
+ return true;
+}
+
+bool MockBrowserPluginManager::OnControlMessageReceived(
+ const IPC::Message& message) {
+ // Save the message in the sink.
+ sink_.OnMessageReceived(message);
+ return false;
+}
+
+} // namespace browser_plugin
+} // namespace content

Powered by Google App Engine
This is Rietveld 408576698