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

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

Issue 10918259: [Chrome OS]Implement MediaStorageUtil::GetDeviceInfoForPath function to support media gallery permi… (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: '' 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 // chromeos::RemovableDeviceNotificationsCros listens for mount point changes 5 // chromeos::RemovableDeviceNotificationsCros listens for mount point changes
6 // and notifies the SystemMonitor about the addition and deletion of media 6 // and notifies the SystemMonitor about the addition and deletion of media
7 // devices. 7 // devices.
8 8
9 #ifndef CHROME_BROWSER_SYSTEM_MONITOR_REMOVABLE_DEVICE_NOTIFICATIONS_CHROMEOS_H_ 9 #ifndef CHROME_BROWSER_SYSTEM_MONITOR_REMOVABLE_DEVICE_NOTIFICATIONS_CHROMEOS_H_
10 #define CHROME_BROWSER_SYSTEM_MONITOR_REMOVABLE_DEVICE_NOTIFICATIONS_CHROMEOS_H_ 10 #define CHROME_BROWSER_SYSTEM_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 "base/system_monitor/system_monitor.h" 22 #include "base/system_monitor/system_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 class RemovableDeviceNotificationsCros;
Lei Zhang 2012/09/17 22:52:52 just move this down to line 37
kmadhusu 2012/09/17 23:32:23 I need this forward declaration right before the t
27 } // namespace chromeos
26 28
27 class RemovableDeviceNotificationsCros; 29 namespace chrome {
28 typedef RemovableDeviceNotificationsCros RemovableDeviceNotifications; 30
31 typedef class chromeos::RemovableDeviceNotificationsCros
32 RemovableDeviceNotifications;
33
34 } // namespace chrome
35
36 namespace chromeos {
29 37
30 class RemovableDeviceNotificationsCros 38 class RemovableDeviceNotificationsCros
31 : public base::RefCountedThreadSafe<RemovableDeviceNotificationsCros>, 39 : public base::RefCountedThreadSafe<RemovableDeviceNotificationsCros>,
32 public disks::DiskMountManager::Observer { 40 public disks::DiskMountManager::Observer {
33 public: 41 public:
42 // Should only be called by browser start up code. Use GetInstance() instead.
34 RemovableDeviceNotificationsCros(); 43 RemovableDeviceNotificationsCros();
35 44
45 static RemovableDeviceNotificationsCros* GetInstance();
46
36 virtual void DiskChanged(disks::DiskMountManagerEventType event, 47 virtual void DiskChanged(disks::DiskMountManagerEventType event,
37 const disks::DiskMountManager::Disk* disk) OVERRIDE; 48 const disks::DiskMountManager::Disk* disk) OVERRIDE;
38 virtual void DeviceChanged(disks::DiskMountManagerEventType event, 49 virtual void DeviceChanged(disks::DiskMountManagerEventType event,
39 const std::string& device_path) OVERRIDE; 50 const std::string& device_path) OVERRIDE;
40 virtual void MountCompleted( 51 virtual void MountCompleted(
41 disks::DiskMountManager::MountEvent event_type, 52 disks::DiskMountManager::MountEvent event_type,
42 MountError error_code, 53 MountError error_code,
43 const disks::DiskMountManager::MountPointInfo& mount_info) OVERRIDE; 54 const disks::DiskMountManager::MountPointInfo& mount_info) OVERRIDE;
44 55
56 // Finds the device that contains |path| and populates |device_info|.
57 // Returns false if unable to find the device.
58 bool GetDeviceInfoForPath(
59 const FilePath& path,
60 base::SystemMonitor::RemovableStorageInfo* device_info) const;
61
45 private: 62 private:
46 friend class base::RefCountedThreadSafe<RemovableDeviceNotificationsCros>; 63 friend class base::RefCountedThreadSafe<RemovableDeviceNotificationsCros>;
47 64
48 // Mapping of mount points to mount device IDs. 65 // Mapping of mount path to removable mass storage info.
49 typedef std::map<std::string, std::string> MountMap; 66 typedef std::map<std::string, base::SystemMonitor::RemovableStorageInfo>
67 MountMap;
50 68
51 // Private to avoid code deleting the object. 69 // Private to avoid code deleting the object.
52 virtual ~RemovableDeviceNotificationsCros(); 70 virtual ~RemovableDeviceNotificationsCros();
53 71
54 // Checks existing mount points map for media devices. For each mount point, 72 // Checks existing mount points map for media devices. For each mount point,
55 // call CheckMountedPathOnFileThread() below. 73 // call CheckMountedPathOnFileThread() below.
56 void CheckExistingMountPointsOnUIThread(); 74 void CheckExistingMountPointsOnUIThread();
57 75
58 // Checks if the mount point in |mount_info| is a media device. If it is, 76 // Checks if the mount point in |mount_info| is a media device. If it is,
59 // then continue with AddMountedPathOnUIThread() below. 77 // then continue with AddMountedPathOnUIThread() below.
(...skipping 10 matching lines...) Expand all
70 // Mapping of relevant mount points and their corresponding mount devices. 88 // Mapping of relevant mount points and their corresponding mount devices.
71 // Only accessed on the UI thread. 89 // Only accessed on the UI thread.
72 MountMap mount_map_; 90 MountMap mount_map_;
73 91
74 DISALLOW_COPY_AND_ASSIGN(RemovableDeviceNotificationsCros); 92 DISALLOW_COPY_AND_ASSIGN(RemovableDeviceNotificationsCros);
75 }; 93 };
76 94
77 } // namespace chromeos 95 } // namespace chromeos
78 96
79 #endif // CHROME_BROWSER_SYSTEM_MONITOR_REMOVABLE_DEVICE_NOTIFICATIONS_CHROMEOS _H_ 97 #endif // CHROME_BROWSER_SYSTEM_MONITOR_REMOVABLE_DEVICE_NOTIFICATIONS_CHROMEOS _H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698