Chromium Code Reviews| 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..b9cc07d9ac6fbb5c9830b2e191a5114eacbc418c |
| --- /dev/null |
| +++ b/remoting/test/connection_time_observer.h |
| @@ -0,0 +1,60 @@ |
| +// 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; |
| +} |
| + |
| +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 was in. |
|
joedow
2015/07/24 13:38:28
nit: s/was in/transitioned through
tonychun
2015/07/27 16:03:37
Done.
|
| +class ConnectionTimeObserver |
| + : public RemoteConnectionObserver { |
| + public: |
| + ConnectionTimeObserver(); |
| + ~ConnectionTimeObserver() override; |
| + |
| + // RemoteConnectionObserver interface. |
| + void ConnectionStateChanged(protocol::ConnectionToHost::State state, |
| + 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.
|
| + |
| + // Prints out connection performance stats to STDOUT. |
| + void DisplayConnectionStats(); |
|
joedow
2015/07/24 13:38:28
this method should be const.
tonychun
2015/07/27 16:03:37
Done.
|
| + |
| + // 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.
|
| + // |end_state| stored in |transition_times_map_|. |
| + 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.
|
| + 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.
|
| + const 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; |
| + |
| + // 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_ |