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

Unified Diff: media/audio/mac/audio_device_listener_mac.cc

Issue 12161002: MessageLoop's RUN method will pass a const ref to PendingTask when (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: Created 7 years, 11 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 | « content/renderer/renderer_main.cc ('k') | net/http/http_pipelined_connection_impl_unittest.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: media/audio/mac/audio_device_listener_mac.cc
===================================================================
--- media/audio/mac/audio_device_listener_mac.cc (revision 180270)
+++ media/audio/mac/audio_device_listener_mac.cc (working copy)
@@ -4,12 +4,14 @@
#include "media/audio/mac/audio_device_listener_mac.h"
+#include "base/bind.h"
#include "base/file_path.h"
#include "base/logging.h"
#include "base/mac/libdispatch_task_runner.h"
#include "base/mac/mac_logging.h"
#include "base/mac/mac_util.h"
#include "base/message_loop.h"
+#include "base/pending_task.h"
namespace media {
@@ -27,7 +29,7 @@
// If we're currently on the thread, fire the suspend operation so we don't
// end up with an unbalanced resume.
if (message_loop_->message_loop_proxy()->BelongsToCurrentThread())
- WillProcessTask(base::TimeTicks());
+ SuspendDispatchQueue();
message_loop_->AddTaskObserver(this);
}
@@ -38,26 +40,18 @@
// If we're currently on the thread, fire the resume operation so we don't
// end up with an unbalanced suspend.
if (message_loop_->message_loop_proxy()->BelongsToCurrentThread())
- DidProcessTask(base::TimeTicks());
+ ResumeDispatchQueue();
// This will hang if any listeners are still registered with the queue.
property_listener_queue_->Shutdown();
}
- virtual void WillProcessTask(base::TimeTicks time_posted) OVERRIDE {
- // Issue a synchronous suspend operation. Benchmarks on a retina 10.8.2
- // machine show this takes < 20us on average. dispatch_suspend() is an
- // asynchronous operation so we need to issue it inside of a synchronous
- // block to ensure it completes before WillProccesTask() completes.
- dispatch_sync(queue_, ^{
- dispatch_suspend(queue_);
- });
+ virtual void WillProcessTask(const base::PendingTask& pending_task) OVERRIDE {
+ SuspendDispatchQueue();
}
- virtual void DidProcessTask(base::TimeTicks time_posted) OVERRIDE {
- // Issue an asynchronous resume operation. Benchmarks on a retina 10.8.2
- // machine show this takes < 10us on average.
- dispatch_resume(queue_);
+ virtual void DidProcessTask(const base::PendingTask& pending_task) OVERRIDE {
+ ResumeDispatchQueue();
}
dispatch_queue_t dispatch_queue() const {
@@ -65,6 +59,22 @@
}
private:
+ // Issue a synchronous suspend operation. Benchmarks on a retina 10.8.2
+ // machine show this takes < 20us on average. dispatch_suspend() is an
+ // asynchronous operation so we need to issue it inside of a synchronous block
+ // to ensure it completes before WillProccesTask() completes.
+ void SuspendDispatchQueue() {
+ dispatch_sync(queue_, ^{
+ dispatch_suspend(queue_);
+ });
+ }
+
+ // Issue an asynchronous resume operation. Benchmarks on a retina 10.8.2
+ // machine show this takes < 10us on average.
+ void ResumeDispatchQueue() {
+ dispatch_resume(queue_);
+ }
+
scoped_refptr<base::mac::LibDispatchTaskRunner> property_listener_queue_;
const dispatch_queue_t queue_;
MessageLoop* message_loop_;
« no previous file with comments | « content/renderer/renderer_main.cc ('k') | net/http/http_pipelined_connection_impl_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698