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

Unified Diff: trunk/src/ash/test/test_metro_viewer_process_host.cc

Issue 15966003: Revert 201806 "Create MetroViewerProcessHost as a common base fo..." (Closed) Base URL: svn://svn.chromium.org/chrome/
Patch Set: Created 7 years, 7 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
« no previous file with comments | « trunk/src/ash/test/test_metro_viewer_process_host.h ('k') | trunk/src/chrome/browser/DEPS » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: trunk/src/ash/test/test_metro_viewer_process_host.cc
===================================================================
--- trunk/src/ash/test/test_metro_viewer_process_host.cc (revision 201965)
+++ trunk/src/ash/test/test_metro_viewer_process_host.cc (working copy)
@@ -23,15 +23,83 @@
namespace ash {
namespace test {
+TestMetroViewerProcessHost::InternalMessageFilter::InternalMessageFilter(
+ TestMetroViewerProcessHost* owner)
+ : owner_(owner) {
+}
+
+void TestMetroViewerProcessHost::InternalMessageFilter::OnChannelConnected(
+ int32 peer_pid) {
+ owner_->NotifyChannelConnected();
+}
+
TestMetroViewerProcessHost::TestMetroViewerProcessHost(
- const std::string& ipc_channel_name,
- base::SingleThreadTaskRunner* ipc_task_runner)
- : MetroViewerProcessHost(ipc_channel_name, ipc_task_runner) {
+ const std::string& ipc_channel_name)
+ : ipc_thread_("test_metro_viewer_ipc_thread"),
+ channel_connected_event_(false, false),
+ closed_unexpectedly_(false) {
+
+ base::Thread::Options options;
+ options.message_loop_type = base::MessageLoop::TYPE_IO;
+ ipc_thread_.StartWithOptions(options);
+
+ channel_.reset(new IPC::ChannelProxy(
+ ipc_channel_name.c_str(),
+ IPC::Channel::MODE_NAMED_SERVER,
+ this,
+ ipc_thread_.message_loop_proxy()));
+
+ channel_->AddFilter(new InternalMessageFilter(this));
}
TestMetroViewerProcessHost::~TestMetroViewerProcessHost() {
+ channel_.reset();
+ ipc_thread_.Stop();
}
+void TestMetroViewerProcessHost::NotifyChannelConnected() {
+ channel_connected_event_.Signal();
+}
+
+bool TestMetroViewerProcessHost::LaunchViewerAndWaitForConnection(
+ const base::string16& app_user_model_id) {
+ // Activate the viewer process. NOTE: This assumes that the viewer process is
+ // registered as the default browser using the provided |app_user_model_id|.
+
+ // TODO(robertshield): Initialize COM at test suite startup.
+ base::win::ScopedCOMInitializer com_initializer;
+
+ base::win::ScopedComPtr<IApplicationActivationManager> activator;
+ HRESULT hr = activator.CreateInstance(CLSID_ApplicationActivationManager);
+ if (SUCCEEDED(hr)) {
+ DWORD pid = 0;
+ hr = activator->ActivateApplication(
+ app_user_model_id.c_str(), L"open", AO_NONE, &pid);
+ }
+
+ LOG_IF(ERROR, FAILED(hr)) << "Tried and failed to launch Metro Chrome. "
+ << "hr=" << std::hex << hr;
+
+ // Having launched the viewer process, now we wait for it to connect.
+ return channel_connected_event_.TimedWait(base::TimeDelta::FromSeconds(60));
+}
+
+bool TestMetroViewerProcessHost::Send(IPC::Message* msg) {
+ return channel_->Send(msg);
+}
+
+bool TestMetroViewerProcessHost::OnMessageReceived(
+ const IPC::Message& message) {
+ DCHECK(CalledOnValidThread());
+ bool handled = true;
+ IPC_BEGIN_MESSAGE_MAP(TestMetroViewerProcessHost, message)
+ IPC_MESSAGE_HANDLER(MetroViewerHostMsg_SetTargetSurface, OnSetTargetSurface)
+ IPC_MESSAGE_UNHANDLED(handled = false)
+ IPC_END_MESSAGE_MAP()
+ return handled ? true :
+ aura::RemoteRootWindowHostWin::Instance()->OnMessageReceived(message);
+}
+
void TestMetroViewerProcessHost::OnChannelError() {
closed_unexpectedly_ = true;
aura::RemoteRootWindowHostWin::Instance()->Disconnected();
« no previous file with comments | « trunk/src/ash/test/test_metro_viewer_process_host.h ('k') | trunk/src/chrome/browser/DEPS » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698