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

Side by Side Diff: remoting/test/connection_time_observer.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: Changed to ConnectionTimeObserver. Created 5 years, 5 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/test/connection_time_observer.h"
6
7 #include "base/time/time.h"
8
9 namespace {
10
11 std::string GetStateAsString(
12 const remoting::protocol::ConnectionToHost::State& state) {
13 switch (state) {
14 case remoting::protocol::ConnectionToHost::State::INITIALIZING:
15 return "INITIALIZING";
16 case remoting::protocol::ConnectionToHost::State::CONNECTING:
17 return "CONNECTING";
18 case remoting::protocol::ConnectionToHost::State::AUTHENTICATED:
19 return "AUTHENTICATED";
20 case remoting::protocol::ConnectionToHost::State::CONNECTED:
21 return "CONNECTED";
22 case remoting::protocol::ConnectionToHost::State::FAILED:
23 return "FAILED";
24 case remoting::protocol::ConnectionToHost::State::CLOSED:
25 return "CLOSED";
26 default:
27 LOG(ERROR) << "Unknown current state";
28 NOTREACHED();
29 }
30 }
31
32 } // namespace
33
34 namespace remoting {
35 namespace test {
36
37 ConnectionTimeObserver::ConnectionTimeObserver()
38 : current_state_(protocol::ConnectionToHost::State::INITIALIZING),
Sergey Ulanov 2015/07/20 23:04:04 nit: move this initializer to .h
tonychun 2015/07/23 03:31:04 Done.
39 last_state_change_time_ticks(base::TimeTicks::Now()) {
40 }
41
42 ConnectionTimeObserver::~ConnectionTimeObserver() {
43 }
44
45 void ConnectionTimeObserver::ConnectionStateChanged(
46 protocol::ConnectionToHost::State state,
47 protocol::ErrorCode error_code) {
48 int state_change_time =
49 (base::TimeTicks::Now() - last_state_change_time_ticks).InMilliseconds();
50
51 std::string current_state_string = GetStateAsString(current_state_);
52 std::string next_state_string = GetStateAsString(state);
53
54 VLOG(1) << current_state_string << " to " << next_state_string
55 << " Delta Time: " << state_change_time << " ms";
56
57 current_state_ = state;
58 last_state_change_time_ticks = base::TimeTicks::Now();
59 }
60
61 } // namespace test
62 } // namespace remoting
OLDNEW
« remoting/test/connection_time_observer.h ('K') | « remoting/test/connection_time_observer.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698