summaryrefslogtreecommitdiffstats
path: root/chrome/common/net/thread_blocker.cc
diff options
context:
space:
mode:
authorpkasting@chromium.org <pkasting@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-06-25 21:30:38 +0000
committerpkasting@chromium.org <pkasting@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-06-25 21:30:38 +0000
commit66761b95332549f825999e482c17c94675275f49 (patch)
treefc5307808a2c62f1eff2a9f37db3aff11c5455d9 /chrome/common/net/thread_blocker.cc
parente313f3b11360902a3da9b3b1cc0df2a4792d0867 (diff)
downloadchromium_src-66761b95332549f825999e482c17c94675275f49.zip
chromium_src-66761b95332549f825999e482c17c94675275f49.tar.gz
chromium_src-66761b95332549f825999e482c17c94675275f49.tar.bz2
Massively simplify the NetworkChangeNotifier infrastructure:
* Use a process-wide object (singleton pattern) * Create/destroy this object on the main thread, make it outlive all consumers * Make observer-related functions threadsafe As a result, the notifier can now be used by any thread (eliminating things like NetworkChangeObserverProxy and NetworkChangeNotifierProxy, and expanding its usefulness); its creation and inner workings are much simplified (eliminating implementation-specific classes); and it is simpler to access (eliminating things like NetworkChangeNotifierThread and a LOT of passing pointers around). BUG=none TEST=Unittests; network changes still trigger notifications Review URL: http://codereview.chromium.org/2802015 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@50895 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/common/net/thread_blocker.cc')
-rw-r--r--chrome/common/net/thread_blocker.cc47
1 files changed, 0 insertions, 47 deletions
diff --git a/chrome/common/net/thread_blocker.cc b/chrome/common/net/thread_blocker.cc
deleted file mode 100644
index 2291d33..0000000
--- a/chrome/common/net/thread_blocker.cc
+++ /dev/null
@@ -1,47 +0,0 @@
-// Copyright (c) 2010 The Chromium Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-#include "chrome/common/net/thread_blocker.h"
-
-#include "base/logging.h"
-#include "base/message_loop.h"
-#include "base/task.h"
-#include "base/thread.h"
-#include "base/waitable_event.h"
-
-// Since a ThreadBlocker is outlived by its target thread, we don't
-// have to ref-count it.
-DISABLE_RUNNABLE_METHOD_REFCOUNT(chrome_common_net::ThreadBlocker);
-
-namespace chrome_common_net {
-
-ThreadBlocker::ThreadBlocker(base::Thread* target_thread)
- : target_message_loop_(target_thread->message_loop()),
- is_blocked_(false, false), is_finished_blocking_(false, false),
- is_unblocked_(false, false) {
- DCHECK(target_message_loop_);
-}
-
-void ThreadBlocker::Block() {
- DCHECK_NE(MessageLoop::current(), target_message_loop_);
- target_message_loop_->PostTask(
- FROM_HERE,
- NewRunnableMethod(this, &ThreadBlocker::BlockOnTargetThread));
- while (!is_blocked_.Wait()) {}
-}
-
-void ThreadBlocker::Unblock() {
- DCHECK_NE(MessageLoop::current(), target_message_loop_);
- is_finished_blocking_.Signal();
- while (!is_unblocked_.Wait()) {}
-}
-
-void ThreadBlocker::BlockOnTargetThread() {
- DCHECK_EQ(MessageLoop::current(), target_message_loop_);
- is_blocked_.Signal();
- while (!is_finished_blocking_.Wait()) {}
- is_unblocked_.Signal();
-}
-
-} // namespace chrome_common_net