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

Unified Diff: net/base/network_change_notifier_linux.cc

Issue 10151009: Disallow UI/IO thread blocking on any other thread. (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: Created 8 years, 8 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 | « net/base/file_stream_win.cc ('k') | net/disk_cache/backend_impl.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: net/base/network_change_notifier_linux.cc
===================================================================
--- net/base/network_change_notifier_linux.cc (revision 133458)
+++ net/base/network_change_notifier_linux.cc (working copy)
@@ -24,6 +24,7 @@
#include "base/synchronization/waitable_event.h"
#include "base/threading/platform_thread.h"
#include "base/threading/thread.h"
+#include "base/threading/thread_restrictions.h"
#include "dbus/bus.h"
#include "dbus/message.h"
#include "dbus/object_proxy.h"
@@ -63,6 +64,30 @@
NM_STATE_CONNECTED_GLOBAL = 70
};
+class DNSWatchDelegate : public FilePathWatcher::Delegate {
+ public:
+ explicit DNSWatchDelegate(const base::Closure& callback)
+ : callback_(callback) {}
+ virtual ~DNSWatchDelegate() {}
+ // FilePathWatcher::Delegate interface
+ virtual void OnFilePathChanged(const FilePath& path) OVERRIDE;
+ virtual void OnFilePathError(const FilePath& path) OVERRIDE;
+ private:
+ base::Closure callback_;
+ DISALLOW_COPY_AND_ASSIGN(DNSWatchDelegate);
+};
+
+void DNSWatchDelegate::OnFilePathChanged(const FilePath& path) {
+ // Calls NetworkChangeNotifier::NotifyObserversOfDNSChange().
+ callback_.Run();
+}
+
+void DNSWatchDelegate::OnFilePathError(const FilePath& path) {
+ LOG(ERROR) << "DNSWatchDelegate::OnFilePathError for " << path.value();
+}
+
+} // namespace
+
// A wrapper around NetworkManager's D-Bus API.
class NetworkManagerApi {
public:
@@ -232,35 +257,13 @@
}
bool NetworkManagerApi::IsCurrentlyOffline() {
+ // http://crbug.com/125097
+ base::ThreadRestrictions::ScopedAllowWait allow_wait;
offline_state_initialized_.Wait();
base::AutoLock lock(is_offline_lock_);
return is_offline_;
}
-class DNSWatchDelegate : public FilePathWatcher::Delegate {
- public:
- explicit DNSWatchDelegate(const base::Closure& callback)
- : callback_(callback) {}
- virtual ~DNSWatchDelegate() {}
- // FilePathWatcher::Delegate interface
- virtual void OnFilePathChanged(const FilePath& path) OVERRIDE;
- virtual void OnFilePathError(const FilePath& path) OVERRIDE;
- private:
- base::Closure callback_;
- DISALLOW_COPY_AND_ASSIGN(DNSWatchDelegate);
-};
-
-void DNSWatchDelegate::OnFilePathChanged(const FilePath& path) {
- // Calls NetworkChangeNotifier::NotifyObserversOfDNSChange().
- callback_.Run();
-}
-
-void DNSWatchDelegate::OnFilePathError(const FilePath& path) {
- LOG(ERROR) << "DNSWatchDelegate::OnFilePathError for " << path.value();
-}
-
-} // namespace
-
class NetworkChangeNotifierLinux::Thread
: public base::Thread, public MessageLoopForIO::Watcher {
public:
« no previous file with comments | « net/base/file_stream_win.cc ('k') | net/disk_cache/backend_impl.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698