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

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: Addressing Sergey's feedback 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 session_config_(protocol::SessionConfig::ForTest()) {
15 }
16
17 FakeConnectionToHost::~FakeConnectionToHost() {
18 }
19
20 void FakeConnectionToHost::Connect(
21 SignalStrategy* signal_strategy,
22 scoped_ptr<protocol::TransportFactory> transport_factory,
23 scoped_ptr<protocol::Authenticator> authenticator,
24 const std::string& host_jid,
25 HostEventCallback* event_callback) {
26 DCHECK(CalledOnValidThread());
27 DCHECK(event_callback);
28
29 event_callback_ = event_callback;
30
31 SetState(CONNECTING, protocol::OK);
32 }
33
34 void FakeConnectionToHost::OnSessionStateChange(
Sergey Ulanov 2015/03/11 00:09:51 I'm not sure why you need this. FakeConnectionToHo
joedow 2015/03/11 19:06:39 Done.
35 protocol::Session::State state) {
36 DCHECK(CalledOnValidThread());
37 DCHECK(event_callback_);
38
39 switch (state) {
40 case protocol::Session::INITIALIZING:
41 case protocol::Session::CONNECTING:
42 case protocol::Session::ACCEPTING:
43 case protocol::Session::AUTHENTICATING:
44 // No updates for these events.
45 break;
46
47 case protocol::Session::CONNECTED:
48 SetState(CONNECTED, protocol::ErrorCode::OK);
49 break;
50
51 case protocol::Session::AUTHENTICATED:
52 SetState(AUTHENTICATED, protocol::ErrorCode::OK);
53 break;
54
55 case protocol::Session::CLOSED:
56 SetState(CLOSED, protocol::ErrorCode::OK);
57 break;
58
59 case protocol::Session::FAILED:
60 // session_state_change_error_code_ must be set before sending a FAILED
61 // session state.
62 DCHECK(session_state_change_error_code_ != protocol::ErrorCode::OK);
63 SetState(FAILED, session_state_change_error_code_);
64 break;
65 }
66 }
67
68 void FakeConnectionToHost::OnVideoChannelStatus(bool active) {
69 DCHECK(CalledOnValidThread());
70 DCHECK(event_callback_);
71
72 event_callback_->OnConnectionReady(active);
73 }
74
75 const protocol::SessionConfig& FakeConnectionToHost::config() {
76 return session_config_;
77 }
78
79 protocol::HostStub* FakeConnectionToHost::host_stub() {
80 return &mock_host_stub_;
81 }
82
83 } // namespace test
84 } // namespace remoting
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698