OOPIF: Fix the new task manager to show the correct proc IDs of subframe procs
[chromium-blink-merge.git] / remoting / test / test_chromoting_client.h
blobcb0c730b0837483ab3eb038ef100011107c3f84a
1 // Copyright 2015 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.
5 #ifndef REMOTING_TEST_TEST_CHROMOTING_CLIENT_H_
6 #define REMOTING_TEST_TEST_CHROMOTING_CLIENT_H_
8 #include <string>
10 #include "base/memory/ref_counted.h"
11 #include "base/memory/scoped_ptr.h"
12 #include "base/observer_list.h"
13 #include "remoting/client/chromoting_client.h"
14 #include "remoting/client/client_user_interface.h"
15 #include "remoting/protocol/clipboard_filter.h"
16 #include "remoting/protocol/cursor_shape_stub.h"
17 #include "remoting/test/remote_connection_observer.h"
19 namespace remoting {
21 class ClientContext;
22 class XmppSignalStrategy;
23 class VideoRenderer;
25 namespace protocol {
26 class ClipboardStub;
27 class HostStub;
28 class InputStub;
29 } // namespace protocol
31 namespace test {
33 struct ConnectionSetupInfo;
35 // Manages a chromoting connection to a remote host. Destroying a
36 // TestChromotingClient object with an active connection will close it.
37 // Must be used from a thread running an IO message loop.
38 // RemoteConnectionObserver objects must not destroy this class within a
39 // callback.
40 // A VideoRenderer can be passed in to customize the connection.
41 class TestChromotingClient : public ClientUserInterface,
42 public protocol::ClipboardStub,
43 public protocol::CursorShapeStub {
44 public:
45 TestChromotingClient();
46 explicit TestChromotingClient(scoped_ptr<VideoRenderer> video_renderer);
47 ~TestChromotingClient() override;
49 // Starts a Chromoting connection using the specified connection setup info.
50 void StartConnection(const ConnectionSetupInfo& connection_setup_info);
52 // Ends the current remote connection and updates the connection state.
53 void EndConnection();
55 // Stubs used to send messages to the remote host.
56 protocol::ClipboardStub* clipboard_forwarder() {
57 return chromoting_client_->clipboard_forwarder();
59 protocol::HostStub* host_stub() { return chromoting_client_->host_stub(); }
60 protocol::InputStub* input_stub() { return chromoting_client_->input_stub(); }
62 // Registers an observer which will be notfied when remote connection events
63 // occur. Registered Observers must not tear-down this object on receipt of
64 // these callbacks. The callbacks should be used for informational purposes.
65 void AddRemoteConnectionObserver(RemoteConnectionObserver* observer);
67 // Unregisters an observerer from notifications for remote connection events.
68 void RemoveRemoteConnectionObserver(RemoteConnectionObserver* observer);
70 // Used to set a fake/mock connection object for TestChromotingClient tests.
71 void SetConnectionToHostForTests(
72 scoped_ptr<protocol::ConnectionToHost> connection_to_host);
74 private:
75 // ClientUserInterface interface.
76 void OnConnectionState(protocol::ConnectionToHost::State state,
77 protocol::ErrorCode error_code) override;
78 void OnConnectionReady(bool ready) override;
79 void OnRouteChanged(const std::string& channel_name,
80 const protocol::TransportRoute& route) override;
81 void SetCapabilities(const std::string& capabilities) override;
82 void SetPairingResponse(
83 const protocol::PairingResponse& pairing_response) override;
84 void DeliverHostMessage(const protocol::ExtensionMessage& message) override;
85 protocol::ClipboardStub* GetClipboardStub() override;
86 protocol::CursorShapeStub* GetCursorShapeStub() override;
88 // protocol::ClipboardStub interface.
89 void InjectClipboardEvent(const protocol::ClipboardEvent& event) override;
91 // protocol::CursorShapeStub interface.
92 void SetCursorShape(const protocol::CursorShapeInfo& cursor_shape) override;
94 // Tracks the current connection state.
95 protocol::ConnectionToHost::State connection_to_host_state_;
97 // Tracks the most recent connection error code seen.
98 protocol::ErrorCode connection_error_code_;
100 // List of observers which are notified when remote connection events occur.
101 // We specify true below for the 'check_empty' flag so the list will check to
102 // see if all observers have been unregistered when it is destroyed.
103 base::ObserverList<RemoteConnectionObserver, true> connection_observers_;
105 // ConnectionToHost used by TestChromotingClient tests.
106 scoped_ptr<protocol::ConnectionToHost> test_connection_to_host_;
108 // Creates and manages the connection to the remote host.
109 scoped_ptr<ChromotingClient> chromoting_client_;
111 // Manages the threads and task runners for |chromoting_client_|.
112 scoped_ptr<ClientContext> client_context_;
114 // Processes video packets from the host.
115 scoped_ptr<VideoRenderer> video_renderer_;
117 // Used to establish an XMPP connection with the google talk service.
118 scoped_ptr<XmppSignalStrategy> signal_strategy_;
120 DISALLOW_COPY_AND_ASSIGN(TestChromotingClient);
123 } // namespace test
124 } // namespace remoting
126 #endif // REMOTING_TEST_TEST_CHROMOTING_CLIENT_H_