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

Side by Side Diff: third_party/WebKit/Source/modules/mediasession/NavigatorMediaSession.cpp

Issue 2401013002: Make MediaSession per frame as an attribute of Navigator (Closed)
Patch Set: split mojo tests Created 4 years, 2 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
(Empty)
1 // Copyright 2016 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4
5 #include "modules/mediasession/NavigatorMediaSession.h"
6
7 #include "bindings/core/v8/ExceptionStatePlaceholder.h"
8 #include "modules/mediasession/MediaSession.h"
9 #include "platform/Supplementable.h"
10
11 namespace blink {
12
13 NavigatorMediaSession::NavigatorMediaSession(Navigator&) {}
14
15 DEFINE_TRACE(NavigatorMediaSession) {
16 visitor->trace(m_session);
17 Supplement<Navigator>::trace(visitor);
18 }
19
20 const char* NavigatorMediaSession::supplementName() {
21 return "NavigatorMediaSession";
22 }
23
24 NavigatorMediaSession& NavigatorMediaSession::from(Navigator& navigator) {
25 NavigatorMediaSession* supplement = static_cast<NavigatorMediaSession*>(
26 Supplement<Navigator>::from(navigator, supplementName()));
27 if (!supplement) {
28 supplement = new NavigatorMediaSession(navigator);
29 provideTo(navigator, supplementName(), supplement);
30 }
31 return *supplement;
32 }
33
34 MediaSession* NavigatorMediaSession::mediaSession(Navigator& navigator) {
35 NavigatorMediaSession& self = NavigatorMediaSession::from(navigator);
36 if (!self.m_session)
37 self.m_session = MediaSession::create();
38 return self.m_session.get();
39 }
40
41 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698