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

Side by Side Diff: third_party/WebKit/Source/modules/mediastream/NavigatorUserMedia.cpp

Issue 2646383002: Use a new Supplement constructor for (Worker)Navigator supplements (Closed)
Patch Set: temp 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 #include "modules/mediastream/NavigatorUserMedia.h" 5 #include "modules/mediastream/NavigatorUserMedia.h"
6 6
7 #include "core/dom/Document.h" 7 #include "core/dom/Document.h"
8 #include "core/dom/ExecutionContext.h" 8 #include "core/dom/ExecutionContext.h"
9 #include "core/frame/LocalFrame.h" 9 #include "core/frame/LocalFrame.h"
10 #include "core/frame/Navigator.h" 10 #include "core/frame/Navigator.h"
11 #include "modules/mediastream/MediaDevices.h" 11 #include "modules/mediastream/MediaDevices.h"
12 12
13 namespace blink { 13 namespace blink {
14 14
15 NavigatorUserMedia::NavigatorUserMedia(ExecutionContext* context) 15 NavigatorUserMedia::NavigatorUserMedia(Navigator& navigator)
16 : m_mediaDevices(MediaDevices::create(context)) {} 16 : Supplement<Navigator>(navigator),
17 m_mediaDevices(MediaDevices::create(
18 navigator.frame() ? navigator.frame()->document() : nullptr)) {}
17 19
18 const char* NavigatorUserMedia::supplementName() { 20 const char* NavigatorUserMedia::supplementName() {
19 return "NavigatorUserMedia"; 21 return "NavigatorUserMedia";
20 } 22 }
21 23
22 NavigatorUserMedia& NavigatorUserMedia::from(Navigator& navigator) { 24 NavigatorUserMedia& NavigatorUserMedia::from(Navigator& navigator) {
23 NavigatorUserMedia* supplement = static_cast<NavigatorUserMedia*>( 25 NavigatorUserMedia* supplement = static_cast<NavigatorUserMedia*>(
24 Supplement<Navigator>::from(navigator, supplementName())); 26 Supplement<Navigator>::from(navigator, supplementName()));
25 if (!supplement) { 27 if (!supplement) {
26 ExecutionContext* context = 28 supplement = new NavigatorUserMedia(navigator);
27 navigator.frame() ? navigator.frame()->document() : nullptr;
28 supplement = new NavigatorUserMedia(context);
29 provideTo(navigator, supplementName(), supplement); 29 provideTo(navigator, supplementName(), supplement);
30 } 30 }
31 return *supplement; 31 return *supplement;
32 } 32 }
33 33
34 MediaDevices* NavigatorUserMedia::getMediaDevices() { 34 MediaDevices* NavigatorUserMedia::getMediaDevices() {
35 return m_mediaDevices; 35 return m_mediaDevices;
36 } 36 }
37 37
38 MediaDevices* NavigatorUserMedia::mediaDevices(Navigator& navigator) { 38 MediaDevices* NavigatorUserMedia::mediaDevices(Navigator& navigator) {
39 return NavigatorUserMedia::from(navigator).getMediaDevices(); 39 return NavigatorUserMedia::from(navigator).getMediaDevices();
40 } 40 }
41 41
42 DEFINE_TRACE(NavigatorUserMedia) { 42 DEFINE_TRACE(NavigatorUserMedia) {
43 visitor->trace(m_mediaDevices); 43 visitor->trace(m_mediaDevices);
44 Supplement<Navigator>::trace(visitor); 44 Supplement<Navigator>::trace(visitor);
45 } 45 }
46 46
47 } // namespace blink 47 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698