| Index: base/win/object_watcher.cc
|
| diff --git a/base/win/object_watcher.cc b/base/win/object_watcher.cc
|
| index 5ebe1856d3182aec93dd97e08f712f761d5bbbf9..bd9efbf799fd72fecc8d00e6afa9890a98fc0da0 100644
|
| --- a/base/win/object_watcher.cc
|
| +++ b/base/win/object_watcher.cc
|
| @@ -16,6 +16,7 @@ ObjectWatcher::ObjectWatcher()
|
| : object_(NULL),
|
| wait_object_(NULL),
|
| origin_loop_(NULL),
|
| + wait_many_(false),
|
| weak_factory_(this) {
|
| }
|
|
|
| @@ -23,16 +24,20 @@ ObjectWatcher::~ObjectWatcher() {
|
| StopWatching();
|
| }
|
|
|
| -bool ObjectWatcher::StartWatching(HANDLE object, Delegate* delegate) {
|
| +bool ObjectWatcher::StartWatching(HANDLE object, Delegate* delegate,
|
| + bool wait_many) {
|
| CHECK(delegate);
|
| if (wait_object_) {
|
| NOTREACHED() << "Already watching an object";
|
| return false;
|
| }
|
| + wait_many_ = wait_many;
|
|
|
| // Since our job is to just notice when an object is signaled and report the
|
| // result back to this thread, we can just run on a Windows wait thread.
|
| - DWORD wait_flags = WT_EXECUTEINWAITTHREAD | WT_EXECUTEONLYONCE;
|
| + DWORD wait_flags = WT_EXECUTEINWAITTHREAD;
|
| + if (!wait_many_)
|
| + wait_flags |= WT_EXECUTEONLYONCE;
|
|
|
| // DoneWaiting can be synchronously called from RegisterWaitForSingleObject,
|
| // so set up all state now.
|
| @@ -93,7 +98,8 @@ void CALLBACK ObjectWatcher::DoneWaiting(void* param, BOOLEAN timed_out) {
|
| // that is always a pointer to a valid ObjectWater.
|
| ObjectWatcher* that = static_cast<ObjectWatcher*>(param);
|
| that->origin_loop_->task_runner()->PostTask(FROM_HERE, that->callback_);
|
| - that->callback_.Reset();
|
| + if (!that->wait_many_)
|
| + that->callback_.Reset();
|
| }
|
|
|
| void ObjectWatcher::Signal(Delegate* delegate) {
|
| @@ -101,7 +107,8 @@ void ObjectWatcher::Signal(Delegate* delegate) {
|
| // StartWatching(). As a result, we save any state we need and clear previous
|
| // watcher state before signaling the delegate.
|
| HANDLE object = object_;
|
| - StopWatching();
|
| + if (!wait_many_)
|
| + StopWatching();
|
| delegate->OnObjectSignaled(object);
|
| }
|
|
|
|
|