OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "base/base64.h" | 5 #include "base/base64.h" |
6 #include "base/files/file_util.h" | 6 #include "base/files/file_util.h" |
7 #include "base/message_loop/message_loop.h" | 7 #include "base/message_loop/message_loop.h" |
8 #include "base/rand_util.h" | 8 #include "base/rand_util.h" |
9 #include "base/run_loop.h" | 9 #include "base/run_loop.h" |
10 #include "base/single_thread_task_runner.h" | 10 #include "base/single_thread_task_runner.h" |
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
61 double out_of_order_rate; | 61 double out_of_order_rate; |
62 }; | 62 }; |
63 | 63 |
64 class FakeCursorShapeStub : public protocol::CursorShapeStub { | 64 class FakeCursorShapeStub : public protocol::CursorShapeStub { |
65 public: | 65 public: |
66 FakeCursorShapeStub() {} | 66 FakeCursorShapeStub() {} |
67 virtual ~FakeCursorShapeStub() {} | 67 virtual ~FakeCursorShapeStub() {} |
68 | 68 |
69 // protocol::CursorShapeStub interface. | 69 // protocol::CursorShapeStub interface. |
70 virtual void SetCursorShape( | 70 virtual void SetCursorShape( |
71 const protocol::CursorShapeInfo& cursor_shape) OVERRIDE {}; | 71 const protocol::CursorShapeInfo& cursor_shape) override {}; |
72 }; | 72 }; |
73 | 73 |
74 class ProtocolPerfTest | 74 class ProtocolPerfTest |
75 : public testing::Test, | 75 : public testing::Test, |
76 public testing::WithParamInterface<NetworkPerformanceParams>, | 76 public testing::WithParamInterface<NetworkPerformanceParams>, |
77 public ClientUserInterface, | 77 public ClientUserInterface, |
78 public VideoRenderer, | 78 public VideoRenderer, |
79 public HostStatusObserver { | 79 public HostStatusObserver { |
80 public: | 80 public: |
81 ProtocolPerfTest() | 81 ProtocolPerfTest() |
82 : host_thread_("host"), | 82 : host_thread_("host"), |
83 capture_thread_("capture"), | 83 capture_thread_("capture"), |
84 encode_thread_("encode") { | 84 encode_thread_("encode") { |
85 VideoScheduler::EnableTimestampsForTests(); | 85 VideoScheduler::EnableTimestampsForTests(); |
86 host_thread_.StartWithOptions( | 86 host_thread_.StartWithOptions( |
87 base::Thread::Options(base::MessageLoop::TYPE_IO, 0)); | 87 base::Thread::Options(base::MessageLoop::TYPE_IO, 0)); |
88 capture_thread_.Start(); | 88 capture_thread_.Start(); |
89 encode_thread_.Start(); | 89 encode_thread_.Start(); |
90 } | 90 } |
91 | 91 |
92 virtual ~ProtocolPerfTest() { | 92 virtual ~ProtocolPerfTest() { |
93 host_thread_.message_loop_proxy()->DeleteSoon(FROM_HERE, host_.release()); | 93 host_thread_.message_loop_proxy()->DeleteSoon(FROM_HERE, host_.release()); |
94 host_thread_.message_loop_proxy()->DeleteSoon(FROM_HERE, | 94 host_thread_.message_loop_proxy()->DeleteSoon(FROM_HERE, |
95 host_signaling_.release()); | 95 host_signaling_.release()); |
96 message_loop_.RunUntilIdle(); | 96 message_loop_.RunUntilIdle(); |
97 } | 97 } |
98 | 98 |
99 // ClientUserInterface interface. | 99 // ClientUserInterface interface. |
100 virtual void OnConnectionState(protocol::ConnectionToHost::State state, | 100 virtual void OnConnectionState(protocol::ConnectionToHost::State state, |
101 protocol::ErrorCode error) OVERRIDE { | 101 protocol::ErrorCode error) override { |
102 if (state == protocol::ConnectionToHost::CONNECTED) { | 102 if (state == protocol::ConnectionToHost::CONNECTED) { |
103 client_connected_ = true; | 103 client_connected_ = true; |
104 if (host_connected_) | 104 if (host_connected_) |
105 connecting_loop_->Quit(); | 105 connecting_loop_->Quit(); |
106 } | 106 } |
107 } | 107 } |
108 virtual void OnConnectionReady(bool ready) OVERRIDE {} | 108 virtual void OnConnectionReady(bool ready) override {} |
109 virtual void OnRouteChanged(const std::string& channel_name, | 109 virtual void OnRouteChanged(const std::string& channel_name, |
110 const protocol::TransportRoute& route) OVERRIDE { | 110 const protocol::TransportRoute& route) override { |
111 } | 111 } |
112 virtual void SetCapabilities(const std::string& capabilities) OVERRIDE {} | 112 virtual void SetCapabilities(const std::string& capabilities) override {} |
113 virtual void SetPairingResponse( | 113 virtual void SetPairingResponse( |
114 const protocol::PairingResponse& pairing_response) OVERRIDE {} | 114 const protocol::PairingResponse& pairing_response) override {} |
115 virtual void DeliverHostMessage( | 115 virtual void DeliverHostMessage( |
116 const protocol::ExtensionMessage& message) OVERRIDE {} | 116 const protocol::ExtensionMessage& message) override {} |
117 virtual protocol::ClipboardStub* GetClipboardStub() OVERRIDE { | 117 virtual protocol::ClipboardStub* GetClipboardStub() override { |
118 return NULL; | 118 return NULL; |
119 } | 119 } |
120 virtual protocol::CursorShapeStub* GetCursorShapeStub() OVERRIDE { | 120 virtual protocol::CursorShapeStub* GetCursorShapeStub() override { |
121 return &cursor_shape_stub_; | 121 return &cursor_shape_stub_; |
122 } | 122 } |
123 | 123 |
124 // VideoRenderer interface. | 124 // VideoRenderer interface. |
125 virtual void Initialize(const protocol::SessionConfig& config) OVERRIDE {} | 125 virtual void Initialize(const protocol::SessionConfig& config) override {} |
126 virtual ChromotingStats* GetStats() OVERRIDE { return NULL; } | 126 virtual ChromotingStats* GetStats() override { return NULL; } |
127 virtual void ProcessVideoPacket(scoped_ptr<VideoPacket> video_packet, | 127 virtual void ProcessVideoPacket(scoped_ptr<VideoPacket> video_packet, |
128 const base::Closure& done) OVERRIDE { | 128 const base::Closure& done) override { |
129 if (video_packet->data().empty()) { | 129 if (video_packet->data().empty()) { |
130 // Ignore keep-alive packets | 130 // Ignore keep-alive packets |
131 done.Run(); | 131 done.Run(); |
132 return; | 132 return; |
133 } | 133 } |
134 | 134 |
135 last_video_packet_ = video_packet.Pass(); | 135 last_video_packet_ = video_packet.Pass(); |
136 | 136 |
137 if (!on_frame_task_.is_null()) | 137 if (!on_frame_task_.is_null()) |
138 on_frame_task_.Run(); | 138 on_frame_task_.Run(); |
139 | 139 |
140 done.Run(); | 140 done.Run(); |
141 } | 141 } |
142 | 142 |
143 // HostStatusObserver interface. | 143 // HostStatusObserver interface. |
144 virtual void OnClientConnected(const std::string& jid) OVERRIDE { | 144 virtual void OnClientConnected(const std::string& jid) override { |
145 message_loop_.PostTask( | 145 message_loop_.PostTask( |
146 FROM_HERE, | 146 FROM_HERE, |
147 base::Bind(&ProtocolPerfTest::OnHostConnectedMainThread, | 147 base::Bind(&ProtocolPerfTest::OnHostConnectedMainThread, |
148 base::Unretained(this))); | 148 base::Unretained(this))); |
149 } | 149 } |
150 | 150 |
151 protected: | 151 protected: |
152 void WaitConnected() { | 152 void WaitConnected() { |
153 client_connected_ = false; | 153 client_connected_ = false; |
154 host_connected_ = false; | 154 host_connected_ = false; |
(...skipping 334 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
489 << "ms Encode: " << last_video_packet_->encode_time_ms() | 489 << "ms Encode: " << last_video_packet_->encode_time_ms() |
490 << "ms Capture: " << last_video_packet_->capture_time_ms() | 490 << "ms Capture: " << last_video_packet_->capture_time_ms() |
491 << "ms"; | 491 << "ms"; |
492 sum += latency; | 492 sum += latency; |
493 } | 493 } |
494 | 494 |
495 LOG(INFO) << "Average: " << (sum / kFrames).InMillisecondsF(); | 495 LOG(INFO) << "Average: " << (sum / kFrames).InMillisecondsF(); |
496 } | 496 } |
497 | 497 |
498 } // namespace remoting | 498 } // namespace remoting |
OLD | NEW |