OLD | NEW |
1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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 <signal.h> | 5 #include <signal.h> |
6 | 6 |
7 #include "base/at_exit.h" | 7 #include "base/at_exit.h" |
8 #include "base/bind.h" | 8 #include "base/bind.h" |
9 #include "base/command_line.h" | 9 #include "base/command_line.h" |
10 #include "base/logging.h" | 10 #include "base/logging.h" |
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
43 g_message_loop->PostTask(FROM_HERE, base::Bind(&StopLoop)); | 43 g_message_loop->PostTask(FROM_HERE, base::Bind(&StopLoop)); |
44 g_printer = NULL; | 44 g_printer = NULL; |
45 } | 45 } |
46 } | 46 } |
47 | 47 |
48 } // namespace | 48 } // namespace |
49 | 49 |
50 int main(int argc, char* argv[]) { | 50 int main(int argc, char* argv[]) { |
51 base::AtExitManager at_exit; | 51 base::AtExitManager at_exit; |
52 Printer printer; | 52 Printer printer; |
53 CommandLine::Init(argc, argv); | 53 base::CommandLine::Init(argc, argv); |
| 54 base::CommandLine* command_line = base::CommandLine::ForCurrentProcess(); |
54 | 55 |
55 logging::LoggingSettings settings; | 56 logging::LoggingSettings settings; |
56 settings.logging_dest = logging::LOG_TO_SYSTEM_DEBUG_LOG; | 57 settings.logging_dest = logging::LOG_TO_SYSTEM_DEBUG_LOG; |
57 logging::InitLogging(settings); | 58 logging::InitLogging(settings); |
58 | 59 |
59 if (CommandLine::ForCurrentProcess()->HasSwitch(switches::kHelp) || | 60 if (command_line->HasSwitch(switches::kHelp) || |
60 CommandLine::ForCurrentProcess()->HasSwitch(switches::kHelpShort)) { | 61 command_line->HasSwitch(switches::kHelpShort)) { |
61 switches::PrintUsage(); | 62 switches::PrintUsage(); |
62 return 0; | 63 return 0; |
63 } | 64 } |
64 | 65 |
65 signal(SIGINT, OnAbort); // Handle Ctrl+C signal. | 66 signal(SIGINT, OnAbort); // Handle Ctrl+C signal. |
66 | 67 |
67 base::MessageLoopForIO loop; | 68 base::MessageLoopForIO loop; |
68 g_message_loop = &loop; | 69 g_message_loop = &loop; |
69 g_message_loop->PostTask(FROM_HERE, base::Bind(&StartPrinter, &printer)); | 70 g_message_loop->PostTask(FROM_HERE, base::Bind(&StartPrinter, &printer)); |
70 base::RunLoop runner; | 71 base::RunLoop runner; |
71 g_printer = &printer; | 72 g_printer = &printer; |
72 g_runner = &runner; | 73 g_runner = &runner; |
73 runner.Run(); | 74 runner.Run(); |
74 | 75 |
75 return 0; | 76 return 0; |
76 } | 77 } |
77 | 78 |
OLD | NEW |