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

Side by Side Diff: chrome/common/logging_chrome.cc

Issue 1012683003: Remove some dead code, fix some includes and whitespace. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 9 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 | « chrome/common/logging_chrome.h ('k') | no next file » | 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) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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 "build/build_config.h" 5 #include "build/build_config.h"
6 6
7 // Need to include this before most other files because it defines 7 // Need to include this before most other files because it defines
8 // IPC_MESSAGE_LOG_ENABLED. We need to use it to define 8 // IPC_MESSAGE_LOG_ENABLED. We need to use it to define
9 // IPC_MESSAGE_MACROS_LOG_ENABLED so render_messages.h will generate the 9 // IPC_MESSAGE_MACROS_LOG_ENABLED so render_messages.h will generate the
10 // ViewMsgLog et al. functions. 10 // ViewMsgLog et al. functions.
11 #include "ipc/ipc_message.h" 11 #include "ipc/ipc_message.h"
12 12
13 // On Windows, the about:ipc dialog shows IPCs; on POSIX, we hook up a 13 // On Windows, the about:ipc dialog shows IPCs; on POSIX, we hook up a
14 // logger in this file. (We implement about:ipc on Mac but implement 14 // logger in this file. (We implement about:ipc on Mac but implement
15 // the loggers here anyway). We need to do this real early to be sure 15 // the loggers here anyway). We need to do this real early to be sure
16 // IPC_MESSAGE_MACROS_LOG_ENABLED doesn't get undefined. 16 // IPC_MESSAGE_MACROS_LOG_ENABLED doesn't get undefined.
17 #if defined(OS_POSIX) && defined(IPC_MESSAGE_LOG_ENABLED) 17 #if defined(OS_POSIX) && defined(IPC_MESSAGE_LOG_ENABLED)
18 #define IPC_MESSAGE_MACROS_LOG_ENABLED 18 #define IPC_MESSAGE_MACROS_LOG_ENABLED
19 #include "content/public/common/content_ipc_logging.h" 19 #include "content/public/common/content_ipc_logging.h"
20 #define IPC_LOG_TABLE_ADD_ENTRY(msg_id, logger) \ 20 #define IPC_LOG_TABLE_ADD_ENTRY(msg_id, logger) \
21 content::RegisterIPCLogger(msg_id, logger) 21 content::RegisterIPCLogger(msg_id, logger)
22 #include "chrome/common/all_messages.h" 22 #include "chrome/common/all_messages.h"
23 #endif 23 #endif
24 24
25 #if defined(OS_WIN) 25 #if defined(OS_WIN)
26 #include <windows.h> 26 #include <windows.h>
27 #endif 27 #endif
28 28
29 #include <fstream> 29 #include "chrome/common/logging_chrome.h"
30 30
31 #include "chrome/common/logging_chrome.h" 31 #include <fstream> // NOLINT
32 #include <string> // NOLINT
32 33
33 #include "base/command_line.h" 34 #include "base/command_line.h"
34 #include "base/compiler_specific.h" 35 #include "base/compiler_specific.h"
35 #include "base/debug/debugger.h" 36 #include "base/debug/debugger.h"
36 #include "base/debug/dump_without_crashing.h" 37 #include "base/debug/dump_without_crashing.h"
37 #include "base/environment.h" 38 #include "base/environment.h"
38 #include "base/files/file_path.h" 39 #include "base/files/file_path.h"
39 #include "base/files/file_util.h" 40 #include "base/files/file_util.h"
40 #include "base/logging.h"
41 #include "base/path_service.h" 41 #include "base/path_service.h"
42 #include "base/strings/string_number_conversions.h" 42 #include "base/strings/string_number_conversions.h"
43 #include "base/strings/string_util.h" 43 #include "base/strings/string_util.h"
44 #include "base/strings/stringprintf.h" 44 #include "base/strings/stringprintf.h"
45 #include "base/strings/utf_string_conversions.h" 45 #include "base/strings/utf_string_conversions.h"
46 #include "base/threading/thread_restrictions.h" 46 #include "base/threading/thread_restrictions.h"
47 #include "base/time/time.h"
48 #include "chrome/common/chrome_constants.h" 47 #include "chrome/common/chrome_constants.h"
49 #include "chrome/common/chrome_paths.h" 48 #include "chrome/common/chrome_paths.h"
50 #include "chrome/common/chrome_switches.h" 49 #include "chrome/common/chrome_switches.h"
51 #include "chrome/common/env_vars.h" 50 #include "chrome/common/env_vars.h"
52 #include "ipc/ipc_logging.h" 51 #include "ipc/ipc_logging.h"
53 52
54 #if defined(OS_CHROMEOS) 53 #if defined(OS_CHROMEOS)
55 #include "chromeos/chromeos_switches.h" 54 #include "chromeos/chromeos_switches.h"
56 #endif 55 #endif
57 56
(...skipping 327 matching lines...) Expand 10 before | Expand all | Expand 10 after
385 return log_path; 384 return log_path;
386 } else { 385 } else {
387 // error with path service, just use some default file somewhere 386 // error with path service, just use some default file somewhere
388 return log_filename; 387 return log_filename;
389 } 388 }
390 } 389 }
391 390
392 bool DialogsAreSuppressed() { 391 bool DialogsAreSuppressed() {
393 return dialogs_are_suppressed_; 392 return dialogs_are_suppressed_;
394 } 393 }
395
396 size_t GetFatalAssertions(AssertionList* assertions) {
397 // In this function, we don't assume that assertions is non-null, so
398 // that if you just want an assertion count, you can pass in NULL.
399 if (assertions)
400 assertions->clear();
401 size_t assertion_count = 0;
402
403 std::ifstream log_file;
404 log_file.open(GetLogFileName().value().c_str());
405 if (!log_file.is_open())
406 return 0;
407
408 std::string utf8_line;
409 std::wstring wide_line;
410 while (!log_file.eof()) {
411 getline(log_file, utf8_line);
412 if (utf8_line.find(":FATAL:") != std::string::npos) {
413 wide_line = base::UTF8ToWide(utf8_line);
414 if (assertions)
415 assertions->push_back(wide_line);
416 ++assertion_count;
417 }
418 }
419 log_file.close();
420
421 return assertion_count;
422 }
423
424 base::FilePath GenerateTimestampedName(const base::FilePath& base_path, 394 base::FilePath GenerateTimestampedName(const base::FilePath& base_path,
425 base::Time timestamp) { 395 base::Time timestamp) {
426 base::Time::Exploded time_deets; 396 base::Time::Exploded time_deets;
427 timestamp.LocalExplode(&time_deets); 397 timestamp.LocalExplode(&time_deets);
428 std::string suffix = base::StringPrintf("_%02d%02d%02d-%02d%02d%02d", 398 std::string suffix = base::StringPrintf("_%02d%02d%02d-%02d%02d%02d",
429 time_deets.year, 399 time_deets.year,
430 time_deets.month, 400 time_deets.month,
431 time_deets.day_of_month, 401 time_deets.day_of_month,
432 time_deets.hour, 402 time_deets.hour,
433 time_deets.minute, 403 time_deets.minute,
434 time_deets.second); 404 time_deets.second);
435 return base_path.InsertBeforeExtensionASCII(suffix); 405 return base_path.InsertBeforeExtensionASCII(suffix);
436 } 406 }
437 407
438 } // namespace logging 408 } // namespace logging
OLDNEW
« no previous file with comments | « chrome/common/logging_chrome.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698