| 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 19 matching lines...) Expand all Loading... |
| 30 enum MediaLogLevel { | 30 enum MediaLogLevel { |
| 31 MEDIALOG_ERROR, | 31 MEDIALOG_ERROR, |
| 32 MEDIALOG_INFO, | 32 MEDIALOG_INFO, |
| 33 MEDIALOG_DEBUG, | 33 MEDIALOG_DEBUG, |
| 34 }; | 34 }; |
| 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 |
| 41 // Returns a string version of the status, unique to each PipelineStatus, and |
| 42 // not including any ':'. This makes it suitable for usage in |
| 43 // MediaError.message as the UA-specific-error-code. |
| 40 static std::string PipelineStatusToString(PipelineStatus status); | 44 static std::string PipelineStatusToString(PipelineStatus status); |
| 45 |
| 41 static std::string BufferingStateToString(BufferingState state); | 46 static std::string BufferingStateToString(BufferingState state); |
| 42 | 47 |
| 43 static std::string MediaEventToLogString(const MediaLogEvent& event); | 48 static std::string MediaEventToLogString(const MediaLogEvent& event); |
| 44 | 49 |
| 50 // Returns a string usable as part of a MediaError.message, for only |
| 51 // PIPELINE_ERROR or MEDIA_ERROR_LOG_ENTRY events, with any newlines replaced |
| 52 // with whitespace in the latter kind of events. |
| 53 static std::string MediaEventToMessageString(const MediaLogEvent& event); |
| 54 |
| 45 MediaLog(); | 55 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 107 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 170 #define LIMITED_MEDIA_LOG(level, media_log, count, max) \ | 184 #define LIMITED_MEDIA_LOG(level, media_log, count, max) \ |
| 171 LAZY_STREAM(MEDIA_LOG(level, media_log), \ | 185 LAZY_STREAM(MEDIA_LOG(level, media_log), \ |
| 172 (count) < (max) && ((count)++ || true)) \ | 186 (count) < (max) && ((count)++ || true)) \ |
| 173 << (((count) == (max)) ? "(Log limit reached. Further similar entries " \ | 187 << (((count) == (max)) ? "(Log limit reached. Further similar entries " \ |
| 174 "may be suppressed): " \ | 188 "may be suppressed): " \ |
| 175 : "") | 189 : "") |
| 176 | 190 |
| 177 } // namespace media | 191 } // namespace media |
| 178 | 192 |
| 179 #endif // MEDIA_BASE_MEDIA_LOG_H_ | 193 #endif // MEDIA_BASE_MEDIA_LOG_H_ |
| OLD | NEW |