OLD | NEW |
1 // Copyright (c) 2009 The Chromium OS Authors. All rights reserved. | 1 // Copyright (c) 2009 The Chromium OS 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 <cmath> | 5 #include <cmath> |
6 #include <cstdlib> | 6 #include <cstdlib> |
7 #include <ctime> | 7 #include <ctime> |
8 | 8 |
9 extern "C" { | 9 extern "C" { |
10 #include <clutter/clutter.h> | 10 #include <clutter/clutter.h> |
11 #include <gdk/gdk.h> | 11 #include <gdk/gdk.h> |
12 #include <gdk/gdkx.h> | 12 #include <gdk/gdkx.h> |
13 } | 13 } |
14 | 14 |
15 #include <gflags/gflags.h> | 15 #include <gflags/gflags.h> |
16 | 16 |
17 #include "base/command_line.h" | 17 #include "base/command_line.h" |
18 #include "base/file_path.h" | 18 #include "base/file_path.h" |
19 #include "base/file_util.h" | 19 #include "base/file_util.h" |
20 #include "base/logging.h" | 20 #include "base/logging.h" |
21 #include "base/scoped_ptr.h" | 21 #include "base/scoped_ptr.h" |
22 #include "base/string_util.h" | 22 #include "base/string_util.h" |
| 23 #include "handler/exception_handler.h" |
23 #include "window_manager/clutter_interface.h" | 24 #include "window_manager/clutter_interface.h" |
24 #include "window_manager/window_manager.h" | 25 #include "window_manager/window_manager.h" |
25 #include "window_manager/real_x_connection.h" | 26 #include "window_manager/real_x_connection.h" |
26 | 27 |
27 DECLARE_bool(wm_use_compositing); // from window_manager.cc | 28 DECLARE_bool(wm_use_compositing); // from window_manager.cc |
28 | 29 |
29 DEFINE_string(log_dir, ".", | 30 DEFINE_string(log_dir, ".", |
30 "Directory where logs should be written; created if it doesn't " | 31 "Directory where logs should be written; created if it doesn't " |
31 "exist."); | 32 "exist."); |
32 DEFINE_bool(logtostderr, false, | 33 DEFINE_bool(logtostderr, false, |
33 "Should logs be written to stderr instead of to a file in " | 34 "Should logs be written to stderr instead of to a file in " |
34 "--log_dir?"); | 35 "--log_dir?"); |
| 36 DEFINE_string(minidump_dir, ".", |
| 37 "Directory where crash minidumps should be written"); |
35 | 38 |
36 using chromeos::ClutterInterface; | 39 using chromeos::ClutterInterface; |
37 using chromeos::MockClutterInterface; | 40 using chromeos::MockClutterInterface; |
38 using chromeos::RealClutterInterface; | 41 using chromeos::RealClutterInterface; |
39 using chromeos::RealXConnection; | 42 using chromeos::RealXConnection; |
40 using chromeos::WindowManager; | 43 using chromeos::WindowManager; |
41 | 44 |
42 // Get the current time in the local time zone as "YYYYMMDD-HHMMSS". | 45 // Get the current time in the local time zone as "YYYYMMDD-HHMMSS". |
43 std::string GetCurrentTimeAsString() { | 46 std::string GetCurrentTimeAsString() { |
44 time_t now = time(NULL); | 47 time_t now = time(NULL); |
45 CHECK(now >= 0); | 48 CHECK(now >= 0); |
46 struct tm now_tm; | 49 struct tm now_tm; |
47 CHECK(localtime_r(&now, &now_tm) == &now_tm); | 50 CHECK(localtime_r(&now, &now_tm) == &now_tm); |
48 char now_str[16]; | 51 char now_str[16]; |
49 CHECK(strftime(now_str, sizeof(now_str), "%Y%m%d-%H%M%S", &now_tm) == 15); | 52 CHECK(strftime(now_str, sizeof(now_str), "%Y%m%d-%H%M%S", &now_tm) == 15); |
50 return std::string(now_str); | 53 return std::string(now_str); |
51 } | 54 } |
52 | 55 |
53 int main(int argc, char** argv) { | 56 int main(int argc, char** argv) { |
54 gdk_init(&argc, &argv); | 57 gdk_init(&argc, &argv); |
55 clutter_init(&argc, &argv); | 58 clutter_init(&argc, &argv); |
56 google::ParseCommandLineFlags(&argc, &argv, true); | 59 google::ParseCommandLineFlags(&argc, &argv, true); |
57 CommandLine::Init(argc, argv); | 60 CommandLine::Init(argc, argv); |
58 | 61 |
| 62 google_breakpad::ExceptionHandler exception_handler( |
| 63 FLAGS_minidump_dir, NULL, NULL, NULL, true); |
| 64 |
59 if (!FLAGS_logtostderr) { | 65 if (!FLAGS_logtostderr) { |
60 if (!file_util::CreateDirectory(FilePath(FLAGS_log_dir))) | 66 if (!file_util::CreateDirectory(FilePath(FLAGS_log_dir))) |
61 LOG(ERROR) << "Unable to create logging directory " << FLAGS_log_dir; | 67 LOG(ERROR) << "Unable to create logging directory " << FLAGS_log_dir; |
62 } | 68 } |
63 std::string log_filename = StringPrintf( | 69 std::string log_filename = StringPrintf( |
64 "%s/%s.%s", FLAGS_log_dir.c_str(), WindowManager::GetWmName(), | 70 "%s/%s.%s", FLAGS_log_dir.c_str(), WindowManager::GetWmName(), |
65 GetCurrentTimeAsString().c_str()); | 71 GetCurrentTimeAsString().c_str()); |
66 logging::InitLogging(log_filename.c_str(), | 72 logging::InitLogging(log_filename.c_str(), |
67 FLAGS_logtostderr ? | 73 FLAGS_logtostderr ? |
68 logging::LOG_ONLY_TO_SYSTEM_DEBUG_LOG : | 74 logging::LOG_ONLY_TO_SYSTEM_DEBUG_LOG : |
(...skipping 15 matching lines...) Expand all Loading... |
84 clutter.reset(new RealClutterInterface); | 90 clutter.reset(new RealClutterInterface); |
85 } else { | 91 } else { |
86 clutter.reset(new MockClutterInterface); | 92 clutter.reset(new MockClutterInterface); |
87 } | 93 } |
88 WindowManager wm(&xconn, clutter.get()); | 94 WindowManager wm(&xconn, clutter.get()); |
89 wm.Init(); | 95 wm.Init(); |
90 | 96 |
91 clutter_main(); | 97 clutter_main(); |
92 return 0; | 98 return 0; |
93 } | 99 } |
OLD | NEW |