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

Side by Side Diff: chrome/browser/media_gallery/media_device_notifications_linux.h

Issue 10780023: Change base::SystemMonitor's media device functions to take a type and string16 instead of a FilePa… (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: fix cros Created 8 years, 5 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 // MediaDeviceNotificationsLinux listens for mount point changes and notifies 5 // MediaDeviceNotificationsLinux listens for mount point changes and notifies
6 // the SystemMonitor about the addition and deletion of media devices. 6 // the SystemMonitor about the addition and deletion of media devices.
7 7
8 #ifndef CHROME_BROWSER_MEDIA_GALLERY_MEDIA_DEVICE_NOTIFICATIONS_LINUX_H_ 8 #ifndef CHROME_BROWSER_MEDIA_GALLERY_MEDIA_DEVICE_NOTIFICATIONS_LINUX_H_
9 #define CHROME_BROWSER_MEDIA_GALLERY_MEDIA_DEVICE_NOTIFICATIONS_LINUX_H_ 9 #define CHROME_BROWSER_MEDIA_GALLERY_MEDIA_DEVICE_NOTIFICATIONS_LINUX_H_
10 10
11 #if defined(OS_CHROMEOS) 11 #if defined(OS_CHROMEOS)
12 #error "Use the ChromeOS-specific implementation instead." 12 #error "Use the ChromeOS-specific implementation instead."
13 #endif 13 #endif
14 14
15 #include <map> 15 #include <map>
16 #include <set> 16 #include <set>
17 #include <string> 17 #include <string>
18 #include <utility> 18 #include <utility>
19 19
20 #include "base/basictypes.h" 20 #include "base/basictypes.h"
21 #include "base/compiler_specific.h" 21 #include "base/compiler_specific.h"
22 #include "base/files/file_path_watcher.h" 22 #include "base/files/file_path_watcher.h"
23 #include "base/memory/ref_counted.h" 23 #include "base/memory/ref_counted.h"
24 #include "base/system_monitor/system_monitor.h"
25 #include "content/public/browser/browser_thread.h" 24 #include "content/public/browser/browser_thread.h"
26 25
27 class FilePath; 26 class FilePath;
28 27
29 namespace chrome { 28 namespace chrome {
30 29
31 class MediaDeviceNotificationsLinux 30 class MediaDeviceNotificationsLinux
32 : public base::RefCountedThreadSafe<MediaDeviceNotificationsLinux, 31 : public base::RefCountedThreadSafe<MediaDeviceNotificationsLinux,
33 content::BrowserThread::DeleteOnFileThread> { 32 content::BrowserThread::DeleteOnFileThread> {
34 public: 33 public:
(...skipping 11 matching lines...) Expand all
46 45
47 virtual void OnFilePathChanged(const FilePath& path, bool error); 46 virtual void OnFilePathChanged(const FilePath& path, bool error);
48 47
49 private: 48 private:
50 friend class base::RefCountedThreadSafe<MediaDeviceNotificationsLinux>; 49 friend class base::RefCountedThreadSafe<MediaDeviceNotificationsLinux>;
51 friend class base::DeleteHelper<MediaDeviceNotificationsLinux>; 50 friend class base::DeleteHelper<MediaDeviceNotificationsLinux>;
52 friend struct content::BrowserThread::DeleteOnThread< 51 friend struct content::BrowserThread::DeleteOnThread<
53 content::BrowserThread::FILE>; 52 content::BrowserThread::FILE>;
54 53
55 // (mount device, device id) 54 // (mount device, device id)
56 typedef std::pair<std::string, 55 typedef std::pair<std::string, std::string> MountDeviceAndId;
57 base::SystemMonitor::DeviceIdType> MountDeviceAndId;
58 // Mapping of mount points to MountDeviceAndId. 56 // Mapping of mount points to MountDeviceAndId.
59 typedef std::map<std::string, MountDeviceAndId> MountMap; 57 typedef std::map<std::string, MountDeviceAndId> MountMap;
60 58
61 void InitOnFileThread(); 59 void InitOnFileThread();
62 60
63 // Parse the mtab file and find all changes. 61 // Parse the mtab file and find all changes.
64 void UpdateMtab(); 62 void UpdateMtab();
65 63
66 // Read the mtab file entries into |mtab|. 64 // Read the mtab file entries into |mtab|.
67 void ReadMtab(MountMap* mtab); 65 void ReadMtab(MountMap* mtab);
68 66
69 // Add a media device with a given device and mount device. Assign it a device 67 // Add a media device with a given device and mount device. Assign it a device
70 // id as well. 68 // id as well.
71 void AddNewDevice(const std::string& mount_device, 69 void AddNewDevice(const std::string& mount_device,
72 const std::string& mount_point, 70 const std::string& mount_point,
73 base::SystemMonitor::DeviceIdType* device_id); 71 std::string* device_id);
74 72
75 // Remove a media device with a given device id. 73 // Remove a media device with a given device id.
76 void RemoveOldDevice(const base::SystemMonitor::DeviceIdType& device_id); 74 void RemoveOldDevice(const std::string& device_id);
77 75
78 // Whether Init() has been called or not. 76 // Whether Init() has been called or not.
79 bool initialized_; 77 bool initialized_;
80 78
81 // Mtab file that lists the mount points. 79 // Mtab file that lists the mount points.
82 const FilePath mtab_path_; 80 const FilePath mtab_path_;
83 81
84 // Watcher for |mtab_path_|. 82 // Watcher for |mtab_path_|.
85 base::files::FilePathWatcher file_watcher_; 83 base::files::FilePathWatcher file_watcher_;
86 84
87 // Mapping of relevant mount points and their corresponding mount devices. 85 // Mapping of relevant mount points and their corresponding mount devices.
88 // Keep in mind on Linux, a device can be mounted at multiple mount points, 86 // Keep in mind on Linux, a device can be mounted at multiple mount points,
89 // and multiple devices can be mounted at a mount point. 87 // and multiple devices can be mounted at a mount point.
90 MountMap mtab_; 88 MountMap mtab_;
91 89
92 // The lowest available device id number. 90 // The lowest available device id number.
93 base::SystemMonitor::DeviceIdType current_device_id_; 91 // TODO(thestig) Remove this and use a real per-device unique id instead.
92 int current_device_id_;
94 93
95 // Set of known file systems that we care about. 94 // Set of known file systems that we care about.
96 std::set<std::string> known_file_systems_; 95 std::set<std::string> known_file_systems_;
97 96
98 DISALLOW_COPY_AND_ASSIGN(MediaDeviceNotificationsLinux); 97 DISALLOW_COPY_AND_ASSIGN(MediaDeviceNotificationsLinux);
99 }; 98 };
100 99
101 } // namespace chrome 100 } // namespace chrome
102 101
103 #endif // CHROME_BROWSER_MEDIA_GALLERY_MEDIA_DEVICE_NOTIFICATIONS_LINUX_H_ 102 #endif // CHROME_BROWSER_MEDIA_GALLERY_MEDIA_DEVICE_NOTIFICATIONS_LINUX_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698