Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(98)

Side by Side Diff: media/base/media_log.h

Issue 2815303006: Convert MediaLog from being ref counted to owned by WebMediaPlayer. (Closed)
Patch Set: Rebase. Created 3 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « media/base/demuxer_perftest.cc ('k') | media/base/media_log.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 <memory> 11 #include <memory>
12 #include <sstream> 12 #include <sstream>
13 #include <string> 13 #include <string>
14 14
15 #include "base/containers/flat_set.h" 15 #include "base/containers/flat_set.h"
16 #include "base/logging.h" 16 #include "base/logging.h"
17 #include "base/macros.h" 17 #include "base/macros.h"
18 #include "base/memory/ref_counted.h"
19 #include "media/base/buffering_state.h" 18 #include "media/base/buffering_state.h"
20 #include "media/base/media_export.h" 19 #include "media/base/media_export.h"
21 #include "media/base/media_log_event.h" 20 #include "media/base/media_log_event.h"
22 #include "media/base/pipeline_impl.h" 21 #include "media/base/pipeline_impl.h"
23 #include "media/base/pipeline_status.h" 22 #include "media/base/pipeline_status.h"
24 #include "url/gurl.h" 23 #include "url/gurl.h"
25 24
26 namespace media { 25 namespace media {
27 26
28 class MEDIA_EXPORT MediaLog : public base::RefCountedThreadSafe<MediaLog> { 27 class MEDIA_EXPORT MediaLog {
29 public: 28 public:
30 enum MediaLogLevel { 29 enum MediaLogLevel {
31 MEDIALOG_ERROR, 30 MEDIALOG_ERROR,
32 MEDIALOG_INFO, 31 MEDIALOG_INFO,
33 MEDIALOG_DEBUG, 32 MEDIALOG_DEBUG,
34 }; 33 };
35 34
36 // Convert various enums to strings. 35 // Convert various enums to strings.
37 static std::string MediaLogLevelToString(MediaLogLevel level); 36 static std::string MediaLogLevelToString(MediaLogLevel level);
38 static MediaLogEvent::Type MediaLogLevelToEventType(MediaLogLevel level); 37 static MediaLogEvent::Type MediaLogLevelToEventType(MediaLogLevel level);
39 static std::string EventTypeToString(MediaLogEvent::Type type); 38 static std::string EventTypeToString(MediaLogEvent::Type type);
40 static std::string PipelineStatusToString(PipelineStatus status); 39 static std::string PipelineStatusToString(PipelineStatus status);
41 static std::string BufferingStateToString(BufferingState state); 40 static std::string BufferingStateToString(BufferingState state);
42 41
43 static std::string MediaEventToLogString(const MediaLogEvent& event); 42 static std::string MediaEventToLogString(const MediaLogEvent& event);
44 43
45 MediaLog(); 44 MediaLog();
45 virtual ~MediaLog();
46 46
47 // Add an event to this log. Overriden by inheritors to actually do something 47 // Add an event to this log. Overriden by inheritors to actually do something
48 // with it. 48 // with it.
49 virtual void AddEvent(std::unique_ptr<MediaLogEvent> event); 49 virtual void AddEvent(std::unique_ptr<MediaLogEvent> event);
50 50
51 // Retrieve an error message, if any. 51 // Retrieve an error message, if any.
52 virtual std::string GetLastErrorMessage(); 52 virtual std::string GetLastErrorMessage();
53 53
54 // Records the domain and registry of the current frame security origin to a 54 // Records the domain and registry of the current frame security origin to a
55 // Rappor privacy-preserving metric. See: 55 // Rappor privacy-preserving metric. See:
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after
116 static const char kWatchTimeAudioVideoBackgroundAc[]; 116 static const char kWatchTimeAudioVideoBackgroundAc[];
117 static const char kWatchTimeAudioVideoBackgroundEmbeddedExperience[]; 117 static const char kWatchTimeAudioVideoBackgroundEmbeddedExperience[];
118 118
119 // Markers which signify the watch time should be finalized immediately. 119 // Markers which signify the watch time should be finalized immediately.
120 static const char kWatchTimeFinalize[]; 120 static const char kWatchTimeFinalize[];
121 static const char kWatchTimeFinalizePower[]; 121 static const char kWatchTimeFinalizePower[];
122 122
123 static base::flat_set<base::StringPiece> GetWatchTimeKeys(); 123 static base::flat_set<base::StringPiece> GetWatchTimeKeys();
124 static base::flat_set<base::StringPiece> GetWatchTimePowerKeys(); 124 static base::flat_set<base::StringPiece> GetWatchTimePowerKeys();
125 125
126 protected:
127 friend class base::RefCountedThreadSafe<MediaLog>;
128 virtual ~MediaLog();
129
130 private: 126 private:
131 // A unique (to this process) id for this MediaLog. 127 // A unique (to this process) id for this MediaLog.
132 int32_t id_; 128 int32_t id_;
133 129
134 DISALLOW_COPY_AND_ASSIGN(MediaLog); 130 DISALLOW_COPY_AND_ASSIGN(MediaLog);
135 }; 131 };
136 132
137 // Helper class to make it easier to use MediaLog like DVLOG(). 133 // Helper class to make it easier to use MediaLog like DVLOG().
138 class MEDIA_EXPORT LogHelper { 134 class MEDIA_EXPORT LogHelper {
139 public: 135 public:
140 LogHelper(MediaLog::MediaLogLevel level, 136 LogHelper(MediaLog::MediaLogLevel level, MediaLog* media_log);
141 const scoped_refptr<MediaLog>& media_log);
142 ~LogHelper(); 137 ~LogHelper();
143 138
144 std::ostream& stream() { return stream_; } 139 std::ostream& stream() { return stream_; }
145 140
146 private: 141 private:
147 MediaLog::MediaLogLevel level_; 142 const MediaLog::MediaLogLevel level_;
148 const scoped_refptr<MediaLog> media_log_; 143 MediaLog* const media_log_;
149 std::stringstream stream_; 144 std::stringstream stream_;
150 }; 145 };
151 146
152 // Provides a stringstream to collect a log entry to pass to the provided 147 // Provides a stringstream to collect a log entry to pass to the provided
153 // MediaLog at the requested level. 148 // MediaLog at the requested level.
154 #define MEDIA_LOG(level, media_log) \ 149 #define MEDIA_LOG(level, media_log) \
155 LogHelper((MediaLog::MEDIALOG_##level), (media_log)).stream() 150 LogHelper((MediaLog::MEDIALOG_##level), (media_log)).stream()
156 151
157 // Logs only while |count| < |max|, increments |count| for each log, and warns 152 // Logs only while |count| < |max|, increments |count| for each log, and warns
158 // in the log if |count| has just reached |max|. 153 // in the log if |count| has just reached |max|.
(...skipping 11 matching lines...) Expand all
170 #define LIMITED_MEDIA_LOG(level, media_log, count, max) \ 165 #define LIMITED_MEDIA_LOG(level, media_log, count, max) \
171 LAZY_STREAM(MEDIA_LOG(level, media_log), \ 166 LAZY_STREAM(MEDIA_LOG(level, media_log), \
172 (count) < (max) && ((count)++ || true)) \ 167 (count) < (max) && ((count)++ || true)) \
173 << (((count) == (max)) ? "(Log limit reached. Further similar entries " \ 168 << (((count) == (max)) ? "(Log limit reached. Further similar entries " \
174 "may be suppressed): " \ 169 "may be suppressed): " \
175 : "") 170 : "")
176 171
177 } // namespace media 172 } // namespace media
178 173
179 #endif // MEDIA_BASE_MEDIA_LOG_H_ 174 #endif // MEDIA_BASE_MEDIA_LOG_H_
OLDNEW
« no previous file with comments | « media/base/demuxer_perftest.cc ('k') | media/base/media_log.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698