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

Side by Side Diff: third_party/WebKit/Source/modules/webaudio/MediaElementAudioSourceNode.h

Issue 2702243003: Disallow cross-thread Persistent<> read access. (Closed)
Patch Set: rebased upto r451733 Created 3 years, 10 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 /* 1 /*
2 * Copyright (C) 2011, Google Inc. All rights reserved. 2 * Copyright (C) 2011, Google Inc. All rights reserved.
3 * 3 *
4 * Redistribution and use in source and binary forms, with or without 4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions 5 * modification, are permitted provided that the following conditions
6 * are met: 6 * are met:
7 * 1. Redistributions of source code must retain the above copyright 7 * 1. Redistributions of source code must retain the above copyright
8 * notice, this list of conditions and the following disclaimer. 8 * notice, this list of conditions and the following disclaimer.
9 * 2. Redistributions in binary form must reproduce the above copyright 9 * 2. Redistributions in binary form must reproduce the above copyright
10 * notice, this list of conditions and the following disclaimer in the 10 * notice, this list of conditions and the following disclaimer in the
(...skipping 27 matching lines...) Expand all
38 class BaseAudioContext; 38 class BaseAudioContext;
39 class HTMLMediaElement; 39 class HTMLMediaElement;
40 class MediaElementAudioSourceOptions; 40 class MediaElementAudioSourceOptions;
41 41
42 class MediaElementAudioSourceHandler final : public AudioHandler { 42 class MediaElementAudioSourceHandler final : public AudioHandler {
43 public: 43 public:
44 static PassRefPtr<MediaElementAudioSourceHandler> create(AudioNode&, 44 static PassRefPtr<MediaElementAudioSourceHandler> create(AudioNode&,
45 HTMLMediaElement&); 45 HTMLMediaElement&);
46 ~MediaElementAudioSourceHandler() override; 46 ~MediaElementAudioSourceHandler() override;
47 47
48 HTMLMediaElement* mediaElement() { return m_mediaElement.get(); } 48 HTMLMediaElement* mediaElement() const;
49 49
50 // AudioHandler 50 // AudioHandler
51 void dispose() override; 51 void dispose() override;
52 void process(size_t framesToProcess) override; 52 void process(size_t framesToProcess) override;
53 53
54 // Helpers for AudioSourceProviderClient implementation of 54 // Helpers for AudioSourceProviderClient implementation of
55 // MediaElementAudioSourceNode. 55 // MediaElementAudioSourceNode.
56 void setFormat(size_t numberOfChannels, float sampleRate); 56 void setFormat(size_t numberOfChannels, float sampleRate);
57 void onCurrentSrcChanged(const KURL& currentSrc); 57 void onCurrentSrcChanged(const KURL& currentSrc);
58 void lock(); 58 void lock();
(...skipping 10 matching lines...) Expand all
69 // Must be called only on the main thread. 69 // Must be called only on the main thread.
70 bool passesCurrentSrcCORSAccessCheck(const KURL& currentSrc); 70 bool passesCurrentSrcCORSAccessCheck(const KURL& currentSrc);
71 71
72 // Print warning if CORS restrictions cause MediaElementAudioSource to output 72 // Print warning if CORS restrictions cause MediaElementAudioSource to output
73 // zeroes. 73 // zeroes.
74 void printCORSMessage(const String& message); 74 void printCORSMessage(const String& message);
75 75
76 // This Persistent doesn't make a reference cycle. The reference from 76 // This Persistent doesn't make a reference cycle. The reference from
77 // HTMLMediaElement to AudioSourceProvideClient, which 77 // HTMLMediaElement to AudioSourceProvideClient, which
78 // MediaElementAudioSourceNode implements, is weak. 78 // MediaElementAudioSourceNode implements, is weak.
79 Persistent<HTMLMediaElement> m_mediaElement; 79 //
80 // It is accessed by both audio and main thread. TODO: we really should
81 // try to minimize or avoid the audio thread touching this element.
82 CrossThreadPersistent<HTMLMediaElement> m_mediaElement;
80 Mutex m_processLock; 83 Mutex m_processLock;
81 84
82 unsigned m_sourceNumberOfChannels; 85 unsigned m_sourceNumberOfChannels;
83 double m_sourceSampleRate; 86 double m_sourceSampleRate;
84 87
85 std::unique_ptr<MultiChannelResampler> m_multiChannelResampler; 88 std::unique_ptr<MultiChannelResampler> m_multiChannelResampler;
86 89
87 // |m_passesCurrentSrcCORSAccessCheck| holds the value of 90 // |m_passesCurrentSrcCORSAccessCheck| holds the value of
88 // context()->getSecurityOrigin() && 91 // context()->getSecurityOrigin() &&
89 // context()->getSecurityOrigin()->canRequest(mediaElement()->currentSrc()), 92 // context()->getSecurityOrigin()->canRequest(mediaElement()->currentSrc()),
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after
126 void lock() override; 129 void lock() override;
127 void unlock() override; 130 void unlock() override;
128 131
129 private: 132 private:
130 MediaElementAudioSourceNode(BaseAudioContext&, HTMLMediaElement&); 133 MediaElementAudioSourceNode(BaseAudioContext&, HTMLMediaElement&);
131 }; 134 };
132 135
133 } // namespace blink 136 } // namespace blink
134 137
135 #endif // MediaElementAudioSourceNode_h 138 #endif // MediaElementAudioSourceNode_h
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698