Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(699)

Side by Side Diff: chrome/app/chrome_dll_main.cc

Issue 56072: Make Gtk/Gdk/GLib errors/warnings really fatal. (Closed)
Patch Set: extract to function Created 11 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « no previous file | chrome/chrome.gyp » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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"
(...skipping 141 matching lines...) Expand 10 before | Expand all | Expand 10 after
152 return false; 152 return false;
153 } 153 }
154 } 154 }
155 155
156 return true; 156 return true;
157 } 157 }
158 158
159 #endif // OS_WIN 159 #endif // OS_WIN
160 160
161 #if defined(OS_LINUX) 161 #if defined(OS_LINUX)
162 static void GtkFatalLogHandler(const gchar* log_domain, 162 static void GLibFatalLogHandler(const gchar* log_domain,
163 GLogLevelFlags log_level, 163 GLogLevelFlags log_level,
164 const gchar* message, 164 const gchar* message,
165 gpointer userdata) { 165 gpointer userdata) {
166 if (!log_domain) 166 if (!log_domain)
167 log_domain = "<all>"; 167 log_domain = "<unknown>";
168 if (!message) 168 if (!message)
169 message = "<no message>"; 169 message = "<no message>";
170 170
171 NOTREACHED() << "GTK: (" << log_domain << "): " << message; 171 LOG(FATAL) << log_domain << ": " << message;
172 } 172 }
173 #endif 173
174 static void SetUpGLibLogHandler() {
175 // Register GLib-handled assertions to go through our logging system.
176 const char* kLogDomains[] = { NULL, "Gtk", "Gdk", "GLib" };
177 for (size_t i = 0; i < arraysize(kLogDomains); i++) {
178 g_log_set_handler(kLogDomains[i],
179 static_cast<GLogLevelFlags>(G_LOG_FLAG_RECURSION |
180 G_LOG_FLAG_FATAL |
181 G_LOG_LEVEL_ERROR |
182 G_LOG_LEVEL_CRITICAL |
183 G_LOG_LEVEL_WARNING),
184 GLibFatalLogHandler,
185 NULL);
186 }
187 }
188 #endif // defined(OS_LINUX)
174 189
175 // Register the invalid param handler and pure call handler to be able to 190 // Register the invalid param handler and pure call handler to be able to
176 // notify breakpad when it happens. 191 // notify breakpad when it happens.
177 void RegisterInvalidParamHandler() { 192 void RegisterInvalidParamHandler() {
178 #if defined(OS_WIN) 193 #if defined(OS_WIN)
179 _set_invalid_parameter_handler(InvalidParameter); 194 _set_invalid_parameter_handler(InvalidParameter);
180 _set_purecall_handler(PureCall); 195 _set_purecall_handler(PureCall);
181 // Gather allocation failure. 196 // Gather allocation failure.
182 _set_new_handler(&OnNoMemory); 197 _set_new_handler(&OnNoMemory);
183 // Make sure malloc() calls the new handler too. 198 // Make sure malloc() calls the new handler too.
(...skipping 213 matching lines...) Expand 10 before | Expand all | Expand 10 after
397 rv = PluginMain(main_params); 412 rv = PluginMain(main_params);
398 #endif 413 #endif
399 } else if (process_type == switches::kWorkerProcess) { 414 } else if (process_type == switches::kWorkerProcess) {
400 #if defined(OS_WIN) 415 #if defined(OS_WIN)
401 rv = WorkerMain(main_params); 416 rv = WorkerMain(main_params);
402 #endif 417 #endif
403 } else if (process_type.empty()) { 418 } else if (process_type.empty()) {
404 #if defined(OS_LINUX) 419 #if defined(OS_LINUX)
405 // gtk_init() can change |argc| and |argv|, but nobody else uses them. 420 // gtk_init() can change |argc| and |argv|, but nobody else uses them.
406 gtk_init(&argc, const_cast<char***>(&argv)); 421 gtk_init(&argc, const_cast<char***>(&argv));
407 // Register GTK assertions to go through our logging system. 422 SetUpGLibLogHandler();
408 g_log_set_handler(NULL, // All logging domains.
409 static_cast<GLogLevelFlags>(G_LOG_FLAG_RECURSION |
410 G_LOG_FLAG_FATAL |
411 G_LOG_LEVEL_ERROR |
412 G_LOG_LEVEL_CRITICAL |
413 G_LOG_LEVEL_WARNING),
414 GtkFatalLogHandler,
415 NULL);
416 #endif 423 #endif
417 424
418 ScopedOleInitializer ole_initializer; 425 ScopedOleInitializer ole_initializer;
419 rv = BrowserMain(main_params); 426 rv = BrowserMain(main_params);
420 } else { 427 } else {
421 NOTREACHED() << "Unknown process type"; 428 NOTREACHED() << "Unknown process type";
422 } 429 }
423 430
424 if (!process_type.empty()) { 431 if (!process_type.empty()) {
425 ResourceBundle::CleanupSharedInstance(); 432 ResourceBundle::CleanupSharedInstance();
426 } 433 }
427 434
428 #if defined(OS_WIN) 435 #if defined(OS_WIN)
429 #ifdef _CRTDBG_MAP_ALLOC 436 #ifdef _CRTDBG_MAP_ALLOC
430 _CrtDumpMemoryLeaks(); 437 _CrtDumpMemoryLeaks();
431 #endif // _CRTDBG_MAP_ALLOC 438 #endif // _CRTDBG_MAP_ALLOC
432 439
433 _Module.Term(); 440 _Module.Term();
434 #endif 441 #endif
435 442
436 logging::CleanupChromeLogging(); 443 logging::CleanupChromeLogging();
437 444
438 return rv; 445 return rv;
439 } 446 }
OLDNEW
« no previous file with comments | « no previous file | chrome/chrome.gyp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698