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

Unified Diff: content/renderer/media/media_stream_source.h

Issue 1834323002: MediaStream audio: Refactor 3 separate "glue" implementations into one. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: REBASE + Workaround to ensure MediaStreamAudioProcessor is destroyed on the main thread. Created 4 years, 7 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 side-by-side diff with in-line comments
Download patch
Index: content/renderer/media/media_stream_source.h
diff --git a/content/renderer/media/media_stream_source.h b/content/renderer/media/media_stream_source.h
index 940efcc30a337da6d9e3957943766fda3b594251..7c451564d6f00bc514153e55c9d700ba29f81c5e 100644
--- a/content/renderer/media/media_stream_source.h
+++ b/content/renderer/media/media_stream_source.h
@@ -9,6 +9,7 @@
#include "base/compiler_specific.h"
#include "base/logging.h"
#include "base/macros.h"
+#include "base/threading/thread_checker.h"
#include "content/common/content_export.h"
#include "content/common/media/media_stream_options.h"
#include "third_party/WebKit/public/platform/WebMediaStreamSource.h"
@@ -43,37 +44,40 @@ class CONTENT_EXPORT MediaStreamSource
return device_info_;
}
- // Stops the source (by calling DoStopSource()). This sets the
- // WebMediaStreamSource::readyState to ended, triggers the |stop_callback_|
- // if set. All pointers to this object are invalid after calling this.
+ // Stops the source (by calling DoStopSource()). This runs the
+ // |stop_callback_| (if set), and then sets the
+ // WebMediaStreamSource::readyState to ended.
void StopSource();
- void ResetSourceStoppedCallback() {
- DCHECK(!stop_callback_.is_null());
- stop_callback_.Reset();
- }
-
- protected:
- // Called when StopSource is called. It allows derived classes to implement
- // its own Stop method.
- virtual void DoStopSource() = 0;
-
// Sets device information about a source that has been created by a
// JavaScript call to GetUserMedia. F.E a camera or microphone.
- void SetDeviceInfo(const StreamDeviceInfo& device_info) {
- device_info_ = device_info;
- }
+ void SetDeviceInfo(const StreamDeviceInfo& device_info);
// Sets a callback that will be triggered when StopSource is called.
- void SetStopCallback(const SourceStoppedCallback& stop_callback) {
- DCHECK(stop_callback_.is_null());
- stop_callback_ = stop_callback;
- }
+ void SetStopCallback(const SourceStoppedCallback& stop_callback);
+
+ // Clears the previously-set SourceStoppedCallback so that it will not be run
+ // in the future.
+ void ResetSourceStoppedCallback();
+
+ protected:
+ // Called when StopSource is called. It allows derived classes to implement
+ // its own Stop method.
+ virtual void DoStopSource() = 0;
private:
+ // Called by both StopSource() and the destructor to ensure the
+ // |stop_callback_| has been run and the blink::WebMediaStreamSource's ready
+ // state has been set to "ended."
+ void RunStopCallbackAndEndStream();
+
StreamDeviceInfo device_info_;
SourceStoppedCallback stop_callback_;
+ // In debug builds, check that all methods are being called on the main
+ // thread.
+ base::ThreadChecker thread_checker_;
+
DISALLOW_COPY_AND_ASSIGN(MediaStreamSource);
};
« no previous file with comments | « content/renderer/media/media_stream_renderer_factory_impl.cc ('k') | content/renderer/media/media_stream_source.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698