summaryrefslogtreecommitdiffstats
path: root/media/base
diff options
context:
space:
mode:
authorscottfr@chromium.org <scottfr@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2011-08-05 00:11:49 +0000
committerscottfr@chromium.org <scottfr@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2011-08-05 00:11:49 +0000
commitdabaf655b51cd1ffb254f8abf79d5551f8dbb178 (patch)
tree474bec664c0815ad0bcd3e0de6b1ece1c5d85b14 /media/base
parentc3d78e06c57fcd18a04110472e2456a513c903ac (diff)
downloadchromium_src-dabaf655b51cd1ffb254f8abf79d5551f8dbb178.zip
chromium_src-dabaf655b51cd1ffb254f8abf79d5551f8dbb178.tar.gz
chromium_src-dabaf655b51cd1ffb254f8abf79d5551f8dbb178.tar.bz2
Plumb media data from renderers up to MediaInternals in the browser process.
BUG=none TEST=manually Review URL: http://codereview.chromium.org/7480032 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@95542 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'media/base')
-rw-r--r--media/base/media_log.cc60
-rw-r--r--media/base/media_log.h50
-rw-r--r--media/base/media_log_event.h39
3 files changed, 149 insertions, 0 deletions
diff --git a/media/base/media_log.cc b/media/base/media_log.cc
new file mode 100644
index 0000000..6bcbcd71
--- /dev/null
+++ b/media/base/media_log.cc
@@ -0,0 +1,60 @@
+// Copyright (c) 2011 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include "media/base/media_log.h"
+
+#include "base/atomic_sequence_num.h"
+#include "base/logging.h"
+
+namespace media {
+
+// A count of all MediaLogs created on this render process.
+// Used to generate unique ids.
+static base::AtomicSequenceNumber media_log_count(base::LINKER_INITIALIZED);
+
+const char* MediaLog::EventTypeToString(MediaLogEvent::Type type) {
+ switch (type) {
+ case MediaLogEvent::CREATING:
+ return "CREATING";
+ case MediaLogEvent::DESTROYING:
+ return "DESTROYING";
+ case MediaLogEvent::LOAD:
+ return "LOAD";
+ case MediaLogEvent::PLAY:
+ return "PLAY";
+ case MediaLogEvent::PAUSE:
+ return "PAUSE";
+ }
+ NOTREACHED();
+ return NULL;
+}
+
+MediaLog::MediaLog() {
+ id_ = media_log_count.GetNext();
+}
+
+MediaLog::~MediaLog() {}
+
+void MediaLog::Load(const std::string& url) {
+ MediaLogEvent* event = CreateEvent(MediaLogEvent::LOAD);
+ event->params.SetString("url", url);
+ AddEvent(event);
+}
+
+void MediaLog::AddEventOfType(MediaLogEvent::Type type) {
+ MediaLogEvent* event = CreateEvent(type);
+ AddEvent(event);
+}
+
+MediaLogEvent* MediaLog::CreateEvent(MediaLogEvent::Type type) {
+ MediaLogEvent* event = new MediaLogEvent;
+ event->id = id_;
+ event->type = type;
+ event->time = base::Time::Now();
+ return event;
+}
+
+void MediaLog::AddEvent(MediaLogEvent* event) {}
+
+} //namespace media
diff --git a/media/base/media_log.h b/media/base/media_log.h
new file mode 100644
index 0000000..fcf0c31
--- /dev/null
+++ b/media/base/media_log.h
@@ -0,0 +1,50 @@
+// Copyright (c) 2011 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#ifndef MEDIA_BASE_MEDIA_LOG_H_
+#define MEDIA_BASE_MEDIA_LOG_H_
+#pragma once
+
+#include "base/memory/ref_counted.h"
+#include "media/base/media_log_event.h"
+
+namespace media {
+
+class MediaLog : public base::RefCountedThreadSafe<MediaLog> {
+ public:
+
+ // Return a string to represent an EventType.
+ static const char* EventTypeToString(MediaLogEvent::Type type);
+
+ MediaLog();
+
+ // Methods called by loggers when events occur. These generate appropriate
+ // event parameters so the caller need not worry about them.
+ void Load(const std::string& url);
+
+ // Add an event to this log. Overriden by inheritors to actually do something
+ // with it.
+ // Takes ownership of |event|.
+ virtual void AddEvent(MediaLogEvent* event);
+
+ // Convenience method for adding an event with no parameters.
+ void AddEventOfType(MediaLogEvent::Type type);
+
+ // Convenience method for filling in common fields of a new event.
+ MediaLogEvent* CreateEvent(MediaLogEvent::Type type);
+
+ protected:
+ friend class base::RefCountedThreadSafe<MediaLog>;
+ virtual ~MediaLog();
+
+ private:
+ // A unique (to this process) id for this MediaLog.
+ int32 id_;
+
+ DISALLOW_COPY_AND_ASSIGN(MediaLog);
+};
+
+} // namespace media
+
+#endif // MEDIA_BASE_MEDIA_LOG_H_
diff --git a/media/base/media_log_event.h b/media/base/media_log_event.h
new file mode 100644
index 0000000..dd1735e
--- /dev/null
+++ b/media/base/media_log_event.h
@@ -0,0 +1,39 @@
+// Copyright (c) 2011 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#ifndef MEDIA_BASE_MEDIA_LOG_EVENT_H_
+#define MEDIA_BASE_MEDIA_LOG_EVENT_H_
+#pragma once
+
+#include "base/time.h"
+#include "base/values.h"
+
+namespace media {
+
+struct MediaLogEvent {
+ enum Type {
+ // A media player is being created or destroyed.
+ // params: none.
+ CREATING,
+ DESTROYING,
+
+ // A media player is loading a resource.
+ // params: "url": <URL of the resource>.
+ LOAD,
+
+ // A media player has been told to play or pause.
+ // params: none.
+ PLAY,
+ PAUSE,
+ };
+
+ int32 id;
+ Type type;
+ base::DictionaryValue params;
+ base::Time time;
+};
+
+} // namespace media
+
+#endif // MEDIA_BASE_MEDIA_LOG_EVENT_H_