| OLD | NEW |
| 1 // Copyright (c) 2006-2008 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2006-2008 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 // TODO(port): the ifdefs in here are a first step towards trying to determine | 5 // TODO(port): the ifdefs in here are a first step towards trying to determine |
| 6 // the correct abstraction for all the OS functionality required at this | 6 // the correct abstraction for all the OS functionality required at this |
| 7 // stage of process initialization. It should not be taken as a final | 7 // stage of process initialization. It should not be taken as a final |
| 8 // abstraction. | 8 // abstraction. |
| 9 | 9 |
| 10 #include "build/build_config.h" | 10 #include "build/build_config.h" |
| 11 | 11 |
| 12 #if defined(OS_WIN) | 12 #if defined(OS_WIN) |
| 13 #include <algorithm> | 13 #include <algorithm> |
| 14 #include <atlbase.h> | 14 #include <atlbase.h> |
| 15 #include <atlapp.h> | 15 #include <atlapp.h> |
| 16 #include <malloc.h> | 16 #include <malloc.h> |
| 17 #include <new.h> | 17 #include <new.h> |
| 18 #endif | 18 #endif |
| 19 | 19 |
| 20 #if defined(OS_LINUX) | 20 #if defined(OS_LINUX) |
| 21 #include <gtk/gtk.h> | 21 #include <gtk/gtk.h> |
| 22 #include <string.h> |
| 22 #endif | 23 #endif |
| 23 | 24 |
| 24 #include "base/at_exit.h" | 25 #include "base/at_exit.h" |
| 25 #include "base/command_line.h" | 26 #include "base/command_line.h" |
| 26 #include "base/debug_util.h" | 27 #include "base/debug_util.h" |
| 27 #include "base/icu_util.h" | 28 #include "base/icu_util.h" |
| 28 #include "base/message_loop.h" | 29 #include "base/message_loop.h" |
| 29 #include "base/path_service.h" | 30 #include "base/path_service.h" |
| 30 #include "base/process_util.h" | 31 #include "base/process_util.h" |
| 31 #include "base/scoped_nsautorelease_pool.h" | 32 #include "base/scoped_nsautorelease_pool.h" |
| (...skipping 120 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 152 return false; | 153 return false; |
| 153 } | 154 } |
| 154 } | 155 } |
| 155 | 156 |
| 156 return true; | 157 return true; |
| 157 } | 158 } |
| 158 | 159 |
| 159 #endif // OS_WIN | 160 #endif // OS_WIN |
| 160 | 161 |
| 161 #if defined(OS_LINUX) | 162 #if defined(OS_LINUX) |
| 162 static void GLibFatalLogHandler(const gchar* log_domain, | 163 static void GLibLogHandler(const gchar* log_domain, |
| 163 GLogLevelFlags log_level, | 164 GLogLevelFlags log_level, |
| 164 const gchar* message, | 165 const gchar* message, |
| 165 gpointer userdata) { | 166 gpointer userdata) { |
| 166 if (!log_domain) | 167 if (!log_domain) |
| 167 log_domain = "<unknown>"; | 168 log_domain = "<unknown>"; |
| 168 if (!message) | 169 if (!message) |
| 169 message = "<no message>"; | 170 message = "<no message>"; |
| 170 | 171 |
| 171 LOG(FATAL) << log_domain << ": " << message; | 172 // http://code.google.com/p/chromium/issues/detail?id=9643 |
| 173 // Until we have a real 64-bit build or all of these 32-bit package issues |
| 174 // are sorted out, don't fatal on ELF 32/64-bit mismatch warnings. |
| 175 if (strstr(message, "Loading IM context type") || |
| 176 strstr(message, "wrong ELF class: ELFCLASS64")) { |
| 177 LOG(ERROR) << "Bug 9643: " << log_domain << ": " << message; |
| 178 } else { |
| 179 LOG(FATAL) << log_domain << ": " << message; |
| 180 } |
| 172 } | 181 } |
| 173 | 182 |
| 174 static void SetUpGLibLogHandler() { | 183 static void SetUpGLibLogHandler() { |
| 175 // Register GLib-handled assertions to go through our logging system. | 184 // Register GLib-handled assertions to go through our logging system. |
| 176 const char* kLogDomains[] = { NULL, "Gtk", "Gdk", "GLib" }; | 185 const char* kLogDomains[] = { NULL, "Gtk", "Gdk", "GLib" }; |
| 177 for (size_t i = 0; i < arraysize(kLogDomains); i++) { | 186 for (size_t i = 0; i < arraysize(kLogDomains); i++) { |
| 178 g_log_set_handler(kLogDomains[i], | 187 g_log_set_handler(kLogDomains[i], |
| 179 static_cast<GLogLevelFlags>(G_LOG_FLAG_RECURSION | | 188 static_cast<GLogLevelFlags>(G_LOG_FLAG_RECURSION | |
| 180 G_LOG_FLAG_FATAL | | 189 G_LOG_FLAG_FATAL | |
| 181 G_LOG_LEVEL_ERROR | | 190 G_LOG_LEVEL_ERROR | |
| 182 G_LOG_LEVEL_CRITICAL | | 191 G_LOG_LEVEL_CRITICAL | |
| 183 G_LOG_LEVEL_WARNING), | 192 G_LOG_LEVEL_WARNING), |
| 184 GLibFatalLogHandler, | 193 GLibLogHandler, |
| 185 NULL); | 194 NULL); |
| 186 } | 195 } |
| 187 } | 196 } |
| 188 #endif // defined(OS_LINUX) | 197 #endif // defined(OS_LINUX) |
| 189 | 198 |
| 190 // Register the invalid param handler and pure call handler to be able to | 199 // Register the invalid param handler and pure call handler to be able to |
| 191 // notify breakpad when it happens. | 200 // notify breakpad when it happens. |
| 192 void RegisterInvalidParamHandler() { | 201 void RegisterInvalidParamHandler() { |
| 193 #if defined(OS_WIN) | 202 #if defined(OS_WIN) |
| 194 _set_invalid_parameter_handler(InvalidParameter); | 203 _set_invalid_parameter_handler(InvalidParameter); |
| (...skipping 242 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 437 _CrtDumpMemoryLeaks(); | 446 _CrtDumpMemoryLeaks(); |
| 438 #endif // _CRTDBG_MAP_ALLOC | 447 #endif // _CRTDBG_MAP_ALLOC |
| 439 | 448 |
| 440 _Module.Term(); | 449 _Module.Term(); |
| 441 #endif | 450 #endif |
| 442 | 451 |
| 443 logging::CleanupChromeLogging(); | 452 logging::CleanupChromeLogging(); |
| 444 | 453 |
| 445 return rv; | 454 return rv; |
| 446 } | 455 } |
| OLD | NEW |