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 24 matching lines...) Expand all Loading... |
35 | 35 |
36 // Convert various enums to strings. | 36 // Convert various enums to strings. |
37 static std::string MediaLogLevelToString(MediaLogLevel level); | 37 static std::string MediaLogLevelToString(MediaLogLevel level); |
38 static MediaLogEvent::Type MediaLogLevelToEventType(MediaLogLevel level); | 38 static MediaLogEvent::Type MediaLogLevelToEventType(MediaLogLevel level); |
39 static std::string EventTypeToString(MediaLogEvent::Type type); | 39 static std::string EventTypeToString(MediaLogEvent::Type type); |
40 static std::string PipelineStatusToString(PipelineStatus status); | 40 static std::string PipelineStatusToString(PipelineStatus status); |
41 static std::string BufferingStateToString(BufferingState state); | 41 static std::string BufferingStateToString(BufferingState state); |
42 | 42 |
43 static std::string MediaEventToLogString(const MediaLogEvent& event); | 43 static std::string MediaEventToLogString(const MediaLogEvent& event); |
44 | 44 |
| 45 // Returns a string usable as part of a MediaError.message, for only |
| 46 // PIPELINE_ERROR or MEDIA_ERROR_LOG_ENTRY events, with any newlines replaced |
| 47 // with whitespace in the latter kind of events. |
| 48 static std::string MediaEventToMessageString(const MediaLogEvent& event); |
| 49 |
45 MediaLog(); | 50 MediaLog(); |
46 | 51 |
47 // Add an event to this log. Overriden by inheritors to actually do something | 52 // Add an event to this log. Overriden by inheritors to actually do something |
48 // with it. | 53 // with it. |
49 virtual void AddEvent(std::unique_ptr<MediaLogEvent> event); | 54 virtual void AddEvent(std::unique_ptr<MediaLogEvent> event); |
50 | 55 |
51 // Retrieve an error message, if any. | 56 virtual std::string GetErrorMessage(); |
52 virtual std::string GetLastErrorMessage(); | |
53 | 57 |
54 // Records the domain and registry of the current frame security origin to a | 58 // Records the domain and registry of the current frame security origin to a |
55 // Rappor privacy-preserving metric. See: | 59 // Rappor privacy-preserving metric. See: |
56 // https://www.chromium.org/developers/design-documents/rappor | 60 // https://www.chromium.org/developers/design-documents/rappor |
57 virtual void RecordRapporWithSecurityOrigin(const std::string& metric); | 61 virtual void RecordRapporWithSecurityOrigin(const std::string& metric); |
58 | 62 |
59 // Helper methods to create events and their parameters. | 63 // Helper methods to create events and their parameters. |
60 std::unique_ptr<MediaLogEvent> CreateEvent(MediaLogEvent::Type type); | 64 std::unique_ptr<MediaLogEvent> CreateEvent(MediaLogEvent::Type type); |
61 std::unique_ptr<MediaLogEvent> CreateBooleanEvent(MediaLogEvent::Type type, | 65 std::unique_ptr<MediaLogEvent> CreateBooleanEvent(MediaLogEvent::Type type, |
62 const std::string& property, | 66 const std::string& property, |
(...skipping 107 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
170 #define LIMITED_MEDIA_LOG(level, media_log, count, max) \ | 174 #define LIMITED_MEDIA_LOG(level, media_log, count, max) \ |
171 LAZY_STREAM(MEDIA_LOG(level, media_log), \ | 175 LAZY_STREAM(MEDIA_LOG(level, media_log), \ |
172 (count) < (max) && ((count)++ || true)) \ | 176 (count) < (max) && ((count)++ || true)) \ |
173 << (((count) == (max)) ? "(Log limit reached. Further similar entries " \ | 177 << (((count) == (max)) ? "(Log limit reached. Further similar entries " \ |
174 "may be suppressed): " \ | 178 "may be suppressed): " \ |
175 : "") | 179 : "") |
176 | 180 |
177 } // namespace media | 181 } // namespace media |
178 | 182 |
179 #endif // MEDIA_BASE_MEDIA_LOG_H_ | 183 #endif // MEDIA_BASE_MEDIA_LOG_H_ |
OLD | NEW |