diff options
author | dbeam@chromium.org <dbeam@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2013-05-24 03:27:02 +0000 |
---|---|---|
committer | dbeam@chromium.org <dbeam@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2013-05-24 03:27:02 +0000 |
commit | 028b8ac199c3b9ef7532ae26386246ef53e61a71 (patch) | |
tree | 34abe83dddee781ae513787c87061309a6b98491 /win8/viewer | |
parent | 33826fbd796d286022b16e7de324211a1bfbbb53 (diff) | |
download | chromium_src-028b8ac199c3b9ef7532ae26386246ef53e61a71.zip chromium_src-028b8ac199c3b9ef7532ae26386246ef53e61a71.tar.gz chromium_src-028b8ac199c3b9ef7532ae26386246ef53e61a71.tar.bz2 |
Revert 201806 "Create MetroViewerProcessHost as a common base fo..."
Broke ash_unittests on Win8 Aura:
http://build.chromium.org/p/chromium.win/builders/Win8%20Aura/builds/6316
[ RUN ] AcceleratorControllerTest.Register
[912:1324:0523/094526:1371217:INFO:test_metro_viewer_process_host.cc(42)] ash::test::TestMetroViewerProcessHost::OnSetTargetSurface, target_surface = 131580
[912:1324:0523/094526:1371233:FATAL:ash_test_base.cc(149)] Check failed: !metro_viewer_host_->closed_unexpectedly().
Backtrace:
base::debug::StackTrace::StackTrace [0x100839F1+33]
logging::LogMessage::~LogMessage [0x100F6FCE+94]
ash::test::AshTestBase::TearDown [0x006DC397+471]
testing::internal::HandleExceptionsInMethodIfSupported<testing::Test,void> [0x007405FF+319]
testing::Test::Run [0x0072A525+229]
testing::TestInfo::Run [0x0072AF4D+221]
testing::TestCase::Run [0x0072B71F+239]
testing::internal::UnitTestImpl::RunAllTests [0x0073234D+701]
testing::internal::HandleExceptionsInMethodIfSupported<testing::internal::UnitTestImpl,bool> [0x00741227+327]
testing::UnitTest::Run [0x00730BB0+192]
base::TestSuite::Run [0x00756AE0+240]
main [0x0058AFA4+100]
__tmainCRTStartup [0x0075BA6F+447] (f:\dd\vctools\crt_bld\self_x86\crt\src\crtexe.c:555)
mainCRTStartup [0x0075B89F+15] (f:\dd\vctools\crt_bld\self_x86\crt\src\crtexe.c:371)
BaseThreadInitThunk [0x76D78543+14]
RtlInitializeExceptionChain [0x7775AC69+133]
RtlInitializeExceptionChain [0x7775AC3C+88]
(No symbol) [0x00000000]
[912:1324:0523/094526:1371233:FATAL:ash_test_base.cc(149)] Check failed: !metro_viewer_host_->closed_unexpectedly().
Backtrace:
base::debug::StackTrace::StackTrace [0x100839F1+33]
logging::LogMessage::~LogMessage [0x100F6FCE+94]
ash::test::AshTestBase::TearDown [0x006DC397+471]
testing::internal::HandleExceptionsInMethodIfSupported<testing::Test,void> [0x007405FF+319]
testing::Test::Run [0x0072A525+229]
testing::TestInfo::Run [0x0072AF4D+221]
testing::TestCase::Run [0x0072B71F+239]
testing::internal::UnitTestImpl::RunAllTests [0x0073234D+701]
testing::internal::HandleExceptionsInMethodIfSupported<testing::internal::UnitTestImpl,bool> [0x00741227+327]
testing::UnitTest::Run [0x00730BB0+192]
base::TestSuite::Run [0x00756AE0+240]
main [0x0058AFA4+100]
__tmainCRTStartup [0x0075BA6F+447] (f:\dd\vctools\crt_bld\self_x86\crt\src\crtexe.c:555)
mainCRTStartup [0x0075B89F+15] (f:\dd\vctools\crt_bld\self_x86\crt\src\crtexe.c:371)
BaseThreadInitThunk [0x76D78543+14]
RtlInitializeExceptionChain [0x7775AC69+133]
RtlInitializeExceptionChain [0x7775AC3C+88]
(No symbol) [0x00000000]
> Create MetroViewerProcessHost as a common base for TestMetroViewerProcessHost and ChromeMetroViewerProcessHost
>
> Bringing LaunchViewerAndWaitForConnection() to the common base so that ChromeMetroViewerProcessHost can also benefit from it (required for ash browser tests).
>
> BUG=179830
>
> Review URL: https://chromiumcodereview.appspot.com/14629025
TBR=gab@chromium.org
Review URL: https://codereview.chromium.org/15966003
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@201966 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'win8/viewer')
-rw-r--r-- | win8/viewer/metro_viewer_process_host.cc | 108 | ||||
-rw-r--r-- | win8/viewer/metro_viewer_process_host.h | 94 |
2 files changed, 0 insertions, 202 deletions
diff --git a/win8/viewer/metro_viewer_process_host.cc b/win8/viewer/metro_viewer_process_host.cc deleted file mode 100644 index f945039..0000000 --- a/win8/viewer/metro_viewer_process_host.cc +++ /dev/null @@ -1,108 +0,0 @@ -// Copyright (c) 2013 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 "win8/viewer/metro_viewer_process_host.h" - -#include <shlobj.h> - -#include "base/command_line.h" -#include "base/file_util.h" -#include "base/files/file_path.h" -#include "base/memory/ref_counted.h" -#include "base/process.h" -#include "base/string16.h" -#include "base/synchronization/waitable_event.h" -#include "base/time.h" -#include "base/win/scoped_comptr.h" -#include "ipc/ipc_message.h" -#include "ipc/ipc_message_macros.h" -#include "ui/aura/remote_root_window_host_win.h" -#include "ui/metro_viewer/metro_viewer_messages.h" - -namespace win8 { - -MetroViewerProcessHost::InternalMessageFilter::InternalMessageFilter( - MetroViewerProcessHost* owner) : owner_(owner) { -} - -void MetroViewerProcessHost::InternalMessageFilter::OnChannelConnected( - int32 /* peer_pid */) { - owner_->NotifyChannelConnected(); -} - -MetroViewerProcessHost::MetroViewerProcessHost( - const std::string& ipc_channel_name, - base::SingleThreadTaskRunner* ipc_task_runner) { - - channel_.reset(new IPC::ChannelProxy( - ipc_channel_name.c_str(), - IPC::Channel::MODE_NAMED_SERVER, - this, - ipc_task_runner)); -} - -MetroViewerProcessHost::~MetroViewerProcessHost() { -} - -base::ProcessId MetroViewerProcessHost::GetViewerProcessId() { - if (channel_) - return channel_->peer_pid(); - return base::kNullProcessId; -} - -bool MetroViewerProcessHost::LaunchViewerAndWaitForConnection( - const base::string16& app_user_model_id) { - DCHECK_EQ(base::kNullProcessId, channel_->peer_pid()); - - channel_connected_event_.reset(new base::WaitableEvent(false, false)); - - scoped_refptr<InternalMessageFilter> message_filter( - new InternalMessageFilter(this)); - channel_->AddFilter(message_filter); - - 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. - bool success = - channel_connected_event_->TimedWait(base::TimeDelta::FromSeconds(60)); - channel_connected_event_.reset(); - - // |message_filter| is only used to signal |channel_connected_event_| above - // and can thus be removed after |channel_connected_event_| is no longer - // waiting. - channel_->RemoveFilter(message_filter); - return success; -} - -bool MetroViewerProcessHost::Send(IPC::Message* msg) { - return channel_->Send(msg); -} - -bool MetroViewerProcessHost::OnMessageReceived( - const IPC::Message& message) { - DCHECK(CalledOnValidThread()); - bool handled = true; - IPC_BEGIN_MESSAGE_MAP(MetroViewerProcessHost, 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 MetroViewerProcessHost::NotifyChannelConnected() { - if (channel_connected_event_) - channel_connected_event_->Signal(); -} - -} // namespace win8 diff --git a/win8/viewer/metro_viewer_process_host.h b/win8/viewer/metro_viewer_process_host.h deleted file mode 100644 index 5be3a90..0000000 --- a/win8/viewer/metro_viewer_process_host.h +++ /dev/null @@ -1,94 +0,0 @@ -// Copyright (c) 2013 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. - -#ifndef WIN8_VIEWER_METRO_VIEWER_PROCESS_HOST_H_ -#define WIN8_VIEWER_METRO_VIEWER_PROCESS_HOST_H_ - -#include <string> - -#include "base/basictypes.h" -#include "base/memory/scoped_ptr.h" -#include "base/string16.h" -#include "base/threading/non_thread_safe.h" -#include "ipc/ipc_channel_proxy.h" -#include "ipc/ipc_listener.h" -#include "ipc/ipc_sender.h" -#include "ui/gfx/native_widget_types.h" - -namespace base { -class SingleThreadTaskRunner; -class WaitableEvent; -} - -namespace IPC { -class Message; -} - -namespace win8 { - -// Abstract base class for various Metro viewer process host implementations. -class MetroViewerProcessHost : public IPC::Listener, - public IPC::Sender, - public base::NonThreadSafe { - public: - // Initializes a viewer process host over |ipc_channel_name|. The given task - // runner correspond to a thread on which IPC::Channel is created and used - // (e.g. IO thread). Instantly connects to the viewer process if one is - // already connected to |ipc_channel_name|; a viewer can otherwise be - // launched synchronously via LaunchViewerAndWaitForConnection(). - MetroViewerProcessHost(const std::string& ipc_channel_name, - base::SingleThreadTaskRunner* ipc_task_runner); - virtual ~MetroViewerProcessHost(); - - // Returns the process id of the viewer process if one is connected to this - // host, returns base::kNullProcessId otherwise. - base::ProcessId GetViewerProcessId(); - - // Launches the viewer process associated with the given |app_user_model_id| - // and blocks until that viewer process connects or until a timeout is - // reached. Returns true if the viewer process connects before the timeout is - // reached. NOTE: this assumes that the app referred to by |app_user_model_id| - // is registered as the default browser. - bool LaunchViewerAndWaitForConnection( - const base::string16& app_user_model_id); - - private: - // IPC::Sender implementation: - virtual bool Send(IPC::Message* msg) OVERRIDE; - - // IPC::Listener implementation: - virtual bool OnMessageReceived(const IPC::Message& message) OVERRIDE; - virtual void OnChannelError() OVERRIDE = 0; - - // Called over IPC by the viewer process to tell this host that it should be - // be drawing to |target_surface|. - virtual void OnSetTargetSurface(gfx::NativeViewId target_surface) = 0; - - void NotifyChannelConnected(); - - // Inner message filter used to handle connection event on the IPC channel - // proxy's background thread. This prevents consumers of - // MetroViewerProcessHost from having to pump messages on their own message - // loop. - class InternalMessageFilter : public IPC::ChannelProxy::MessageFilter { - public: - InternalMessageFilter(MetroViewerProcessHost* owner); - - // IPC::ChannelProxy::MessageFilter implementation. - virtual void OnChannelConnected(int32 peer_pid) OVERRIDE; - - private: - MetroViewerProcessHost* owner_; - DISALLOW_COPY_AND_ASSIGN(InternalMessageFilter); - }; - - scoped_ptr<IPC::ChannelProxy> channel_; - scoped_ptr<base::WaitableEvent> channel_connected_event_; - - DISALLOW_COPY_AND_ASSIGN(MetroViewerProcessHost); -}; - -} // namespace win8 - -#endif // WIN8_VIEWER_METRO_VIEWER_PROCESS_HOST_H_ |