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

Unified 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 side-by-side diff with in-line comments
Download patch
Index: remoting/test/connection_time_observer.cc
diff --git a/remoting/test/connection_time_observer.cc b/remoting/test/connection_time_observer.cc
new file mode 100644
index 0000000000000000000000000000000000000000..1da5cdb237dcd72e016263b5d42c987c51043a5d
--- /dev/null
+++ b/remoting/test/connection_time_observer.cc
@@ -0,0 +1,62 @@
+// Copyright 2015 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include "remoting/test/connection_time_observer.h"
+
+#include "base/time/time.h"
+
+namespace {
+
+std::string GetStateAsString(
+ const remoting::protocol::ConnectionToHost::State& state) {
+ switch (state) {
+ case remoting::protocol::ConnectionToHost::State::INITIALIZING:
+ return "INITIALIZING";
+ case remoting::protocol::ConnectionToHost::State::CONNECTING:
+ return "CONNECTING";
+ case remoting::protocol::ConnectionToHost::State::AUTHENTICATED:
+ return "AUTHENTICATED";
+ case remoting::protocol::ConnectionToHost::State::CONNECTED:
+ return "CONNECTED";
+ case remoting::protocol::ConnectionToHost::State::FAILED:
+ return "FAILED";
+ case remoting::protocol::ConnectionToHost::State::CLOSED:
+ return "CLOSED";
+ default:
+ LOG(ERROR) << "Unknown current state";
+ NOTREACHED();
+ }
+}
+
+} // namespace
+
+namespace remoting {
+namespace test {
+
+ConnectionTimeObserver::ConnectionTimeObserver()
+ : 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.
+ last_state_change_time_ticks(base::TimeTicks::Now()) {
+}
+
+ConnectionTimeObserver::~ConnectionTimeObserver() {
+}
+
+void ConnectionTimeObserver::ConnectionStateChanged(
+ protocol::ConnectionToHost::State state,
+ protocol::ErrorCode error_code) {
+ int state_change_time =
+ (base::TimeTicks::Now() - last_state_change_time_ticks).InMilliseconds();
+
+ std::string current_state_string = GetStateAsString(current_state_);
+ std::string next_state_string = GetStateAsString(state);
+
+ VLOG(1) << current_state_string << " to " << next_state_string
+ << " Delta Time: " << state_change_time << " ms";
+
+ current_state_ = state;
+ last_state_change_time_ticks = base::TimeTicks::Now();
+}
+
+} // namespace test
+} // namespace remoting
« 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