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

Unified Diff: net/dns/notify_watcher_mac.h

Issue 9969190: [net/dns] Watch configd notifications to detect DnsConfig changes on Mac. (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: Fixed missing ':'. 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/dns/file_path_watcher_wrapper.h ('k') | net/dns/notify_watcher_mac.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: net/dns/notify_watcher_mac.h
diff --git a/net/dns/notify_watcher_mac.h b/net/dns/notify_watcher_mac.h
new file mode 100644
index 0000000000000000000000000000000000000000..57562bdfecfd1347ee2cad9f0f54b3b7d9226d5f
--- /dev/null
+++ b/net/dns/notify_watcher_mac.h
@@ -0,0 +1,48 @@
+// Copyright (c) 2012 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.
+
+#ifndef NET_DNS_NOTIFY_WATCHER_MAC_H_
+#define NET_DNS_NOTIFY_WATCHER_MAC_H_
+#pragma once
+
+#include "base/callback.h"
+#include "base/message_loop.h"
+
+namespace net {
+
+// Watches for notifications from Libnotify and delivers them to a Callback.
+// After failure the watch is cancelled and will have to be restarted.
+class NotifyWatcherMac : public MessageLoopForIO::Watcher {
+ public:
+ // Called on received notification with true on success and false on error.
+ typedef base::Callback<void(bool succeeded)> CallbackType;
+
+ NotifyWatcherMac();
+
+ // When deleted, automatically cancels.
+ virtual ~NotifyWatcherMac();
+
+ // Registers for notifications for |key|. Returns true if succeeds. If so,
+ // will deliver asynchronous notifications and errors to |callback|.
+ bool Watch(const char* key, const CallbackType& callback);
+
+ // Cancels the watch.
+ void Cancel();
+
+ private:
+ // MessageLoopForIO::Watcher:
+ virtual void OnFileCanReadWithoutBlocking(int fd) OVERRIDE;
+ virtual void OnFileCanWriteWithoutBlocking(int fd) OVERRIDE {}
+
+ int notify_fd_;
+ int notify_token_;
+ CallbackType callback_;
+ MessageLoopForIO::FileDescriptorWatcher watcher_;
+
+ DISALLOW_COPY_AND_ASSIGN(NotifyWatcherMac);
+};
+
+} // namespace net
+
+#endif // NET_DNS_NOTIFY_WATCHER_MAC_H_
« no previous file with comments | « net/dns/file_path_watcher_wrapper.h ('k') | net/dns/notify_watcher_mac.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698