Chromium Code Reviews| OLD | NEW |
|---|---|
| (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 #ifndef REMOTING_TEST_CONNECTION_TIME_OBSERVER_H_ | |
| 6 #define REMOTING_TEST_CONNECTION_TIME_OBSERVER_H_ | |
| 7 | |
| 8 #include <map> | |
| 9 | |
| 10 #include "remoting/test/remote_connection_observer.h" | |
| 11 | |
| 12 namespace base { | |
| 13 class TimeDelta; | |
| 14 } | |
| 15 | |
| 16 namespace remoting { | |
| 17 namespace test { | |
| 18 | |
| 19 // Observes and saves the times when a chromoting client changes its state. It | |
| 20 // allows for tests to access latency times between the different states the | |
| 21 // client was in. | |
|
joedow
2015/07/24 13:38:28
nit: s/was in/transitioned through
tonychun
2015/07/27 16:03:37
Done.
| |
| 22 class ConnectionTimeObserver | |
| 23 : public RemoteConnectionObserver { | |
| 24 public: | |
| 25 ConnectionTimeObserver(); | |
| 26 ~ConnectionTimeObserver() override; | |
| 27 | |
| 28 // RemoteConnectionObserver interface. | |
| 29 void ConnectionStateChanged(protocol::ConnectionToHost::State state, | |
| 30 protocol::ErrorCode error_code) override; | |
|
joedow
2015/07/24 13:38:28
You may consider adding a helper method for settin
tonychun
2015/07/27 16:03:38
Done.
| |
| 31 | |
| 32 // Prints out connection performance stats to STDOUT. | |
| 33 void DisplayConnectionStats(); | |
|
joedow
2015/07/24 13:38:28
this method should be const.
tonychun
2015/07/27 16:03:37
Done.
| |
| 34 | |
| 35 // Returns the delta time in milliseconds between |start_state| and | |
|
joedow
2015/07/24 13:38:29
nit: s/delta time/time delta
tonychun
2015/07/27 16:03:38
Done.
| |
| 36 // |end_state| stored in |transition_times_map_|. | |
| 37 base::TimeDelta GetStateTransitionDelay( | |
|
joedow
2015/07/24 13:38:28
With the updated signature, this method should pro
tonychun
2015/07/27 16:03:37
Done.
| |
| 38 const protocol::ConnectionToHost::State& start_state, | |
|
joedow
2015/07/24 13:38:29
The parameters here do not need to be passed as c
tonychun
2015/07/27 16:03:37
Done.
| |
| 39 const protocol::ConnectionToHost::State& end_state) const; | |
| 40 | |
| 41 // Used to set fake state transition times for ConnectionTimeObserver tests. | |
| 42 void SetTransitionTimesMapForTest( | |
| 43 const std::map<protocol::ConnectionToHost::State, base::TimeTicks>& map); | |
| 44 | |
| 45 private: | |
| 46 // Saves the current connection state of client to host. | |
| 47 protocol::ConnectionToHost::State current_connection_state_ = | |
| 48 protocol::ConnectionToHost::State::INITIALIZING; | |
| 49 | |
| 50 // Stores TimeTick of states the client changes to. | |
| 51 std::map<protocol::ConnectionToHost::State, base::TimeTicks> | |
| 52 transition_times_map_; | |
| 53 | |
| 54 DISALLOW_COPY_AND_ASSIGN(ConnectionTimeObserver); | |
| 55 }; | |
| 56 | |
| 57 } // namespace test | |
| 58 } // namespace remoting | |
| 59 | |
| 60 #endif // REMOTING_TEST_CONNECTION_TIME_OBSERVER_H_ | |
| OLD | NEW |