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

Side by Side Diff: remoting/test/test_chromoting_client.cc

Issue 1238343002: Added ConnectionTimeObserver to calculate the times to authenticate and connect. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Removed timer from observer, used print friendly string in TestChromotingClient, and made modificat… Created 5 years, 4 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
1 // Copyright 2015 The Chromium Authors. All rights reserved. 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 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 #include "remoting/test/test_chromoting_client.h" 5 #include "remoting/test/test_chromoting_client.h"
6 6
7 #include <string> 7 #include <string>
8 #include <vector> 8 #include <vector>
9 9
10 #include "base/logging.h" 10 #include "base/logging.h"
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after
53 } 53 }
54 } 54 }
55 55
56 void FetchSecret( 56 void FetchSecret(
57 const std::string& client_secret, 57 const std::string& client_secret,
58 bool pairing_expected, 58 bool pairing_expected,
59 const remoting::protocol::SecretFetchedCallback& secret_fetched_callback) { 59 const remoting::protocol::SecretFetchedCallback& secret_fetched_callback) {
60 secret_fetched_callback.Run(client_secret); 60 secret_fetched_callback.Run(client_secret);
61 } 61 }
62 62
63 const char* ConnectionStateToFriendlyString(
64 remoting::protocol::ConnectionToHost::State state) {
65 switch (state) {
66 case remoting::protocol::ConnectionToHost::INITIALIZING:
67 return "INITIALIZING";
68
69 case remoting::protocol::ConnectionToHost::CONNECTING:
70 return "CONNECTING";
71
72 case remoting::protocol::ConnectionToHost::AUTHENTICATED:
73 return "AUTHENTICATED";
74
75 case remoting::protocol::ConnectionToHost::CONNECTED:
76 return "CONNECTED";
77
78 case remoting::protocol::ConnectionToHost::CLOSED:
79 return "CLOSED";
80
81 case remoting::protocol::ConnectionToHost::FAILED:
82 return "FAILED";
83
84 default:
85 LOG(ERROR) << "Unknown connection state: '" << state << "'";
86 return "UNKNOWN";
87 }
88 }
89
90 const char* ProtocolErrorToFriendlyString( 63 const char* ProtocolErrorToFriendlyString(
joedow 2015/07/27 21:45:45 Per my previous comment about adding a pretty prin
tonychun 2015/07/28 17:53:45 Done.
91 remoting::protocol::ErrorCode error_code) { 64 remoting::protocol::ErrorCode error_code) {
92 switch (error_code) { 65 switch (error_code) {
93 case remoting::protocol::OK: 66 case remoting::protocol::OK:
94 return "NONE"; 67 return "NONE";
95 68
96 case remoting::protocol::PEER_IS_OFFLINE: 69 case remoting::protocol::PEER_IS_OFFLINE:
97 return "PEER_IS_OFFLINE"; 70 return "PEER_IS_OFFLINE";
98 71
99 case remoting::protocol::SESSION_REJECTED: 72 case remoting::protocol::SESSION_REJECTED:
100 return "SESSION_REJECTED"; 73 return "SESSION_REJECTED";
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after
141 : video_renderer_(video_renderer.Pass()) { 114 : video_renderer_(video_renderer.Pass()) {
142 TestChromotingClient(); 115 TestChromotingClient();
143 } 116 }
144 117
145 TestChromotingClient::~TestChromotingClient() { 118 TestChromotingClient::~TestChromotingClient() {
146 // Ensure any connections are closed and the members are destroyed in the 119 // Ensure any connections are closed and the members are destroyed in the
147 // appropriate order. 120 // appropriate order.
148 EndConnection(); 121 EndConnection();
149 } 122 }
150 123
124 // static
joedow 2015/07/27 21:45:44 please remove comment, it isn't needed in the impl
tonychun 2015/07/28 17:53:45 Done.
125 const char* TestChromotingClient::ConnectionStateToFriendlyString(
126 remoting::protocol::ConnectionToHost::State state) {
127 switch (state) {
128 case remoting::protocol::ConnectionToHost::INITIALIZING:
129 return "INITIALIZING";
130
131 case remoting::protocol::ConnectionToHost::CONNECTING:
132 return "CONNECTING";
133
134 case remoting::protocol::ConnectionToHost::AUTHENTICATED:
135 return "AUTHENTICATED";
136
137 case remoting::protocol::ConnectionToHost::CONNECTED:
138 return "CONNECTED";
139
140 case remoting::protocol::ConnectionToHost::CLOSED:
141 return "CLOSED";
142
143 case remoting::protocol::ConnectionToHost::FAILED:
144 return "FAILED";
145
146 default:
147 LOG(ERROR) << "Unknown connection state: '" << state << "'";
148 return "UNKNOWN";
149 }
150 }
151
151 void TestChromotingClient::StartConnection( 152 void TestChromotingClient::StartConnection(
152 const ConnectionSetupInfo& connection_setup_info) { 153 const ConnectionSetupInfo& connection_setup_info) {
153 // Required to establish a connection to the host. 154 // Required to establish a connection to the host.
154 jingle_glue::JingleThreadWrapper::EnsureForCurrentMessageLoop(); 155 jingle_glue::JingleThreadWrapper::EnsureForCurrentMessageLoop();
155 156
156 scoped_refptr<URLRequestContextGetter> request_context_getter; 157 scoped_refptr<URLRequestContextGetter> request_context_getter;
157 request_context_getter = new URLRequestContextGetter( 158 request_context_getter = new URLRequestContextGetter(
158 base::ThreadTaskRunnerHandle::Get(), // network_runner 159 base::ThreadTaskRunnerHandle::Get(), // network_runner
159 base::ThreadTaskRunnerHandle::Get()); // file_runner 160 base::ThreadTaskRunnerHandle::Get()); // file_runner
160 161
(...skipping 179 matching lines...) Expand 10 before | Expand all | Expand 10 after
340 VLOG(1) << "TestChromotingClient::InjectClipboardEvent() Called"; 341 VLOG(1) << "TestChromotingClient::InjectClipboardEvent() Called";
341 } 342 }
342 343
343 void TestChromotingClient::SetCursorShape( 344 void TestChromotingClient::SetCursorShape(
344 const protocol::CursorShapeInfo& cursor_shape) { 345 const protocol::CursorShapeInfo& cursor_shape) {
345 VLOG(1) << "TestChromotingClient::SetCursorShape() Called"; 346 VLOG(1) << "TestChromotingClient::SetCursorShape() Called";
346 } 347 }
347 348
348 } // namespace test 349 } // namespace test
349 } // namespace remoting 350 } // namespace remoting
OLDNEW
« remoting/test/connection_time_observer_unittest.cc ('K') | « remoting/test/test_chromoting_client.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698