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

Side by Side Diff: chrome/browser/system_monitor/removable_device_notifications_mac.h

Issue 10909259: Share MediaStorageUtil common code among platforms. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Try a different way 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 unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #ifndef CHROME_BROWSER_SYSTEM_MONITOR_REMOVABLE_DEVICE_NOTIFICATIONS_MAC_H_ 5 #ifndef CHROME_BROWSER_SYSTEM_MONITOR_REMOVABLE_DEVICE_NOTIFICATIONS_MAC_H_
6 #define CHROME_BROWSER_SYSTEM_MONITOR_REMOVABLE_DEVICE_NOTIFICATIONS_MAC_H_ 6 #define CHROME_BROWSER_SYSTEM_MONITOR_REMOVABLE_DEVICE_NOTIFICATIONS_MAC_H_
7 7
8 #include <DiskArbitration/DiskArbitration.h> 8 #include <DiskArbitration/DiskArbitration.h>
9 #include <map> 9 #include <map>
10 10
11 #include "base/mac/scoped_cftyperef.h" 11 #include "base/mac/scoped_cftyperef.h"
12 #include "base/memory/weak_ptr.h" 12 #include "base/memory/weak_ptr.h"
13 #include "base/system_monitor/system_monitor.h" 13 #include "base/system_monitor/system_monitor.h"
14 #include "chrome/browser/system_monitor/disk_info_mac.h" 14 #include "chrome/browser/system_monitor/disk_info_mac.h"
15 15
16 namespace chrome { 16 namespace chrome {
17 17
18 class RemovableDeviceNotificationsMac;
19 typedef RemovableDeviceNotificationsMac RemovableDeviceNotifications;
20
18 // This class posts notifications to base::SystemMonitor when a new disk 21 // This class posts notifications to base::SystemMonitor when a new disk
19 // is attached, removed, or changed. 22 // is attached, removed, or changed.
20 class RemovableDeviceNotificationsMac : 23 class RemovableDeviceNotificationsMac :
21 public base::SupportsWeakPtr<RemovableDeviceNotificationsMac> { 24 public base::SupportsWeakPtr<RemovableDeviceNotificationsMac> {
22 public: 25 public:
23 enum UpdateType { 26 enum UpdateType {
24 UPDATE_DEVICE_ADDED, 27 UPDATE_DEVICE_ADDED,
25 UPDATE_DEVICE_CHANGED, 28 UPDATE_DEVICE_CHANGED,
26 UPDATE_DEVICE_REMOVED, 29 UPDATE_DEVICE_REMOVED,
27 }; 30 };
28 31
32 // Should only be called by browser start up code. Use GetInstance() instead.
29 RemovableDeviceNotificationsMac(); 33 RemovableDeviceNotificationsMac();
30 virtual ~RemovableDeviceNotificationsMac(); 34 virtual ~RemovableDeviceNotificationsMac();
31 35
36 static RemovableDeviceNotificationsMac* GetInstance();
37
32 void UpdateDisk(const DiskInfoMac& info, UpdateType update_type); 38 void UpdateDisk(const DiskInfoMac& info, UpdateType update_type);
33 39
34 bool GetDeviceInfoForPath( 40 bool GetDeviceInfoForPath(
35 const FilePath& path, 41 const FilePath& path,
36 base::SystemMonitor::RemovableStorageInfo* device_info) const; 42 base::SystemMonitor::RemovableStorageInfo* device_info) const;
37 43
38 private: 44 private:
39 static void DiskAppearedCallback(DADiskRef disk, void* context); 45 static void DiskAppearedCallback(DADiskRef disk, void* context);
40 static void DiskDisappearedCallback(DADiskRef disk, void* context); 46 static void DiskDisappearedCallback(DADiskRef disk, void* context);
41 static void DiskDescriptionChangedCallback(DADiskRef disk, 47 static void DiskDescriptionChangedCallback(DADiskRef disk,
42 CFArrayRef keys, 48 CFArrayRef keys,
43 void *context); 49 void *context);
44 50
45 bool ShouldPostNotificationForDisk(const DiskInfoMac& info) const; 51 bool ShouldPostNotificationForDisk(const DiskInfoMac& info) const;
46 bool FindDiskWithMountPoint(const FilePath& mount_point, 52 bool FindDiskWithMountPoint(const FilePath& mount_point,
47 DiskInfoMac* info) const; 53 DiskInfoMac* info) const;
48 54
49 base::mac::ScopedCFTypeRef<DASessionRef> session_; 55 base::mac::ScopedCFTypeRef<DASessionRef> session_;
50 // Maps disk bsd names to disk info objects. This map tracks all mountable 56 // Maps disk bsd names to disk info objects. This map tracks all mountable
51 // devices on the system though only notifications for removable devices are 57 // devices on the system though only notifications for removable devices are
52 // posted. 58 // posted.
53 std::map<std::string, DiskInfoMac> disk_info_map_; 59 std::map<std::string, DiskInfoMac> disk_info_map_;
54 60
55 DISALLOW_COPY_AND_ASSIGN(RemovableDeviceNotificationsMac); 61 DISALLOW_COPY_AND_ASSIGN(RemovableDeviceNotificationsMac);
56 }; 62 };
57 63
58 } // namespace chrome 64 } // namespace chrome
59 65
60 #endif // CHROME_BROWSER_SYSTEM_MONITOR_REMOVABLE_DEVICE_NOTIFICATIONS_MAC_H_ 66 #endif // CHROME_BROWSER_SYSTEM_MONITOR_REMOVABLE_DEVICE_NOTIFICATIONS_MAC_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698