This source file includes following definitions.
- StartIt2MeNativeMessagingHost
- It2MeNativeMessagingHostMain
#include "remoting/host/it2me/it2me_native_messaging_host_main.h"
#include "base/at_exit.h"
#include "base/command_line.h"
#include "base/i18n/icu_util.h"
#include "base/message_loop/message_loop.h"
#include "base/run_loop.h"
#include "media/base/media.h"
#include "net/socket/ssl_server_socket.h"
#include "remoting/base/breakpad.h"
#include "remoting/base/resources.h"
#include "remoting/host/it2me/it2me_native_messaging_host.h"
#include "remoting/host/logging.h"
#include "remoting/host/usage_stats_consent.h"
#if defined(OS_LINUX)
#include <gtk/gtk.h>
#endif
#if defined(OS_MACOSX)
#include "base/mac/scoped_nsautorelease_pool.h"
#endif
#if defined(OS_WIN)
#include <commctrl.h>
#endif
namespace remoting {
int StartIt2MeNativeMessagingHost() {
#if defined(OS_MACOSX)
base::mac::ScopedNSAutoreleasePool pool;
#endif
#if defined(REMOTING_ENABLE_BREAKPAD)
if (IsUsageStatsAllowed()) {
InitializeCrashReporting();
}
#endif
#if defined(OS_WIN)
INITCOMMONCONTROLSEX info;
info.dwSize = sizeof(info);
info.dwICC = ICC_STANDARD_CLASSES;
InitCommonControlsEx(&info);
#endif
base::i18n::InitializeICU();
remoting::LoadResources("");
#if defined(OS_LINUX)
gtk_init(NULL, NULL);
#endif
net::EnableSSLServerSockets();
media::InitializeCPUSpecificMediaFeatures();
#if defined(OS_WIN)
base::PlatformFile read_file = GetStdHandle(STD_INPUT_HANDLE);
base::PlatformFile write_file = GetStdHandle(STD_OUTPUT_HANDLE);
SetStdHandle(STD_INPUT_HANDLE, NULL);
SetStdHandle(STD_OUTPUT_HANDLE, NULL);
#elif defined(OS_POSIX)
base::PlatformFile read_file = STDIN_FILENO;
base::PlatformFile write_file = STDOUT_FILENO;
#else
#error Not implemented.
#endif
base::MessageLoopForUI message_loop;
base::RunLoop run_loop;
scoped_refptr<AutoThreadTaskRunner> task_runner =
new remoting::AutoThreadTaskRunner(message_loop.message_loop_proxy(),
run_loop.QuitClosure());
scoped_ptr<It2MeHostFactory> factory(new It2MeHostFactory());
scoped_ptr<NativeMessagingChannel> channel(
new NativeMessagingChannel(read_file, write_file));
scoped_ptr<It2MeNativeMessagingHost> host(
new It2MeNativeMessagingHost(
task_runner, channel.Pass(), factory.Pass()));
host->Start(run_loop.QuitClosure());
run_loop.Run();
return kSuccessExitCode;
}
int It2MeNativeMessagingHostMain(int argc, char** argv) {
base::AtExitManager exit_manager;
CommandLine::Init(argc, argv);
remoting::InitHostLogging();
return StartIt2MeNativeMessagingHost();
}
}