OLD | NEW |
---|---|
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 // chromeos::RemovableDeviceNotificationsCros listens for mount point changes | 5 // chromeos::RemovableDeviceNotificationsCros listens for mount point changes |
6 // and notifies listeners about the addition and deletion of media | 6 // and notifies listeners about the addition and deletion of media |
7 // devices. | 7 // devices. |
8 | 8 |
9 #ifndef CHROME_BROWSER_STORAGE_MONITOR_REMOVABLE_DEVICE_NOTIFICATIONS_CHROMEOS_H _ | 9 #ifndef CHROME_BROWSER_STORAGE_MONITOR_REMOVABLE_DEVICE_NOTIFICATIONS_CHROMEOS_H _ |
vandebo (ex-Chrome)
2013/02/28 20:02:40
Include guards need to be updated as well.
| |
10 #define CHROME_BROWSER_STORAGE_MONITOR_REMOVABLE_DEVICE_NOTIFICATIONS_CHROMEOS_H _ | 10 #define CHROME_BROWSER_STORAGE_MONITOR_REMOVABLE_DEVICE_NOTIFICATIONS_CHROMEOS_H _ |
11 | 11 |
12 #if !defined(OS_CHROMEOS) | 12 #if !defined(OS_CHROMEOS) |
13 #error "Should only be used on ChromeOS." | 13 #error "Should only be used on ChromeOS." |
14 #endif | 14 #endif |
15 | 15 |
16 #include <map> | 16 #include <map> |
17 #include <string> | 17 #include <string> |
18 | 18 |
19 #include "base/basictypes.h" | 19 #include "base/basictypes.h" |
20 #include "base/compiler_specific.h" | 20 #include "base/compiler_specific.h" |
21 #include "base/memory/ref_counted.h" | 21 #include "base/memory/ref_counted.h" |
22 #include "chrome/browser/storage_monitor/storage_monitor.h" | 22 #include "chrome/browser/storage_monitor/storage_monitor.h" |
23 #include "chromeos/disks/disk_mount_manager.h" | 23 #include "chromeos/disks/disk_mount_manager.h" |
24 | 24 |
25 namespace chromeos { | 25 namespace chromeos { |
26 | 26 |
27 class RemovableDeviceNotificationsCros | 27 class StorageMonitorCros |
28 : public chrome::StorageMonitor, | 28 : public chrome::StorageMonitor, |
29 public base::RefCountedThreadSafe<RemovableDeviceNotificationsCros>, | 29 public base::RefCountedThreadSafe<StorageMonitorCros>, |
30 public disks::DiskMountManager::Observer { | 30 public disks::DiskMountManager::Observer { |
31 public: | 31 public: |
32 // Should only be called by browser start up code. Use GetInstance() instead. | 32 // Should only be called by browser start up code. Use GetInstance() instead. |
33 RemovableDeviceNotificationsCros(); | 33 StorageMonitorCros(); |
34 | 34 |
35 virtual void OnDiskEvent(disks::DiskMountManager::DiskEvent event, | 35 virtual void OnDiskEvent(disks::DiskMountManager::DiskEvent event, |
36 const disks::DiskMountManager::Disk* disk) OVERRIDE; | 36 const disks::DiskMountManager::Disk* disk) OVERRIDE; |
37 virtual void OnDeviceEvent(disks::DiskMountManager::DeviceEvent event, | 37 virtual void OnDeviceEvent(disks::DiskMountManager::DeviceEvent event, |
38 const std::string& device_path) OVERRIDE; | 38 const std::string& device_path) OVERRIDE; |
39 virtual void OnMountEvent( | 39 virtual void OnMountEvent( |
40 disks::DiskMountManager::MountEvent event, | 40 disks::DiskMountManager::MountEvent event, |
41 MountError error_code, | 41 MountError error_code, |
42 const disks::DiskMountManager::MountPointInfo& mount_info) OVERRIDE; | 42 const disks::DiskMountManager::MountPointInfo& mount_info) OVERRIDE; |
43 virtual void OnFormatEvent(disks::DiskMountManager::FormatEvent event, | 43 virtual void OnFormatEvent(disks::DiskMountManager::FormatEvent event, |
(...skipping 12 matching lines...) Expand all Loading... | |
56 | 56 |
57 private: | 57 private: |
58 struct StorageObjectInfo { | 58 struct StorageObjectInfo { |
59 // Basic details {storage device name, location and identifier}. | 59 // Basic details {storage device name, location and identifier}. |
60 StorageInfo storage_info; | 60 StorageInfo storage_info; |
61 | 61 |
62 // Device storage size. | 62 // Device storage size. |
63 uint64 storage_size_in_bytes; | 63 uint64 storage_size_in_bytes; |
64 }; | 64 }; |
65 | 65 |
66 friend class base::RefCountedThreadSafe<RemovableDeviceNotificationsCros>; | 66 friend class base::RefCountedThreadSafe<StorageMonitorCros>; |
67 | 67 |
68 // Mapping of mount path to removable mass storage info. | 68 // Mapping of mount path to removable mass storage info. |
69 typedef std::map<std::string, StorageObjectInfo> MountMap; | 69 typedef std::map<std::string, StorageObjectInfo> MountMap; |
70 | 70 |
71 // Private to avoid code deleting the object. | 71 // Private to avoid code deleting the object. |
72 virtual ~RemovableDeviceNotificationsCros(); | 72 virtual ~StorageMonitorCros(); |
73 | 73 |
74 // Checks existing mount points map for media devices. For each mount point, | 74 // Checks existing mount points map for media devices. For each mount point, |
75 // call CheckMountedPathOnFileThread() below. | 75 // call CheckMountedPathOnFileThread() below. |
76 void CheckExistingMountPointsOnUIThread(); | 76 void CheckExistingMountPointsOnUIThread(); |
77 | 77 |
78 // Checks if the mount point in |mount_info| is a media device. If it is, | 78 // Checks if the mount point in |mount_info| is a media device. If it is, |
79 // then continue with AddMountedPathOnUIThread() below. | 79 // then continue with AddMountedPathOnUIThread() below. |
80 void CheckMountedPathOnFileThread( | 80 void CheckMountedPathOnFileThread( |
81 const disks::DiskMountManager::MountPointInfo& mount_info); | 81 const disks::DiskMountManager::MountPointInfo& mount_info); |
82 | 82 |
83 // Adds the mount point in |mount_info| to |mount_map_| and send a media | 83 // Adds the mount point in |mount_info| to |mount_map_| and send a media |
84 // device attach notification. |has_dcim| is true if the attached device has | 84 // device attach notification. |has_dcim| is true if the attached device has |
85 // a DCIM folder. | 85 // a DCIM folder. |
86 void AddMountedPathOnUIThread( | 86 void AddMountedPathOnUIThread( |
87 const disks::DiskMountManager::MountPointInfo& mount_info, | 87 const disks::DiskMountManager::MountPointInfo& mount_info, |
88 bool has_dcim); | 88 bool has_dcim); |
89 | 89 |
90 // Mapping of relevant mount points and their corresponding mount devices. | 90 // Mapping of relevant mount points and their corresponding mount devices. |
91 // Only accessed on the UI thread. | 91 // Only accessed on the UI thread. |
92 MountMap mount_map_; | 92 MountMap mount_map_; |
93 | 93 |
94 DISALLOW_COPY_AND_ASSIGN(RemovableDeviceNotificationsCros); | 94 DISALLOW_COPY_AND_ASSIGN(StorageMonitorCros); |
95 }; | 95 }; |
96 | 96 |
97 } // namespace chromeos | 97 } // namespace chromeos |
98 | 98 |
99 #endif // CHROME_BROWSER_STORAGE_MONITOR_REMOVABLE_DEVICE_NOTIFICATIONS_CHROMEO S_H_ | 99 #endif // CHROME_BROWSER_STORAGE_MONITOR_REMOVABLE_DEVICE_NOTIFICATIONS_CHROMEO S_H_ |
OLD | NEW |