OLD | NEW |
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 #ifndef MEDIA_BASE_MEDIA_LOG_H_ | 5 #ifndef MEDIA_BASE_MEDIA_LOG_H_ |
6 #define MEDIA_BASE_MEDIA_LOG_H_ | 6 #define MEDIA_BASE_MEDIA_LOG_H_ |
7 | 7 |
8 #include <stddef.h> | 8 #include <stddef.h> |
9 #include <stdint.h> | 9 #include <stdint.h> |
10 | 10 |
(...skipping 18 matching lines...) Expand all Loading... |
29 enum MediaLogLevel { | 29 enum MediaLogLevel { |
30 MEDIALOG_ERROR, | 30 MEDIALOG_ERROR, |
31 MEDIALOG_INFO, | 31 MEDIALOG_INFO, |
32 MEDIALOG_DEBUG, | 32 MEDIALOG_DEBUG, |
33 }; | 33 }; |
34 | 34 |
35 // Convert various enums to strings. | 35 // Convert various enums to strings. |
36 static std::string MediaLogLevelToString(MediaLogLevel level); | 36 static std::string MediaLogLevelToString(MediaLogLevel level); |
37 static MediaLogEvent::Type MediaLogLevelToEventType(MediaLogLevel level); | 37 static MediaLogEvent::Type MediaLogLevelToEventType(MediaLogLevel level); |
38 static std::string EventTypeToString(MediaLogEvent::Type type); | 38 static std::string EventTypeToString(MediaLogEvent::Type type); |
| 39 |
| 40 // Returns a string version of the status, unique to each PipelineStatus, and |
| 41 // not including any ':'. This makes it suitable for usage in |
| 42 // MediaError.message as the UA-specific-error-code. |
39 static std::string PipelineStatusToString(PipelineStatus status); | 43 static std::string PipelineStatusToString(PipelineStatus status); |
| 44 |
40 static std::string BufferingStateToString(BufferingState state); | 45 static std::string BufferingStateToString(BufferingState state); |
41 | 46 |
42 static std::string MediaEventToLogString(const MediaLogEvent& event); | 47 static std::string MediaEventToLogString(const MediaLogEvent& event); |
43 | 48 |
| 49 // Returns a string usable as part of a MediaError.message, for only |
| 50 // PIPELINE_ERROR or MEDIA_ERROR_LOG_ENTRY events, with any newlines replaced |
| 51 // with whitespace in the latter kind of events. |
| 52 static std::string MediaEventToMessageString(const MediaLogEvent& event); |
| 53 |
44 MediaLog(); | 54 MediaLog(); |
45 virtual ~MediaLog(); | 55 virtual ~MediaLog(); |
46 | 56 |
47 // Add an event to this log. Overriden by inheritors to actually do something | 57 // Add an event to this log. Overriden by inheritors to actually do something |
48 // with it. | 58 // with it. |
49 virtual void AddEvent(std::unique_ptr<MediaLogEvent> event); | 59 virtual void AddEvent(std::unique_ptr<MediaLogEvent> event); |
50 | 60 |
51 // Retrieve an error message, if any. | 61 // Returns a string usable as the contents of a MediaError.message. |
52 virtual std::string GetLastErrorMessage(); | 62 // This method returns an incomplete message if it is called before the |
| 63 // pertinent events for the error have been added to the log. |
| 64 // Note: The base class definition only produces empty messages. See |
| 65 // RenderMediaLog for where this method is meaningful. |
| 66 virtual std::string GetErrorMessage(); |
53 | 67 |
54 // Records the domain and registry of the current frame security origin to a | 68 // Records the domain and registry of the current frame security origin to a |
55 // Rappor privacy-preserving metric. See: | 69 // Rappor privacy-preserving metric. See: |
56 // https://www.chromium.org/developers/design-documents/rappor | 70 // https://www.chromium.org/developers/design-documents/rappor |
57 virtual void RecordRapporWithSecurityOrigin(const std::string& metric); | 71 virtual void RecordRapporWithSecurityOrigin(const std::string& metric); |
58 | 72 |
59 // Helper methods to create events and their parameters. | 73 // Helper methods to create events and their parameters. |
60 std::unique_ptr<MediaLogEvent> CreateEvent(MediaLogEvent::Type type); | 74 std::unique_ptr<MediaLogEvent> CreateEvent(MediaLogEvent::Type type); |
61 std::unique_ptr<MediaLogEvent> CreateBooleanEvent(MediaLogEvent::Type type, | 75 std::unique_ptr<MediaLogEvent> CreateBooleanEvent(MediaLogEvent::Type type, |
62 const std::string& property, | 76 const std::string& property, |
(...skipping 102 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
165 #define LIMITED_MEDIA_LOG(level, media_log, count, max) \ | 179 #define LIMITED_MEDIA_LOG(level, media_log, count, max) \ |
166 LAZY_STREAM(MEDIA_LOG(level, media_log), \ | 180 LAZY_STREAM(MEDIA_LOG(level, media_log), \ |
167 (count) < (max) && ((count)++ || true)) \ | 181 (count) < (max) && ((count)++ || true)) \ |
168 << (((count) == (max)) ? "(Log limit reached. Further similar entries " \ | 182 << (((count) == (max)) ? "(Log limit reached. Further similar entries " \ |
169 "may be suppressed): " \ | 183 "may be suppressed): " \ |
170 : "") | 184 : "") |
171 | 185 |
172 } // namespace media | 186 } // namespace media |
173 | 187 |
174 #endif // MEDIA_BASE_MEDIA_LOG_H_ | 188 #endif // MEDIA_BASE_MEDIA_LOG_H_ |
OLD | NEW |