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

Unified Diff: media/midi/midi_manager_android.cc

Issue 2262043002: MidiScheduler binds to task runner of constructing thread (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: rebase Created 4 years, 4 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
« no previous file with comments | « media/midi/midi_manager_android.h ('k') | media/midi/midi_manager_usb.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: media/midi/midi_manager_android.cc
diff --git a/media/midi/midi_manager_android.cc b/media/midi/midi_manager_android.cc
index 54fe91514c903f3f1189be369fa316f017589d3f..25966260b01fd2ec0b16f7691bf89006dbf74ac2 100644
--- a/media/midi/midi_manager_android.cc
+++ b/media/midi/midi_manager_android.cc
@@ -35,7 +35,10 @@ MidiManager* MidiManager::Create() {
MidiManagerAndroid::MidiManagerAndroid() {}
-MidiManagerAndroid::~MidiManagerAndroid() {}
+MidiManagerAndroid::~MidiManagerAndroid() {
+ base::AutoLock auto_lock(scheduler_lock_);
+ CHECK(!scheduler_);
+}
void MidiManagerAndroid::StartInitialization() {
JNIEnv* env = base::android::AttachCurrentThread();
@@ -43,10 +46,21 @@ void MidiManagerAndroid::StartInitialization() {
uintptr_t pointer = reinterpret_cast<uintptr_t>(this);
raw_manager_.Reset(Java_MidiManagerAndroid_create(
env, base::android::GetApplicationContext(), pointer));
- scheduler_.reset(new MidiScheduler(this));
+
+ {
+ base::AutoLock auto_lock(scheduler_lock_);
+ scheduler_.reset(new MidiScheduler(this));
+ }
+
Java_MidiManagerAndroid_initialize(env, raw_manager_);
}
+void MidiManagerAndroid::Finalize() {
+ // Destruct MidiScheduler on Chrome_IOThread.
+ base::AutoLock auto_lock(scheduler_lock_);
+ scheduler_.reset();
+}
+
void MidiManagerAndroid::DispatchSendMidiData(MidiManagerClient* client,
uint32_t port_index,
const std::vector<uint8_t>& data,
« no previous file with comments | « media/midi/midi_manager_android.h ('k') | media/midi/midi_manager_usb.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698