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

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: Addressed review comments 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 // TODO(kmadhusu) This forward declaration is ugly. Fix it.
27 class RemovableDeviceNotificationsCros;
28 } // namespace chromeos
26 29
27 class RemovableDeviceNotificationsCros; 30 namespace chrome {
28 typedef RemovableDeviceNotificationsCros RemovableDeviceNotifications; 31
32 typedef class chromeos::RemovableDeviceNotificationsCros
33 RemovableDeviceNotifications;
34
35 } // namespace chrome
36
37 namespace chromeos {
29 38
30 class RemovableDeviceNotificationsCros 39 class RemovableDeviceNotificationsCros
31 : public base::RefCountedThreadSafe<RemovableDeviceNotificationsCros>, 40 : public base::RefCountedThreadSafe<RemovableDeviceNotificationsCros>,
32 public disks::DiskMountManager::Observer { 41 public disks::DiskMountManager::Observer {
33 public: 42 public:
43 // Should only be called by browser start up code. Use GetInstance() instead.
34 RemovableDeviceNotificationsCros(); 44 RemovableDeviceNotificationsCros();
35 45
46 static RemovableDeviceNotificationsCros* GetInstance();
47
36 virtual void DiskChanged(disks::DiskMountManagerEventType event, 48 virtual void DiskChanged(disks::DiskMountManagerEventType event,
37 const disks::DiskMountManager::Disk* disk) OVERRIDE; 49 const disks::DiskMountManager::Disk* disk) OVERRIDE;
38 virtual void DeviceChanged(disks::DiskMountManagerEventType event, 50 virtual void DeviceChanged(disks::DiskMountManagerEventType event,
39 const std::string& device_path) OVERRIDE; 51 const std::string& device_path) OVERRIDE;
40 virtual void MountCompleted( 52 virtual void MountCompleted(
41 disks::DiskMountManager::MountEvent event_type, 53 disks::DiskMountManager::MountEvent event_type,
42 MountError error_code, 54 MountError error_code,
43 const disks::DiskMountManager::MountPointInfo& mount_info) OVERRIDE; 55 const disks::DiskMountManager::MountPointInfo& mount_info) OVERRIDE;
44 56
57 // Finds the device that contains |path| and populates |device_info|.
58 // Returns false if unable to find the device.
59 bool GetDeviceInfoForPath(
60 const FilePath& path,
61 base::SystemMonitor::RemovableStorageInfo* device_info) const;
62
45 private: 63 private:
46 friend class base::RefCountedThreadSafe<RemovableDeviceNotificationsCros>; 64 friend class base::RefCountedThreadSafe<RemovableDeviceNotificationsCros>;
47 65
48 // Mapping of mount points to mount device IDs. 66 // Mapping of mount path to removable mass storage info.
49 typedef std::map<std::string, std::string> MountMap; 67 typedef std::map<std::string, base::SystemMonitor::RemovableStorageInfo>
68 MountMap;
50 69
51 // Private to avoid code deleting the object. 70 // Private to avoid code deleting the object.
52 virtual ~RemovableDeviceNotificationsCros(); 71 virtual ~RemovableDeviceNotificationsCros();
53 72
54 // Checks existing mount points map for media devices. For each mount point, 73 // Checks existing mount points map for media devices. For each mount point,
55 // call CheckMountedPathOnFileThread() below. 74 // call CheckMountedPathOnFileThread() below.
56 void CheckExistingMountPointsOnUIThread(); 75 void CheckExistingMountPointsOnUIThread();
57 76
58 // Checks if the mount point in |mount_info| is a media device. If it is, 77 // Checks if the mount point in |mount_info| is a media device. If it is,
59 // then continue with AddMountedPathOnUIThread() below. 78 // then continue with AddMountedPathOnUIThread() below.
(...skipping 10 matching lines...) Expand all
70 // Mapping of relevant mount points and their corresponding mount devices. 89 // Mapping of relevant mount points and their corresponding mount devices.
71 // Only accessed on the UI thread. 90 // Only accessed on the UI thread.
72 MountMap mount_map_; 91 MountMap mount_map_;
73 92
74 DISALLOW_COPY_AND_ASSIGN(RemovableDeviceNotificationsCros); 93 DISALLOW_COPY_AND_ASSIGN(RemovableDeviceNotificationsCros);
75 }; 94 };
76 95
77 } // namespace chromeos 96 } // namespace chromeos
78 97
79 #endif // CHROME_BROWSER_SYSTEM_MONITOR_REMOVABLE_DEVICE_NOTIFICATIONS_CHROMEOS _H_ 98 #endif // CHROME_BROWSER_SYSTEM_MONITOR_REMOVABLE_DEVICE_NOTIFICATIONS_CHROMEOS _H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698