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

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

Issue 1906423005: Replace scoped_ptr with std::unique_ptr in //media/base. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: scopedptr-media-base: android Created 4 years, 7 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/media_keys.h ('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 <sstream> 12 #include <sstream>
12 #include <string> 13 #include <string>
13 14
14 #include "base/logging.h" 15 #include "base/logging.h"
15 #include "base/macros.h" 16 #include "base/macros.h"
16 #include "base/memory/ref_counted.h" 17 #include "base/memory/ref_counted.h"
17 #include "base/memory/scoped_ptr.h"
18 #include "media/base/media_export.h" 18 #include "media/base/media_export.h"
19 #include "media/base/media_log_event.h" 19 #include "media/base/media_log_event.h"
20 #include "media/base/pipeline_impl.h" 20 #include "media/base/pipeline_impl.h"
21 #include "media/base/pipeline_status.h" 21 #include "media/base/pipeline_status.h"
22 22
23 namespace media { 23 namespace media {
24 24
25 class MEDIA_EXPORT MediaLog : public base::RefCountedThreadSafe<MediaLog> { 25 class MEDIA_EXPORT MediaLog : public base::RefCountedThreadSafe<MediaLog> {
26 public: 26 public:
27 enum MediaLogLevel { 27 enum MediaLogLevel {
28 MEDIALOG_ERROR, 28 MEDIALOG_ERROR,
29 MEDIALOG_INFO, 29 MEDIALOG_INFO,
30 MEDIALOG_DEBUG, 30 MEDIALOG_DEBUG,
31 }; 31 };
32 32
33 // Convert various enums to strings. 33 // Convert various enums to strings.
34 static std::string MediaLogLevelToString(MediaLogLevel level); 34 static std::string MediaLogLevelToString(MediaLogLevel level);
35 static MediaLogEvent::Type MediaLogLevelToEventType(MediaLogLevel level); 35 static MediaLogEvent::Type MediaLogLevelToEventType(MediaLogLevel level);
36 static std::string EventTypeToString(MediaLogEvent::Type type); 36 static std::string EventTypeToString(MediaLogEvent::Type type);
37 static std::string PipelineStatusToString(PipelineStatus status); 37 static std::string PipelineStatusToString(PipelineStatus status);
38 38
39 static std::string MediaEventToLogString(const MediaLogEvent& event); 39 static std::string MediaEventToLogString(const MediaLogEvent& event);
40 40
41 MediaLog(); 41 MediaLog();
42 42
43 // Add an event to this log. Overriden by inheritors to actually do something 43 // Add an event to this log. Overriden by inheritors to actually do something
44 // with it. 44 // with it.
45 virtual void AddEvent(scoped_ptr<MediaLogEvent> event); 45 virtual void AddEvent(std::unique_ptr<MediaLogEvent> event);
46 46
47 // Retrieve an error message, if any. 47 // Retrieve an error message, if any.
48 virtual std::string GetLastErrorMessage(); 48 virtual std::string GetLastErrorMessage();
49 49
50 // Helper methods to create events and their parameters. 50 // Helper methods to create events and their parameters.
51 scoped_ptr<MediaLogEvent> CreateEvent(MediaLogEvent::Type type); 51 std::unique_ptr<MediaLogEvent> CreateEvent(MediaLogEvent::Type type);
52 scoped_ptr<MediaLogEvent> CreateBooleanEvent( 52 std::unique_ptr<MediaLogEvent> CreateBooleanEvent(MediaLogEvent::Type type,
53 MediaLogEvent::Type type, const std::string& property, bool value); 53 const std::string& property,
54 scoped_ptr<MediaLogEvent> CreateStringEvent(MediaLogEvent::Type type, 54 bool value);
55 const std::string& property, 55 std::unique_ptr<MediaLogEvent> CreateStringEvent(MediaLogEvent::Type type,
56 const std::string& value); 56 const std::string& property,
57 scoped_ptr<MediaLogEvent> CreateTimeEvent(MediaLogEvent::Type type, 57 const std::string& value);
58 const std::string& property, 58 std::unique_ptr<MediaLogEvent> CreateTimeEvent(MediaLogEvent::Type type,
59 base::TimeDelta value); 59 const std::string& property,
60 scoped_ptr<MediaLogEvent> CreateLoadEvent(const std::string& url); 60 base::TimeDelta value);
61 scoped_ptr<MediaLogEvent> CreateSeekEvent(float seconds); 61 std::unique_ptr<MediaLogEvent> CreateLoadEvent(const std::string& url);
62 scoped_ptr<MediaLogEvent> CreatePipelineStateChangedEvent( 62 std::unique_ptr<MediaLogEvent> CreateSeekEvent(float seconds);
63 std::unique_ptr<MediaLogEvent> CreatePipelineStateChangedEvent(
63 PipelineImpl::State state); 64 PipelineImpl::State state);
64 scoped_ptr<MediaLogEvent> CreatePipelineErrorEvent(PipelineStatus error); 65 std::unique_ptr<MediaLogEvent> CreatePipelineErrorEvent(PipelineStatus error);
65 scoped_ptr<MediaLogEvent> CreateVideoSizeSetEvent( 66 std::unique_ptr<MediaLogEvent> CreateVideoSizeSetEvent(size_t width,
66 size_t width, size_t height); 67 size_t height);
67 scoped_ptr<MediaLogEvent> CreateBufferedExtentsChangedEvent(int64_t start, 68 std::unique_ptr<MediaLogEvent> CreateBufferedExtentsChangedEvent(
68 int64_t current, 69 int64_t start,
69 int64_t end); 70 int64_t current,
71 int64_t end);
70 72
71 // Report a log message at the specified log level. 73 // Report a log message at the specified log level.
72 void AddLogEvent(MediaLogLevel level, const std::string& message); 74 void AddLogEvent(MediaLogLevel level, const std::string& message);
73 75
74 // Report a property change without an accompanying event. 76 // Report a property change without an accompanying event.
75 void SetStringProperty(const std::string& key, const std::string& value); 77 void SetStringProperty(const std::string& key, const std::string& value);
76 void SetDoubleProperty(const std::string& key, double value); 78 void SetDoubleProperty(const std::string& key, double value);
77 void SetBooleanProperty(const std::string& key, bool value); 79 void SetBooleanProperty(const std::string& key, bool value);
78 80
79 protected: 81 protected:
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after
123 #define LIMITED_MEDIA_LOG(level, media_log, count, max) \ 125 #define LIMITED_MEDIA_LOG(level, media_log, count, max) \
124 LAZY_STREAM(MEDIA_LOG(level, media_log), \ 126 LAZY_STREAM(MEDIA_LOG(level, media_log), \
125 (count) < (max) && ((count)++ || true)) \ 127 (count) < (max) && ((count)++ || true)) \
126 << (((count) == (max)) ? "(Log limit reached. Further similar entries " \ 128 << (((count) == (max)) ? "(Log limit reached. Further similar entries " \
127 "may be suppressed): " \ 129 "may be suppressed): " \
128 : "") 130 : "")
129 131
130 } // namespace media 132 } // namespace media
131 133
132 #endif // MEDIA_BASE_MEDIA_LOG_H_ 134 #endif // MEDIA_BASE_MEDIA_LOG_H_
OLDNEW
« no previous file with comments | « media/base/media_keys.h ('k') | media/base/media_log.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698