1 // Copyright 2019 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 #ifndef BASE_TRACE_EVENT_LOG_MESSAGE_H_
6 #define BASE_TRACE_EVENT_LOG_MESSAGE_H_
7 
8 #include <stddef.h>
9 
10 #include <memory>
11 #include <string>
12 #include <vector>
13 
14 #include "base/macros.h"
15 #include "base/strings/string_piece.h"
16 #include "base/trace_event/trace_event_impl.h"
17 
18 namespace base {
19 
20 class Value;
21 
22 namespace trace_event {
23 
24 class BASE_EXPORT LogMessage : public ConvertableToTraceFormat {
25  public:
26   LogMessage(const char* file, base::StringPiece message, int line);
27   ~LogMessage() override;
28 
29   // ConvertableToTraceFormat class implementation.
30   void AppendAsTraceFormat(std::string* out) const override;
31   bool AppendToProto(ProtoAppender* appender) override;
32 
33   void EstimateTraceMemoryOverhead(TraceEventMemoryOverhead* overhead) override;
34 
file()35   const char* file() const { return file_; }
message()36   const std::string& message() const { return message_; }
line_number()37   int line_number() const { return line_number_; }
38 
39  private:
40   const char* file_;
41   std::string message_;
42   int line_number_;
43   DISALLOW_COPY_AND_ASSIGN(LogMessage);
44 };
45 
46 }  // namespace trace_event
47 }  // namespace base
48 
49 #endif  // BASE_TRACE_EVENT_LOG_MESSAGE_H_