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..845d7f136a0001f4feef51eb2a3143e5a6d54dbd |
--- /dev/null |
+++ b/remoting/test/connection_time_observer.h |
@@ -0,0 +1,49 @@ |
+// 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 remoting { |
+namespace test { |
+ |
+// Observes and saves the times when TestChromotingClient changes its state. It |
joedow
2015/07/23 16:57:55
I don't think the comment should mention the TestC
tonychun
2015/07/24 01:41:47
Good point. Thank you.
|
+// allows for tests to access latency times between the different states the |
+// client was in. |
+class ConnectionTimeObserver |
+ : public RemoteConnectionObserver { |
+ public: |
+ ConnectionTimeObserver(); |
+ ~ConnectionTimeObserver() override; |
+ |
+ // RemoteConnectionObserver interface. |
+ void ConnectionStateChanged(protocol::ConnectionToHost::State state, |
+ protocol::ErrorCode error_code) override; |
+ |
+ // Returns the delta time in milliseconds between |start_state| and |
+ // |end_state| stored in |transition_times_map_|. |
+ int GetStateTransitionDelay( |
Sergey Ulanov
2015/07/23 19:20:57
Return base::TimeDelta here?
tonychun
2015/07/24 01:41:47
Done.
|
+ const protocol::ConnectionToHost::State& start_state, |
+ const protocol::ConnectionToHost::State& end_state) const; |
+ |
+ private: |
+ // Saves the latest state the ChromotingClient is in. |
joedow
2015/07/23 16:57:54
Technically the state is provided by the Connectio
tonychun
2015/07/24 01:41:47
I've changed the name to current_connection_state_
|
+ protocol::ConnectionToHost::State current_state_ = |
+ protocol::ConnectionToHost::State::INITIALIZING; |
+ |
+ // Stores TimeTick of states the client changes to. |
+ 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_ |