| 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 |
| 11 #include <map> |
| 11 #include <memory> | 12 #include <memory> |
| 12 #include <sstream> | 13 #include <sstream> |
| 13 #include <string> | 14 #include <string> |
| 15 #include <vector> |
| 14 | 16 |
| 15 #include "base/containers/flat_set.h" | 17 #include "base/containers/flat_set.h" |
| 16 #include "base/logging.h" | 18 #include "base/logging.h" |
| 17 #include "base/macros.h" | 19 #include "base/macros.h" |
| 18 #include "base/memory/ref_counted.h" | 20 #include "base/memory/ref_counted.h" |
| 19 #include "media/base/buffering_state.h" | 21 #include "media/base/buffering_state.h" |
| 20 #include "media/base/media_export.h" | 22 #include "media/base/media_export.h" |
| 21 #include "media/base/media_log_event.h" | 23 #include "media/base/media_log_event.h" |
| 22 #include "media/base/pipeline_impl.h" | 24 #include "media/base/pipeline_impl.h" |
| 23 #include "media/base/pipeline_status.h" | 25 #include "media/base/pipeline_status.h" |
| 24 #include "url/gurl.h" | 26 #include "url/gurl.h" |
| 25 | 27 |
| 26 namespace media { | 28 namespace media { |
| 27 | 29 |
| 28 class MEDIA_EXPORT MediaLog : public base::RefCountedThreadSafe<MediaLog> { | 30 class MEDIA_EXPORT MediaLog : public base::RefCountedThreadSafe<MediaLog> { |
| 29 public: | 31 public: |
| 30 enum MediaLogLevel { | 32 enum MediaLogLevel { |
| 31 MEDIALOG_ERROR, | 33 MEDIALOG_ERROR, |
| 32 MEDIALOG_INFO, | 34 MEDIALOG_INFO, |
| 33 MEDIALOG_DEBUG, | 35 MEDIALOG_DEBUG, |
| 34 }; | 36 }; |
| 35 | 37 |
| 36 // Convert various enums to strings. | 38 // Convert various enums to strings. |
| 37 static std::string MediaLogLevelToString(MediaLogLevel level); | 39 static std::string MediaLogLevelToString(MediaLogLevel level); |
| 38 static MediaLogEvent::Type MediaLogLevelToEventType(MediaLogLevel level); | 40 static MediaLogEvent::Type MediaLogLevelToEventType(MediaLogLevel level); |
| 39 static std::string EventTypeToString(MediaLogEvent::Type type); | 41 static std::string EventTypeToString(MediaLogEvent::Type type); |
| 40 static std::string PipelineStatusToString(PipelineStatus status); | 42 static std::string PipelineStatusToString(PipelineStatus status); |
| 41 static std::string BufferingStateToString(BufferingState state); | 43 static std::string BufferingStateToString(BufferingState state); |
| 42 | 44 |
| 43 static std::string MediaEventToLogString(const MediaLogEvent& event); | 45 static std::string MediaEventToLogString(const MediaLogEvent& event, |
| 46 bool include_type); |
| 44 | 47 |
| 45 MediaLog(); | 48 MediaLog(); |
| 46 | 49 |
| 47 // Add an event to this log. Overriden by inheritors to actually do something | 50 // Add an event to this log. Overriden by inheritors to actually do something |
| 48 // with it. | 51 // with it. |
| 49 virtual void AddEvent(std::unique_ptr<MediaLogEvent> event); | 52 virtual void AddEvent(std::unique_ptr<MediaLogEvent> event); |
| 50 | 53 |
| 51 // Retrieve an error message, if any. | 54 // Retrieve error messages, if any, keyed by error type. |
| 52 virtual std::string GetLastErrorMessage(); | 55 virtual std::map<std::string, std::vector<std::string>> GetErrorMessages(); |
| 53 | 56 |
| 54 // Records the domain and registry of the current frame security origin to a | 57 // Records the domain and registry of the current frame security origin to a |
| 55 // Rappor privacy-preserving metric. See: | 58 // Rappor privacy-preserving metric. See: |
| 56 // https://www.chromium.org/developers/design-documents/rappor | 59 // https://www.chromium.org/developers/design-documents/rappor |
| 57 virtual void RecordRapporWithSecurityOrigin(const std::string& metric); | 60 virtual void RecordRapporWithSecurityOrigin(const std::string& metric); |
| 58 | 61 |
| 59 // Helper methods to create events and their parameters. | 62 // Helper methods to create events and their parameters. |
| 60 std::unique_ptr<MediaLogEvent> CreateEvent(MediaLogEvent::Type type); | 63 std::unique_ptr<MediaLogEvent> CreateEvent(MediaLogEvent::Type type); |
| 61 std::unique_ptr<MediaLogEvent> CreateBooleanEvent(MediaLogEvent::Type type, | 64 std::unique_ptr<MediaLogEvent> CreateBooleanEvent(MediaLogEvent::Type type, |
| 62 const std::string& property, | 65 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) \ | 173 #define LIMITED_MEDIA_LOG(level, media_log, count, max) \ |
| 171 LAZY_STREAM(MEDIA_LOG(level, media_log), \ | 174 LAZY_STREAM(MEDIA_LOG(level, media_log), \ |
| 172 (count) < (max) && ((count)++ || true)) \ | 175 (count) < (max) && ((count)++ || true)) \ |
| 173 << (((count) == (max)) ? "(Log limit reached. Further similar entries " \ | 176 << (((count) == (max)) ? "(Log limit reached. Further similar entries " \ |
| 174 "may be suppressed): " \ | 177 "may be suppressed): " \ |
| 175 : "") | 178 : "") |
| 176 | 179 |
| 177 } // namespace media | 180 } // namespace media |
| 178 | 181 |
| 179 #endif // MEDIA_BASE_MEDIA_LOG_H_ | 182 #endif // MEDIA_BASE_MEDIA_LOG_H_ |
| OLD | NEW |