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

Side by Side Diff: third_party/cld/base/logging.h

Issue 1911823002: Convert //third_party from scoped_ptr to std::unique_ptr (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Update crashpad's README.chromium Created 4 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 | « third_party/cld/BUILD.gn ('k') | third_party/cld/base/scoped_ptr.h » ('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) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 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 #ifndef _LOGGING_H_ 5 #ifndef _LOGGING_H_
6 #define _LOGGING_H_ 6 #define _LOGGING_H_
7 7
8 #include <errno.h> 8 #include <errno.h>
9 #include <string.h> 9 #include <string.h>
10 #include <time.h> 10 #include <time.h>
11
12 #include <memory>
11 #include <string> 13 #include <string>
12 #include <strstream> 14 #include <strstream>
13 #include <vector> 15 #include <vector>
14 16
15 #ifndef COMPILER_MSVC 17 #ifndef COMPILER_MSVC
16 #include <unistd.h> // for _exit() 18 #include <unistd.h> // for _exit()
17 #endif 19 #endif
18 20
19 #include "base/port.h" 21 #include "base/port.h"
20 #include "base/basictypes.h" 22 #include "base/basictypes.h"
21 #include "base/commandlineflags.h" 23 #include "base/commandlineflags.h"
22 #include "base/crash.h" 24 #include "base/crash.h"
23 #include "base/dynamic_annotations.h" 25 #include "base/dynamic_annotations.h"
24 #include "base/macros.h" 26 #include "base/macros.h"
25 #include "base/memory/scoped_ptr.h"
26 #include "base/stl_decl_msvc.h" 27 #include "base/stl_decl_msvc.h"
27 #include "base/log_severity.h" 28 #include "base/log_severity.h"
28 #include "base/vlog_is_on.h" 29 #include "base/vlog_is_on.h"
29 #include "global_strip_options.h" 30 #include "global_strip_options.h"
30 31
31 // Make a bunch of macros for logging. The way to log things is to stream 32 // Make a bunch of macros for logging. The way to log things is to stream
32 // things to LOG(<a particular severity level>). E.g., 33 // things to LOG(<a particular severity level>). E.g.,
33 // 34 //
34 // LOG(INFO) << "Found " << num_cookies << " cookies"; 35 // LOG(INFO) << "Found " << num_cookies << " cookies";
35 // 36 //
(...skipping 953 matching lines...) Expand 10 before | Expand all | Expand 10 after
989 static int64 num_messages_[NUM_SEVERITIES]; // under log_mutex 990 static int64 num_messages_[NUM_SEVERITIES]; // under log_mutex
990 991
991 // We keep the data in a separate struct so that each instance of 992 // We keep the data in a separate struct so that each instance of
992 // LogMessage uses less stack space. 993 // LogMessage uses less stack space.
993 struct LogMessageData { 994 struct LogMessageData {
994 LogMessageData() {}; 995 LogMessageData() {};
995 996
996 int preserved_errno_; // errno at Init() time 997 int preserved_errno_; // errno at Init() time
997 scoped_array<char> buf_; // buffer space for non FATAL messages 998 scoped_array<char> buf_; // buffer space for non FATAL messages
998 char* message_text_; // Complete message text 999 char* message_text_; // Complete message text
999 scoped_ptr<LogStream> stream_alloc_; 1000 std::unique_ptr<LogStream> stream_alloc_;
1000 LogStream* stream_; 1001 LogStream* stream_;
1001 char severity_; // level of LogMessage (ex. I, W, E, F) 1002 char severity_; // level of LogMessage (ex. I, W, E, F)
1002 int line_; // line number of file that called LOG 1003 int line_; // line number of file that called LOG
1003 void (LogMessage::*send_method_)(); // Call this in destructor to send 1004 void (LogMessage::*send_method_)(); // Call this in destructor to send
1004 union { // At most one of these is used: union to keep the size low. 1005 union { // At most one of these is used: union to keep the size low.
1005 LogSink* sink_; // NULL or sink to send message to 1006 LogSink* sink_; // NULL or sink to send message to
1006 vector<string>* outvec_; // NULL or vector to push message onto 1007 vector<string>* outvec_; // NULL or vector to push message onto
1007 string* message_; // NULL or string to write message into 1008 string* message_; // NULL or string to write message into
1008 }; 1009 };
1009 time_t timestamp_; // Time of creation of LogMessage 1010 time_t timestamp_; // Time of creation of LogMessage
1010 struct tm tm_time_; // Time of creation of LogMessage 1011 struct tm tm_time_; // Time of creation of LogMessage
1011 size_t num_prefix_chars_; // # of chars of prefix in this message 1012 size_t num_prefix_chars_; // # of chars of prefix in this message
1012 size_t num_chars_to_log_; // # of chars of msg to send to log 1013 size_t num_chars_to_log_; // # of chars of msg to send to log
1013 size_t num_chars_to_syslog_; // # of chars of msg to send to syslog 1014 size_t num_chars_to_syslog_; // # of chars of msg to send to syslog
1014 const char* basename_; // basename of file that called LOG 1015 const char* basename_; // basename of file that called LOG
1015 const char* fullname_; // fullname of file that called LOG 1016 const char* fullname_; // fullname of file that called LOG
1016 bool has_been_flushed_; // false => data has not been flushed 1017 bool has_been_flushed_; // false => data has not been flushed
1017 bool first_fatal_; // true => this was first fatal msg 1018 bool first_fatal_; // true => this was first fatal msg
1018 1019
1019 private: 1020 private:
1020 DISALLOW_EVIL_CONSTRUCTORS(LogMessageData); 1021 DISALLOW_EVIL_CONSTRUCTORS(LogMessageData);
1021 }; 1022 };
1022 1023
1023 static LogMessageData fatal_msg_data_exclusive_; 1024 static LogMessageData fatal_msg_data_exclusive_;
1024 static LogMessageData fatal_msg_data_shared_; 1025 static LogMessageData fatal_msg_data_shared_;
1025 1026
1026 scoped_ptr<LogMessageData> allocated_; 1027 std::unique_ptr<LogMessageData> allocated_;
1027 LogMessageData* data_; 1028 LogMessageData* data_;
1028 1029
1029 friend class LogDestination; 1030 friend class LogDestination;
1030 1031
1031 DISALLOW_EVIL_CONSTRUCTORS(LogMessage); 1032 DISALLOW_EVIL_CONSTRUCTORS(LogMessage);
1032 1033
1033 protected: 1034 protected:
1034 // Default false; if true, all failures should be as quiet as possible. This 1035 // Default false; if true, all failures should be as quiet as possible. This
1035 // is stored in LogMessage, rather than LogMessageData, because all FATAL- 1036 // is stored in LogMessage, rather than LogMessageData, because all FATAL-
1036 // level handlers share the same LogMessageData for signal safety reasons. 1037 // level handlers share the same LogMessageData for signal safety reasons.
(...skipping 357 matching lines...) Expand 10 before | Expand all | Expand 10 after
1394 // trace), like LogMessageFatal. 1395 // trace), like LogMessageFatal.
1395 class NullStreamFatal : public NullStream { 1396 class NullStreamFatal : public NullStream {
1396 public: 1397 public:
1397 NullStreamFatal() { } 1398 NullStreamFatal() { }
1398 NullStreamFatal(const char* file, int line, const CheckOpString& result) : 1399 NullStreamFatal(const char* file, int line, const CheckOpString& result) :
1399 NullStream(file, line, result) { } 1400 NullStream(file, line, result) { }
1400 ~NullStreamFatal() ATTRIBUTE_NORETURN { _exit(1); } 1401 ~NullStreamFatal() ATTRIBUTE_NORETURN { _exit(1); }
1401 }; 1402 };
1402 1403
1403 #endif // _LOGGING_H_ 1404 #endif // _LOGGING_H_
OLDNEW
« no previous file with comments | « third_party/cld/BUILD.gn ('k') | third_party/cld/base/scoped_ptr.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698