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

Side by Side Diff: remoting/protocol/fake_connection_to_host.cc

Issue 976233003: Adding the base ChromotingInstance implementation and unittests. This class will be used by the ap… (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fixing a unit test name Created 5 years, 9 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
OLDNEW
(Empty)
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.
4
5 #include "remoting/protocol/fake_connection_to_host.h"
6
7 #include "remoting/protocol/authenticator.h"
8
9 namespace remoting {
10 namespace test {
11
12 FakeConnectionToHost::FakeConnectionToHost() :
13 session_state_change_error_code_(protocol::ErrorCode::OK) {}
14
15 FakeConnectionToHost::~FakeConnectionToHost() {}
16
17 void FakeConnectionToHost::ConnectPtr(
18 SignalStrategy* signal_strategy,
19 protocol::TransportFactory* transport_factory,
20 protocol::Authenticator* authenticator,
21 const std::string& host_jid,
22 HostEventCallback* event_callback) {
23 DCHECK(CalledOnValidThread());
24
25 // WARNING: Do not store |transport_factory| or |authenticator|.
26 // This function is given raw pointers for these params instead of a
27 // scoped_ptr so the method can be called using GMock macros. Since we cannot
28 // take ownership of the pointer, it isn't safe to assign them here for later
29 // use.
30 // |event_callback| and |signal_strategy| are OK to use as they are both raw
31 // ptrs in the original method signature.
32 event_callback_ = event_callback;
33
34 SetState(CONNECTING, protocol::OK);
35 }
36
37 void FakeConnectionToHost::OnSessionStateChange(
38 protocol::Session::State state) {
39 DCHECK(CalledOnValidThread());
40 DCHECK(event_callback_);
41
42 switch (state) {
43 case protocol::Session::INITIALIZING:
44 case protocol::Session::CONNECTING:
45 case protocol::Session::ACCEPTING:
46 case protocol::Session::AUTHENTICATING:
47 // No updates for these events.
48 break;
49
50 case protocol::Session::CONNECTED:
51 SetState(CONNECTED, protocol::ErrorCode::OK);
52 break;
53
54 case protocol::Session::AUTHENTICATED:
55 SetState(AUTHENTICATED, protocol::ErrorCode::OK);
56 break;
57
58 case protocol::Session::CLOSED:
59 SetState(CLOSED, protocol::ErrorCode::OK);
60 break;
61
62 case protocol::Session::FAILED:
63 // session_state_change_error_code_ must be set before sending a FAILED
64 // session state.
65 DCHECK(session_state_change_error_code_ != protocol::ErrorCode::OK);
66 SetState(FAILED, session_state_change_error_code_);
67 break;
68 }
69 }
70
71 void FakeConnectionToHost::OnVideoChannelStatus(bool active) {
72 DCHECK(CalledOnValidThread());
73 DCHECK(event_callback_);
74
75 event_callback_->OnConnectionReady(active);
76 }
77
78 } // namespace test
79 } // namespace remoting
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698