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

Side by Side Diff: trunk/src/ash/test/test_metro_viewer_process_host.h

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 unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2013 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #ifndef ASH_TEST_TEST_METRO_VIEWER_PROCESS_HOST_H_ 5 #ifndef ASH_TEST_TEST_METRO_VIEWER_PROCESS_HOST_H_
6 #define ASH_TEST_TEST_METRO_VIEWER_PROCESS_HOST_H_ 6 #define ASH_TEST_TEST_METRO_VIEWER_PROCESS_HOST_H_
7 7
8 #include <string> 8 #include <string>
9 9
10 #include "win8/viewer/metro_viewer_process_host.h" 10 #include "base/memory/scoped_ptr.h"
11 #include "base/synchronization/waitable_event.h"
12 #include "base/threading/non_thread_safe.h"
13 #include "base/threading/thread.h"
14 #include "ipc/ipc_channel_proxy.h"
15 #include "ipc/ipc_listener.h"
16 #include "ipc/ipc_sender.h"
17 #include "ui/gfx/native_widget_types.h"
11 18
12 class AcceleratedSurface; 19 class AcceleratedSurface;
13 20
14 namespace ash { 21 namespace ash {
15 namespace test { 22 namespace test {
16 23
17 class TestMetroViewerProcessHost : public win8::MetroViewerProcessHost { 24 class TestMetroViewerProcessHost : public IPC::Listener,
25 public IPC::Sender,
26 public base::NonThreadSafe {
18 public: 27 public:
19 TestMetroViewerProcessHost(const std::string& ipc_channel_name, 28 explicit TestMetroViewerProcessHost(const std::string& ipc_channel_name);
20 base::SingleThreadTaskRunner* ipc_task_runner);
21 virtual ~TestMetroViewerProcessHost(); 29 virtual ~TestMetroViewerProcessHost();
22 30
31 // Launches the viewer process associated with the given |app_user_model_id|
32 // and blocks until that viewer process connects or until a timeout is
33 // reached. Returns true if the viewer process connects before the timeout is
34 // reached.
35 bool LaunchViewerAndWaitForConnection(
36 const base::string16& app_user_model_id);
37
38 // IPC::Sender implementation:
39 virtual bool Send(IPC::Message* msg) OVERRIDE;
40
41 // IPC::Listener implementation:
42 virtual bool OnMessageReceived(const IPC::Message& message) OVERRIDE;
43 virtual void OnChannelError() OVERRIDE;
44
23 bool closed_unexpectedly() { return closed_unexpectedly_; } 45 bool closed_unexpectedly() { return closed_unexpectedly_; }
24 46
25 private: 47 private:
26 // win8::MetroViewerProcessHost implementation 48 void OnSetTargetSurface(gfx::NativeViewId target_surface);
27 virtual void OnChannelError() OVERRIDE; 49
28 virtual void OnSetTargetSurface(gfx::NativeViewId target_surface) OVERRIDE; 50 void NotifyChannelConnected();
51
52 // Inner message filter used to handle connection event on the IPC channel
53 // proxy's background thread. This prevents consumers of
54 // TestMetroViewerProcessHost from having to pump messages on their own
55 // message loop.
56 class InternalMessageFilter : public IPC::ChannelProxy::MessageFilter {
57 public:
58 InternalMessageFilter(TestMetroViewerProcessHost* owner);
59
60 // IPC::ChannelProxy::MessageFilter implementation.
61 virtual void OnChannelConnected(int32 peer_pid) OVERRIDE;
62
63 private:
64 TestMetroViewerProcessHost* owner_;
65 DISALLOW_COPY_AND_ASSIGN(InternalMessageFilter);
66 };
67
68 // Members related to the IPC channel. Note that the order is important
69 // here as ipc_thread_ should be destroyed after channel_.
70 base::Thread ipc_thread_;
71 scoped_ptr<IPC::ChannelProxy> channel_;
72 base::WaitableEvent channel_connected_event_;
29 73
30 scoped_ptr<AcceleratedSurface> backing_surface; 74 scoped_ptr<AcceleratedSurface> backing_surface;
31 75
32 bool closed_unexpectedly_; 76 bool closed_unexpectedly_;
33 77
34 DISALLOW_COPY_AND_ASSIGN(TestMetroViewerProcessHost); 78 DISALLOW_COPY_AND_ASSIGN(TestMetroViewerProcessHost);
35 }; 79 };
36 80
37 81
38 } // namespace test 82 } // namespace test
39 } // namespace ash 83 } // namespace ash
40 84
41 #endif // ASH_TEST_TEST_METRO_VIEWER_PROCESS_HOST_H_ 85 #endif // ASH_TEST_TEST_METRO_VIEWER_PROCESS_HOST_H_
OLDNEW
« no previous file with comments | « trunk/src/ash/test/ash_test_base.cc ('k') | trunk/src/ash/test/test_metro_viewer_process_host.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698