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

Unified Diff: chrome/browser/system_monitor/removable_device_notifications_mac.h

Issue 10919185: Implement RemovableDeviceNotifications for Mac (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: fix threading Created 8 years, 3 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
Index: chrome/browser/system_monitor/removable_device_notifications_mac.h
diff --git a/chrome/browser/system_monitor/removable_device_notifications_mac.h b/chrome/browser/system_monitor/removable_device_notifications_mac.h
new file mode 100644
index 0000000000000000000000000000000000000000..7879767777776d74eed7d3c6387164cabe769912
--- /dev/null
+++ b/chrome/browser/system_monitor/removable_device_notifications_mac.h
@@ -0,0 +1,44 @@
+// 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 CHROME_BROWSER_SYSTEM_MONITOR_REMOVABLE_DEVICE_NOTIFICATIONS_MAC_H_
+#define CHROME_BROWSER_SYSTEM_MONITOR_REMOVABLE_DEVICE_NOTIFICATIONS_MAC_H_
+
+#include <DiskArbitration/DiskArbitration.h>
+#include <map>
+
+#include "base/mac/scoped_cftyperef.h"
+#include "base/memory/weak_ptr.h"
+#include "chrome/browser/system_monitor/disk_info_mac.h"
+
+namespace chrome {
+
+// This class posts notifications to base::SystemMonitor when a new disk
+// is attached, removed, or changed.
+class RemovableDeviceNotificationsMac :
+ public base::SupportsWeakPtr<RemovableDeviceNotificationsMac> {
+ public:
+ RemovableDeviceNotificationsMac();
+ virtual ~RemovableDeviceNotificationsMac();
+
vandebo (ex-Chrome) 2012/09/10 18:45:03 It's not part of the System Monitor interface, but
vandebo (ex-Chrome) 2012/09/11 00:45:50 Would it be hard to do this?
sail 2012/09/11 03:02:00 Done. Oops, sorry I missed this earlier. I added t
+ void UpdateDisk(const DiskInfoMac& info, bool should_remove);
Nico 2012/09/10 07:02:34 nit: enums are more readable than bools
sail 2012/09/10 21:58:43 Done.
+
+ private:
+ static void DiskAppearedCallback(DADiskRef disk, void* context);
+ static void DiskDisappearedCallback(DADiskRef disk, void* context);
+ static void DiskDescriptionChangedCallback(DADiskRef disk,
+ CFArrayRef keys,
+ void *context);
+
+ bool ShouldPostNotificationForDisk(const DiskInfoMac& info) const;
+
+ base::mac::ScopedCFTypeRef<DASessionRef> session_;
+ std::map<std::string, DiskInfoMac> disk_info_map_;
vandebo (ex-Chrome) 2012/09/10 18:45:03 nit: document what's in the map, i.e. what is the
vandebo (ex-Chrome) 2012/09/10 18:45:03 Does this track all devices on the system, or just
sail 2012/09/10 21:58:43 Done.
sail 2012/09/10 21:58:43 It tracks all mountable devices. Added a comment a
+
+ DISALLOW_COPY_AND_ASSIGN(RemovableDeviceNotificationsMac);
+};
+
+} // namespace chrome
+
+#endif // CHROME_BROWSER_SYSTEM_MONITOR_REMOVABLE_DEVICE_NOTIFICATIONS_MAC_H_

Powered by Google App Engine
This is Rietveld 408576698