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

Side by Side Diff: media/audio/scoped_task_runner_observer.cc

Issue 2024723002: DO NOT COMMIT (will be split in sub-components) - clang-tidy WaitableEvent refactor (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@WEvent_enums
Patch Set: fix presubmits Created 4 years, 6 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 | « media/audio/clockless_audio_sink.cc ('k') | media/audio/virtual_audio_input_stream_unittest.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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 "media/audio/scoped_task_runner_observer.h" 5 #include "media/audio/scoped_task_runner_observer.h"
6 6
7 #include "base/bind.h" 7 #include "base/bind.h"
8 #include "base/synchronization/waitable_event.h" 8 #include "base/synchronization/waitable_event.h"
9 9
10 namespace media { 10 namespace media {
(...skipping 13 matching lines...) Expand all
24 base::WaitableEvent* done) { 24 base::WaitableEvent* done) {
25 // Note: |done| may be NULL. 25 // Note: |done| may be NULL.
26 if (task_runner_->BelongsToCurrentThread()) { 26 if (task_runner_->BelongsToCurrentThread()) {
27 base::MessageLoop* loop = base::MessageLoop::current(); 27 base::MessageLoop* loop = base::MessageLoop::current();
28 if (enable) { 28 if (enable) {
29 loop->AddDestructionObserver(this); 29 loop->AddDestructionObserver(this);
30 } else { 30 } else {
31 loop->RemoveDestructionObserver(this); 31 loop->RemoveDestructionObserver(this);
32 } 32 }
33 } else { 33 } else {
34 base::WaitableEvent event(false, false); 34 base::WaitableEvent event(base::WaitableEvent::ResetPolicy::AUTOMATIC,
35 base::WaitableEvent::InitialState::NOT_SIGNALED);
35 if (task_runner_->PostTask(FROM_HERE, 36 if (task_runner_->PostTask(FROM_HERE,
36 base::Bind(&ScopedTaskRunnerObserver::ObserveLoopDestruction, 37 base::Bind(&ScopedTaskRunnerObserver::ObserveLoopDestruction,
37 base::Unretained(this), enable, &event))) { 38 base::Unretained(this), enable, &event))) {
38 event.Wait(); 39 event.Wait();
39 } else { 40 } else {
40 // The message loop's thread has already terminated, so no need to wait. 41 // The message loop's thread has already terminated, so no need to wait.
41 } 42 }
42 } 43 }
43 44
44 if (done) 45 if (done)
45 done->Signal(); 46 done->Signal();
46 } 47 }
47 48
48 } // namespace media. 49 } // namespace media.
OLDNEW
« no previous file with comments | « media/audio/clockless_audio_sink.cc ('k') | media/audio/virtual_audio_input_stream_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698