OLD | NEW |
(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/browser/browser_plugin/test_browser_plugin_guest.h" |
| 6 |
| 7 #include "content/browser/browser_plugin/browser_plugin_guest.h" |
| 8 #include "content/browser/renderer_host/render_view_host_impl.h" |
| 9 #include "content/browser/web_contents/web_contents_impl.h" |
| 10 #include "content/common/browser_plugin_messages.h" |
| 11 #include "content/public/test/test_utils.h" |
| 12 #include "ipc/ipc_channel_handle.h" |
| 13 #include "ipc/ipc_sync_message.h" |
| 14 |
| 15 namespace content { |
| 16 |
| 17 class BrowserPluginGuest; |
| 18 |
| 19 TestBrowserPluginGuest::TestBrowserPluginGuest( |
| 20 int instance_id, |
| 21 WebContentsImpl* web_contents, |
| 22 RenderViewHost* render_view_host) : BrowserPluginGuest(instance_id, |
| 23 web_contents, |
| 24 render_view_host), |
| 25 update_rect_count_(0), |
| 26 crash_observed_(false) { |
| 27 } |
| 28 |
| 29 TestBrowserPluginGuest::~TestBrowserPluginGuest() { |
| 30 } |
| 31 |
| 32 void TestBrowserPluginGuest::SendMessageToEmbedder(IPC::Message* msg) { |
| 33 if (msg->type() == BrowserPluginMsg_UpdateRect::ID) { |
| 34 update_rect_count_++; |
| 35 if (send_message_loop_runner_) |
| 36 send_message_loop_runner_->Quit(); |
| 37 } |
| 38 BrowserPluginGuest::SendMessageToEmbedder(msg); |
| 39 } |
| 40 |
| 41 void TestBrowserPluginGuest::WaitForUpdateRectMsg() { |
| 42 // Check if we already got any UpdateRect message. |
| 43 if (update_rect_count_ > 0) |
| 44 return; |
| 45 send_message_loop_runner_= new MessageLoopRunner(); |
| 46 send_message_loop_runner_->Run(); |
| 47 } |
| 48 |
| 49 void TestBrowserPluginGuest::RenderViewGone(base::TerminationStatus status) { |
| 50 crash_observed_ = true; |
| 51 if (crash_message_loop_runner_) |
| 52 crash_message_loop_runner_->Quit(); |
| 53 BrowserPluginGuest::RenderViewGone(status); |
| 54 } |
| 55 |
| 56 void TestBrowserPluginGuest::WaitForCrashed() { |
| 57 // Check if we already observed a guest crash, return immediately if so. |
| 58 if (crash_observed_) |
| 59 return; |
| 60 crash_message_loop_runner_ = new MessageLoopRunner(); |
| 61 crash_message_loop_runner_->Run(); |
| 62 } |
| 63 |
| 64 } // namespace content |
OLD | NEW |