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) |
| 23 : BrowserPluginGuest(instance_id, web_contents, render_view_host), |
| 24 update_rect_count_(0), |
| 25 crash_observed_(false) { |
| 26 } |
| 27 |
| 28 TestBrowserPluginGuest::~TestBrowserPluginGuest() { |
| 29 } |
| 30 |
| 31 void TestBrowserPluginGuest::SendMessageToEmbedder(IPC::Message* msg) { |
| 32 if (msg->type() == BrowserPluginMsg_UpdateRect::ID) { |
| 33 update_rect_count_++; |
| 34 if (send_message_loop_runner_) |
| 35 send_message_loop_runner_->Quit(); |
| 36 } |
| 37 BrowserPluginGuest::SendMessageToEmbedder(msg); |
| 38 } |
| 39 |
| 40 void TestBrowserPluginGuest::WaitForUpdateRectMsg() { |
| 41 // Check if we already got any UpdateRect message. |
| 42 if (update_rect_count_ > 0) |
| 43 return; |
| 44 send_message_loop_runner_= new MessageLoopRunner(); |
| 45 send_message_loop_runner_->Run(); |
| 46 } |
| 47 |
| 48 void TestBrowserPluginGuest::RenderViewGone(base::TerminationStatus status) { |
| 49 crash_observed_ = true; |
| 50 if (crash_message_loop_runner_) |
| 51 crash_message_loop_runner_->Quit(); |
| 52 BrowserPluginGuest::RenderViewGone(status); |
| 53 } |
| 54 |
| 55 void TestBrowserPluginGuest::WaitForCrashed() { |
| 56 // Check if we already observed a guest crash, return immediately if so. |
| 57 if (crash_observed_) |
| 58 return; |
| 59 crash_message_loop_runner_ = new MessageLoopRunner(); |
| 60 crash_message_loop_runner_->Run(); |
| 61 } |
| 62 |
| 63 } // namespace content |
OLD | NEW |