Index: remoting/test/it2me_standalone_host_runner.cc |
diff --git a/remoting/test/it2me_standalone_host_runner.cc b/remoting/test/it2me_standalone_host_runner.cc |
new file mode 100644 |
index 0000000000000000000000000000000000000000..a66f64413d4ab143ca1cd93911e019c4c5584c65 |
--- /dev/null |
+++ b/remoting/test/it2me_standalone_host_runner.cc |
@@ -0,0 +1,88 @@ |
+// Copyright 2016 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. |
+ |
+#include <iostream> |
+#include <vector> |
+ |
+#include "base/at_exit.h" |
+#include "base/bind.h" |
+#include "base/command_line.h" |
+#include "base/logging.h" |
+#include "base/time/time.h" |
+#include "remoting/base/auto_thread_task_runner.h" |
+#include "remoting/host/resources.h" |
+#include "remoting/test/it2me_standalone_host.h" |
+ |
+#if defined(OS_LINUX) |
+#include <gtk/gtk.h> |
+#include <X11/Xlib.h> |
+ |
+#include "base/linux_util.h" |
+#endif // defined(OS_LINUX) |
+ |
+using remoting::test::It2MeStandaloneHost; |
+ |
+namespace { |
+ |
+void BindAnalysisResultOutputter(It2MeStandaloneHost* host); |
+ |
+void OutputLogger(const char* name, |
+ const remoting::test::MessageCounter& counter) { |
+ std::cout << name |
+ << ": " |
+ << counter.message_size() |
+ << " bytes in " |
+ << counter.message_count() |
+ << " packages, last package " |
+ << counter.last_message_size() |
+ << " bytes, " |
+ << counter.AverageMessageSize() |
+ << " bytes/package, " |
+ << counter.MessagesPerSecond() |
+ << " packages/sec, " |
+ << counter.SizePerSecond() |
+ << " bytes/sec" |
+ << std::endl; |
+} |
+ |
+void OutputAnalysisResult(It2MeStandaloneHost* host) { |
+ OutputLogger("audio", host->audio_stub()); |
+ OutputLogger("video", host->video_stub()); |
+ OutputLogger("client", host->client_stub()); |
+ OutputLogger("host", host->host_stub()); |
joedow
2016/05/03 22:28:30
I do wonder if this log could go into a logging cl
Hzj_jie
2016/05/04 02:11:57
Done.
|
+ BindAnalysisResultOutputter(host); |
+} |
+ |
+void BindAnalysisResultOutputter(It2MeStandaloneHost* host) { |
+ host->context().ui_task_runner()->PostDelayedTask( |
+ FROM_HERE, |
+ base::Bind(&OutputAnalysisResult, host), |
+ base::TimeDelta::FromSeconds(1)); |
joedow
2016/05/03 22:28:30
Why not use a RepeatingTimer here?
Hzj_jie
2016/05/04 02:11:57
I do not know we have a RepeatingTimer before :)
|
+} |
+ |
+} // namespace |
+ |
+int main(int argc, const char** argv) { |
+ base::AtExitManager at_exit_manager; |
+ base::CommandLine::Init(argc, argv); |
+ It2MeStandaloneHost host; |
+ |
+#if defined(OS_LINUX) |
+ // Required in order for us to run multiple X11 threads. |
+ XInitThreads(); |
+ |
+ // Required for any calls into GTK functions, such as the Disconnect and |
+ // Continue windows. Calling with nullptr arguments because we don't have |
+ // any command line arguments for gtk to consume. |
+ gtk_init(nullptr, nullptr); |
+ |
+ // Need to prime the host OS version value for linux to prevent IO on the |
+ // network thread. base::GetLinuxDistro() caches the result. |
+ base::GetLinuxDistro(); |
+#endif // OS_LINUX |
+ |
+ DCHECK(remoting::LoadResources("en-US")); |
joedow
2016/05/03 22:28:30
IIRC DCHECKS are removed completely on release bui
Hzj_jie
2016/05/04 02:11:57
Interesting, I believe I need this statement in bo
|
+ BindAnalysisResultOutputter(&host); |
+ host.Run(); |
+} |