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

Unified Diff: third_party/WebKit/Source/modules/mediasession/MediaMetadata.h

Issue 2584703002: Media Session API: make MediaMetadata mutable. (Closed)
Patch Set: review comments and tests Created 4 years 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 side-by-side diff with in-line comments
Download patch
Index: third_party/WebKit/Source/modules/mediasession/MediaMetadata.h
diff --git a/third_party/WebKit/Source/modules/mediasession/MediaMetadata.h b/third_party/WebKit/Source/modules/mediasession/MediaMetadata.h
index 00927feac1af369fe1ea7afb6ab41c1f0fa3d389..bd013cfb54060ab05a31ba4e5cafd657b313c8de 100644
--- a/third_party/WebKit/Source/modules/mediasession/MediaMetadata.h
+++ b/third_party/WebKit/Source/modules/mediasession/MediaMetadata.h
@@ -7,6 +7,7 @@
#include "bindings/core/v8/ScriptWrappable.h"
#include "modules/ModulesExport.h"
+#include "platform/Timer.h"
#include "platform/heap/Handle.h"
#include "wtf/text/WTFString.h"
@@ -15,8 +16,14 @@ namespace blink {
class ExecutionContext;
class MediaImage;
class MediaMetadataInit;
+class MediaSession;
// Implementation of MediaMetadata interface from the Media Session API.
+// The MediaMetadata object is linked to a MediaSession that owns it. When one
+// of its properties are updated, the object will notify its MediaSession if
+// any. The notification will be made asynchronously in order to combine changes
+// made inside the same event loop. When a MediaMetadata is created and assigned
+// to a MediaSession, the MediaSession will automatically update.
class MODULES_EXPORT MediaMetadata final
: public GarbageCollectedFinalized<MediaMetadata>,
public ScriptWrappable {
@@ -30,15 +37,35 @@ class MODULES_EXPORT MediaMetadata final
String album() const;
const HeapVector<Member<MediaImage>>& artwork() const;
+ void setTitle(const String&);
+ void setArtist(const String&);
+ void setAlbum(const String&);
+ void setArtwork(const HeapVector<Member<MediaImage>>&);
+
+ // Called by MediaSession to associate or de-associate itself.
+ void setSession(MediaSession*);
+
DECLARE_VIRTUAL_TRACE();
private:
MediaMetadata(ExecutionContext*, const MediaMetadataInit&);
+ // Called when one of the metadata fields is updated from script. It will
+ // notify the session asynchronously in order to bundle multiple call in one
+ // notification.
+ void notifySessionAsync();
+
+ // Called asynchronously after at least one field of MediaMetadata has been
+ // modified.
+ void notifySessionTimerFired(TimerBase*);
+
String m_title;
String m_artist;
String m_album;
HeapVector<Member<MediaImage>> m_artwork;
+
+ Member<MediaSession> m_session;
+ Timer<MediaMetadata> m_notifySessionTimer;
};
} // namespace blink

Powered by Google App Engine
This is Rietveld 408576698