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

Side by Side Diff: third_party/WebKit/Source/modules/audio_output_devices/AudioOutputDeviceClient.cpp

Issue 2397173002: Check for valid context in AudioOutputDeviceClient::from. (Closed)
Patch Set: 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
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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/audio_output_devices/AudioOutputDeviceClient.h" 5 #include "modules/audio_output_devices/AudioOutputDeviceClient.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 10
11 namespace blink { 11 namespace blink {
12 12
13 const char* AudioOutputDeviceClient::supplementName() { 13 const char* AudioOutputDeviceClient::supplementName() {
14 return "AudioOutputDeviceClient"; 14 return "AudioOutputDeviceClient";
15 } 15 }
16 16
17 AudioOutputDeviceClient* AudioOutputDeviceClient::from( 17 AudioOutputDeviceClient* AudioOutputDeviceClient::from(
18 ExecutionContext* context) { 18 ExecutionContext* context) {
19 if (!context->isDocument()) 19 if (!context || !context->isDocument())
20 return nullptr; 20 return nullptr;
21 21
22 const Document* document = toDocument(context); 22 const Document* document = toDocument(context);
23 if (!document->frame()) 23 if (!document->frame())
24 return nullptr; 24 return nullptr;
25 25
26 return static_cast<AudioOutputDeviceClient*>( 26 return static_cast<AudioOutputDeviceClient*>(
27 Supplement<LocalFrame>::from(document->frame(), supplementName())); 27 Supplement<LocalFrame>::from(document->frame(), supplementName()));
28 } 28 }
29 29
30 void provideAudioOutputDeviceClientTo(LocalFrame& frame, 30 void provideAudioOutputDeviceClientTo(LocalFrame& frame,
31 AudioOutputDeviceClient* client) { 31 AudioOutputDeviceClient* client) {
32 frame.provideSupplement(AudioOutputDeviceClient::supplementName(), client); 32 frame.provideSupplement(AudioOutputDeviceClient::supplementName(), client);
33 } 33 }
34 34
35 DEFINE_TRACE(AudioOutputDeviceClient) { 35 DEFINE_TRACE(AudioOutputDeviceClient) {
36 Supplement<LocalFrame>::trace(visitor); 36 Supplement<LocalFrame>::trace(visitor);
37 } 37 }
38 38
39 } // namespace blink 39 } // namespace blink
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698