[M94 Dev][Tizen] Fix for errors for generating ninja files
[platform/framework/web/chromium-efl.git] / base / check.cc
1 // Copyright 2020 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4
5 #include "base/check.h"
6
7 // check.h is a widely included header and its size has significant impact on
8 // build time. Try not to raise this limit unless absolutely necessary. See
9 // https://chromium.googlesource.com/chromium/src/+/HEAD/docs/wmax_tokens.md
10 #ifndef NACL_TC_REV
11 #pragma clang max_tokens_here 17000
12 #endif
13
14 #include "base/check_op.h"
15 #include "base/logging.h"
16 #include "build/build_config.h"
17
18 namespace logging {
19
20 CheckError CheckError::Check(const char* file,
21                              int line,
22                              const char* condition) {
23   CheckError check_error(new LogMessage(file, line, LOGGING_FATAL));
24   check_error.stream() << "Check failed: " << condition << ". ";
25   return check_error;
26 }
27
28 CheckError CheckError::CheckOp(const char* file,
29                                int line,
30                                CheckOpResult* check_op_result) {
31   CheckError check_error(new LogMessage(file, line, LOGGING_FATAL));
32   check_error.stream() << "Check failed: " << check_op_result->message_;
33   free(check_op_result->message_);
34   check_op_result->message_ = nullptr;
35   return check_error;
36 }
37
38 CheckError CheckError::DCheck(const char* file,
39                               int line,
40                               const char* condition) {
41   CheckError check_error(new LogMessage(file, line, LOGGING_DCHECK));
42   check_error.stream() << "Check failed: " << condition << ". ";
43   return check_error;
44 }
45
46 CheckError CheckError::DCheckOp(const char* file,
47                                 int line,
48                                 CheckOpResult* check_op_result) {
49   CheckError check_error(new LogMessage(file, line, LOGGING_DCHECK));
50   check_error.stream() << "Check failed: " << check_op_result->message_;
51   free(check_op_result->message_);
52   check_op_result->message_ = nullptr;
53   return check_error;
54 }
55
56 CheckError CheckError::PCheck(const char* file,
57                               int line,
58                               const char* condition) {
59   SystemErrorCode err_code = logging::GetLastSystemErrorCode();
60 #if defined(OS_WIN)
61   CheckError check_error(
62       new Win32ErrorLogMessage(file, line, LOGGING_FATAL, err_code));
63 #elif defined(OS_POSIX) || defined(OS_FUCHSIA)
64   CheckError check_error(
65       new ErrnoLogMessage(file, line, LOGGING_FATAL, err_code));
66 #endif
67   check_error.stream() << "Check failed: " << condition << ". ";
68   return check_error;
69 }
70
71 CheckError CheckError::PCheck(const char* file, int line) {
72   return PCheck(file, line, "");
73 }
74
75 CheckError CheckError::DPCheck(const char* file,
76                                int line,
77                                const char* condition) {
78   SystemErrorCode err_code = logging::GetLastSystemErrorCode();
79 #if defined(OS_WIN)
80   CheckError check_error(
81       new Win32ErrorLogMessage(file, line, LOGGING_DCHECK, err_code));
82 #elif defined(OS_POSIX) || defined(OS_FUCHSIA)
83   CheckError check_error(
84       new ErrnoLogMessage(file, line, LOGGING_DCHECK, err_code));
85 #endif
86   check_error.stream() << "Check failed: " << condition << ". ";
87   return check_error;
88 }
89
90 CheckError CheckError::NotImplemented(const char* file,
91                                       int line,
92                                       const char* function) {
93   CheckError check_error(new LogMessage(file, line, LOGGING_ERROR));
94   check_error.stream() << "Not implemented reached in " << function;
95   return check_error;
96 }
97
98 std::ostream& CheckError::stream() {
99   return log_message_->stream();
100 }
101
102 CheckError::~CheckError() {
103   // Note: This function ends up in crash stack traces. If its full name
104   // changes, the crash server's magic signature logic needs to be updated.
105   // See cl/306632920.
106   delete log_message_;
107 }
108
109 CheckError::CheckError(LogMessage* log_message) : log_message_(log_message) {}
110
111 void RawCheck(const char* message) {
112   RawLog(LOGGING_FATAL, message);
113 }
114
115 }  // namespace logging