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

Unified Diff: remoting/test/connection_time_observer.h

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, 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.h
diff --git a/remoting/test/connection_time_observer.h b/remoting/test/connection_time_observer.h
new file mode 100644
index 0000000000000000000000000000000000000000..eee076a9459ed19bb6400863697b71d15120682c
--- /dev/null
+++ b/remoting/test/connection_time_observer.h
@@ -0,0 +1,69 @@
+// 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.
+
+#ifndef REMOTING_TEST_CONNECTION_TIME_OBSERVER_H_
+#define REMOTING_TEST_CONNECTION_TIME_OBSERVER_H_
+
+#include <map>
+
+#include "remoting/test/remote_connection_observer.h"
+
+namespace base {
+class TimeDelta;
+class Timer;
+}
+
+namespace remoting {
+namespace test {
+
+// Observes and saves the times when a chromoting client changes its state. It
+// allows for tests to access latency times between the different states the
+// client transitioned through.
+class ConnectionTimeObserver
+ : public RemoteConnectionObserver {
+ public:
+ ConnectionTimeObserver();
+ ~ConnectionTimeObserver() override;
+
+ // RemoteConnectionObserver interface.
+ void ConnectionStateChanged(protocol::ConnectionToHost::State state,
+ protocol::ErrorCode error_code) override;
+ void ConnectionReady(bool ready) override;
+
+ // Used to properly set the time of the INITIALIZING state of the chromoting
+ // connection.
+ // Note: Initialize() should be called right before a chromoting client starts
+ // a connection to accurately measure the time between INITIALIZING and
+ // CONNECTING states.
+ void Initialize();
+
+ // Prints out connection performance stats to STDOUT.
+ void DisplayConnectionStats() const;
+
+ // Returns the time delta in milliseconds between |start_state| and
+ // |end_state| stored in |transition_times_map_|.
+ base::TimeDelta GetStateTransitionTime(
+ protocol::ConnectionToHost::State start_state,
+ protocol::ConnectionToHost::State end_state) const;
+
+ // Used to set fake state transition times for ConnectionTimeObserver tests.
+ void SetTransitionTimesMapForTest(
+ const std::map<protocol::ConnectionToHost::State, base::TimeTicks>& map);
+
+ private:
+ // Saves the current connection state of client to host.
+ protocol::ConnectionToHost::State current_connection_state_ =
+ protocol::ConnectionToHost::State::INITIALIZING;
+
+ // The TimeTicks to get to a state from the previous state.
+ std::map<protocol::ConnectionToHost::State, base::TimeTicks>
+ transition_times_map_;
+
+ DISALLOW_COPY_AND_ASSIGN(ConnectionTimeObserver);
+};
+
+} // namespace test
+} // namespace remoting
+
+#endif // REMOTING_TEST_CONNECTION_TIME_OBSERVER_H_

Powered by Google App Engine
This is Rietveld 408576698