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

Side by Side Diff: third_party/WebKit/Source/modules/mediasession/MediaMetadata.h

Issue 2612003002: Media Session: use dictionary instead of an interface for MediaImage. (Closed)
Patch Set: apply spec changes and comments Created 3 years, 11 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
OLDNEW
1 // Copyright 2015 The Chromium Authors. All rights reserved. 1 // Copyright 2015 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 MediaMetadata_h 5 #ifndef MediaMetadata_h
6 #define MediaMetadata_h 6 #define MediaMetadata_h
7 7
8 #include "bindings/core/v8/ScriptWrappable.h" 8 #include "bindings/core/v8/ScriptWrappable.h"
9 #include "modules/ModulesExport.h" 9 #include "modules/ModulesExport.h"
10 #include "platform/Timer.h" 10 #include "platform/Timer.h"
11 #include "platform/heap/Handle.h" 11 #include "platform/heap/Handle.h"
12 #include "wtf/text/WTFString.h" 12 #include "wtf/text/WTFString.h"
13 13
14 namespace blink { 14 namespace blink {
15 15
16 class ExecutionContext; 16 class ExceptionState;
17 class MediaImage; 17 class MediaImage;
18 class MediaMetadataInit; 18 class MediaMetadataInit;
19 class MediaSession; 19 class MediaSession;
20 class ScriptState;
20 21
21 // Implementation of MediaMetadata interface from the Media Session API. 22 // Implementation of MediaMetadata interface from the Media Session API.
22 // The MediaMetadata object is linked to a MediaSession that owns it. When one 23 // The MediaMetadata object is linked to a MediaSession that owns it. When one
23 // of its properties are updated, the object will notify its MediaSession if 24 // of its properties are updated, the object will notify its MediaSession if
24 // any. The notification will be made asynchronously in order to combine changes 25 // any. The notification will be made asynchronously in order to combine changes
25 // made inside the same event loop. When a MediaMetadata is created and assigned 26 // made inside the same event loop. When a MediaMetadata is created and assigned
26 // to a MediaSession, the MediaSession will automatically update. 27 // to a MediaSession, the MediaSession will automatically update.
27 class MODULES_EXPORT MediaMetadata final 28 class MODULES_EXPORT MediaMetadata final
28 : public GarbageCollectedFinalized<MediaMetadata>, 29 : public GarbageCollectedFinalized<MediaMetadata>,
29 public ScriptWrappable { 30 public ScriptWrappable {
30 DEFINE_WRAPPERTYPEINFO(); 31 DEFINE_WRAPPERTYPEINFO();
31 32
32 public: 33 public:
33 static MediaMetadata* create(ExecutionContext*, const MediaMetadataInit&); 34 static MediaMetadata* create(ScriptState*,
35 const MediaMetadataInit&,
36 ExceptionState&);
34 37
35 String title() const; 38 String title() const;
36 String artist() const; 39 String artist() const;
37 String album() const; 40 String album() const;
38 const HeapVector<Member<MediaImage>>& artwork() const; 41 Vector<v8::Local<v8::Value>> artwork(ScriptState*) const;
42
43 // Internal use only, returns a reference to m_artwork instead of a Frozen
44 // copy of a MediaImage array.
45 const HeapVector<MediaImage>& artwork() const;
39 46
40 void setTitle(const String&); 47 void setTitle(const String&);
41 void setArtist(const String&); 48 void setArtist(const String&);
42 void setAlbum(const String&); 49 void setAlbum(const String&);
43 void setArtwork(const HeapVector<Member<MediaImage>>&); 50 void setArtwork(ScriptState*, const HeapVector<MediaImage>&, ExceptionState&);
44 51
45 // Called by MediaSession to associate or de-associate itself. 52 // Called by MediaSession to associate or de-associate itself.
46 void setSession(MediaSession*); 53 void setSession(MediaSession*);
47 54
48 DECLARE_VIRTUAL_TRACE(); 55 DECLARE_VIRTUAL_TRACE();
49 56
50 private: 57 private:
51 MediaMetadata(ExecutionContext*, const MediaMetadataInit&); 58 MediaMetadata(ScriptState*, const MediaMetadataInit&, ExceptionState&);
52 59
53 // Called when one of the metadata fields is updated from script. It will 60 // Called when one of the metadata fields is updated from script. It will
54 // notify the session asynchronously in order to bundle multiple call in one 61 // notify the session asynchronously in order to bundle multiple call in one
55 // notification. 62 // notification.
56 void notifySessionAsync(); 63 void notifySessionAsync();
57 64
58 // Called asynchronously after at least one field of MediaMetadata has been 65 // Called asynchronously after at least one field of MediaMetadata has been
59 // modified. 66 // modified.
60 void notifySessionTimerFired(TimerBase*); 67 void notifySessionTimerFired(TimerBase*);
61 68
69 // Make an internal copy of the MediaImage vector with some internal steps
70 // such as parsing of the src property.
71 void setArtworkInternal(ScriptState*,
72 const HeapVector<MediaImage>&,
73 ExceptionState&);
74
62 String m_title; 75 String m_title;
63 String m_artist; 76 String m_artist;
64 String m_album; 77 String m_album;
65 HeapVector<Member<MediaImage>> m_artwork; 78 HeapVector<MediaImage> m_artwork;
66 79
67 Member<MediaSession> m_session; 80 Member<MediaSession> m_session;
68 Timer<MediaMetadata> m_notifySessionTimer; 81 Timer<MediaMetadata> m_notifySessionTimer;
69 }; 82 };
70 83
71 } // namespace blink 84 } // namespace blink
72 85
73 #endif // MediaMetadata_h 86 #endif // MediaMetadata_h
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698