summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--base/message_loop.cc6
-rw-r--r--base/message_loop.h7
-rw-r--r--chrome/browser/chromeos/audio_mixer_alsa.cc7
-rw-r--r--chrome/browser/chromeos/audio_mixer_pulse.cc3
4 files changed, 17 insertions, 6 deletions
diff --git a/base/message_loop.cc b/base/message_loop.cc
index 518a0fd..d83adcc 100644
--- a/base/message_loop.cc
+++ b/base/message_loop.cc
@@ -286,6 +286,12 @@ void MessageLoop::RemoveTaskObserver(TaskObserver* task_observer) {
task_observers_.RemoveObserver(task_observer);
}
+void MessageLoop::AssertIdle() const {
+ // We only check |incoming_queue_|, since we don't want to lock |work_queue_|.
+ base::AutoLock lock(incoming_queue_lock_);
+ DCHECK(incoming_queue_.empty());
+}
+
//------------------------------------------------------------------------------
// Runs the loop in two different SEH modes:
diff --git a/base/message_loop.h b/base/message_loop.h
index 7a3af6e..d238997 100644
--- a/base/message_loop.h
+++ b/base/message_loop.h
@@ -315,6 +315,9 @@ class MessageLoop : public base::MessagePump::Delegate {
// for at least 1s.
static const int kHighResolutionTimerModeLeaseTimeMs = 1000;
+ // Asserts that the MessageLoop is "idle".
+ void AssertIdle() const;
+
//----------------------------------------------------------------------------
protected:
struct RunState {
@@ -461,12 +464,12 @@ class MessageLoop : public base::MessagePump::Delegate {
scoped_refptr<base::Histogram> message_histogram_;
// A null terminated list which creates an incoming_queue of tasks that are
- // aquired under a mutex for processing on this instance's thread. These tasks
+ // acquired under a mutex for processing on this instance's thread. These tasks
// have not yet been sorted out into items for our work_queue_ vs items that
// will be handled by the TimerManager.
TaskQueue incoming_queue_;
// Protect access to incoming_queue_.
- base::Lock incoming_queue_lock_;
+ mutable base::Lock incoming_queue_lock_;
RunState* state_;
diff --git a/chrome/browser/chromeos/audio_mixer_alsa.cc b/chrome/browser/chromeos/audio_mixer_alsa.cc
index a42868e..bb1c1df 100644
--- a/chrome/browser/chromeos/audio_mixer_alsa.cc
+++ b/chrome/browser/chromeos/audio_mixer_alsa.cc
@@ -7,6 +7,7 @@
#include <alsa/asoundlib.h>
#include "base/logging.h"
+#include "base/message_loop.h"
#include "base/task.h"
#include "base/threading/thread_restrictions.h"
#include "chrome/browser/browser_process.h"
@@ -28,8 +29,8 @@ typedef long alsa_long_t; // 'long' is required for ALSA API calls.
namespace {
-const char* kMasterVolume = "Master";
-const char* kPCMVolume = "PCM";
+const char kMasterVolume[] = "Master";
+const char kPCMVolume[] = "PCM";
const double kDefaultMinVolume = -90.0;
const double kDefaultMaxVolume = 0.0;
const double kPrefVolumeInvalid = -999.0;
@@ -56,6 +57,7 @@ AudioMixerAlsa::~AudioMixerAlsa() {
// The worker thread should be idle at this time.
// See http://crosbug.com/11110 for discussion.
base::ThreadRestrictions::ScopedAllowIO allow_io_for_thread_join;
+ thread_->message_loop()->AssertIdle();
thread_->Stop();
thread_.reset();
@@ -444,4 +446,3 @@ void AudioMixerAlsa::SetElementMuted_Locked(snd_mixer_elem_t* elem, bool mute) {
}
} // namespace chromeos
-
diff --git a/chrome/browser/chromeos/audio_mixer_pulse.cc b/chrome/browser/chromeos/audio_mixer_pulse.cc
index 42b268a..b5817bc9 100644
--- a/chrome/browser/chromeos/audio_mixer_pulse.cc
+++ b/chrome/browser/chromeos/audio_mixer_pulse.cc
@@ -7,6 +7,7 @@
#include <pulse/pulseaudio.h>
#include "base/logging.h"
+#include "base/message_loop.h"
#include "base/task.h"
#include "base/threading/thread_restrictions.h"
@@ -64,6 +65,7 @@ AudioMixerPulse::~AudioMixerPulse() {
// The worker thread should be idle at this time.
// See http://crosbug.com/11110 for discussion.
base::ThreadRestrictions::ScopedAllowIO allow_io_for_thread_join;
+ thread_->message_loop()->AssertIdle();
thread_->Stop();
thread_.reset();
@@ -468,4 +470,3 @@ inline bool AudioMixerPulse::MainloopLockIfReady() const {
}
} // namespace chromeos
-