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

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

Issue 10880078: Linux removable device notifications: notify about non-dcim devices. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Address 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
« no previous file with comments | « no previous file | chrome/browser/media_gallery/removable_device_notifications_linux.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 // RemovableDeviceNotificationsLinux listens for mount point changes, notifies 5 // RemovableDeviceNotificationsLinux listens for mount point changes, notifies
6 // the SystemMonitor about the addition and deletion of media devices, and 6 // the SystemMonitor about the addition and deletion of media devices, and
7 // answers queries about mounted devices. 7 // answers queries about mounted devices.
8 8
9 #ifndef CHROME_BROWSER_MEDIA_GALLERY_REMOVABLE_DEVICE_NOTIFICATIONS_LINUX_H_ 9 #ifndef CHROME_BROWSER_MEDIA_GALLERY_REMOVABLE_DEVICE_NOTIFICATIONS_LINUX_H_
10 #define CHROME_BROWSER_MEDIA_GALLERY_REMOVABLE_DEVICE_NOTIFICATIONS_LINUX_H_ 10 #define CHROME_BROWSER_MEDIA_GALLERY_REMOVABLE_DEVICE_NOTIFICATIONS_LINUX_H_
11 11
12 #if defined(OS_CHROMEOS) 12 #if defined(OS_CHROMEOS)
13 #error "Use the ChromeOS-specific implementation instead." 13 #error "Use the ChromeOS-specific implementation instead."
14 #endif 14 #endif
15 15
16 #include <map> 16 #include <map>
17 #include <set> 17 #include <set>
18 #include <string> 18 #include <string>
19 #include <utility> 19 #include <utility>
20 20
21 #include "base/basictypes.h" 21 #include "base/basictypes.h"
22 #include "base/compiler_specific.h" 22 #include "base/compiler_specific.h"
23 #include "base/files/file_path_watcher.h" 23 #include "base/files/file_path_watcher.h"
24 #include "base/memory/ref_counted.h" 24 #include "base/memory/ref_counted.h"
25 #include "content/public/browser/browser_thread.h" 25 #include "content/public/browser/browser_thread.h"
26 26
27 class FilePath; 27 class FilePath;
28 28
29 // Gets the media device information given a |device_path|. On success, 29 // Gets device information given a |device_path|. On success, returns true and
30 // returns true and fills in |unique_id|, |name|, and |removable|. 30 // fills in |unique_id|, |name|, and |removable|.
31 typedef bool (*GetDeviceInfoFunc)(const FilePath& device_path, 31 typedef bool (*GetDeviceInfoFunc)(const FilePath& device_path,
32 std::string* unique_id, string16* name, 32 std::string* unique_id, string16* name,
33 bool* removable); 33 bool* removable);
34 34
35 namespace chrome { 35 namespace chrome {
36 36
37 class RemovableDeviceNotificationsLinux 37 class RemovableDeviceNotificationsLinux
38 : public base::RefCountedThreadSafe<RemovableDeviceNotificationsLinux, 38 : public base::RefCountedThreadSafe<RemovableDeviceNotificationsLinux,
39 content::BrowserThread::DeleteOnFileThread> { 39 content::BrowserThread::DeleteOnFileThread> {
40 public: 40 public:
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after
75 content::BrowserThread::FILE>; 75 content::BrowserThread::FILE>;
76 76
77 // Structure to save mounted device information such as device path and unique 77 // Structure to save mounted device information such as device path and unique
78 // identifier. 78 // identifier.
79 struct MountPointInfo { 79 struct MountPointInfo {
80 MountPointInfo(); 80 MountPointInfo();
81 81
82 FilePath mount_device; 82 FilePath mount_device;
83 std::string device_id; 83 std::string device_id;
84 string16 device_name; 84 string16 device_name;
85 bool has_dcim;
86 }; 85 };
87 86
88 // Mapping of mount points to MountPointInfo. 87 // Mapping of mount points to MountPointInfo.
89 typedef std::map<FilePath, MountPointInfo> MountMap; 88 typedef std::map<FilePath, MountPointInfo> MountMap;
90 89
91 // (mount point, priority) 90 // (mount point, priority)
92 // For devices that are mounted to multiple mount points, this helps us track 91 // For devices that are mounted to multiple mount points, this helps us track
93 // which one we've notified system monitor about. 92 // which one we've notified system monitor about.
94 typedef std::map<FilePath, bool> ReferencedMountPoint; 93 typedef std::map<FilePath, bool> ReferencedMountPoint;
95 94
96 // (mount device, map of known mount points) 95 // (mount device, map of known mount points)
97 // For each mount device, track the places it is mounted and which one (if 96 // For each mount device, track the places it is mounted and which one (if
98 // any) we have notified system monitor about. 97 // any) we have notified system monitor about.
99 typedef std::map<FilePath, ReferencedMountPoint> MountPriorityMap; 98 typedef std::map<FilePath, ReferencedMountPoint> MountPriorityMap;
100 99
101 // Do initialization on the File Thread. 100 // Do initialization on the File Thread.
102 void InitOnFileThread(); 101 void InitOnFileThread();
103 102
104 // Parses mtab file and find all changes. 103 // Parses mtab file and find all changes.
105 void UpdateMtab(); 104 void UpdateMtab();
106 105
107 // Adds |mount_device| as mounted on |mount_point|. If the device is a new 106 // Adds |mount_device| as mounted on |mount_point|. If the device is a new
108 // media device, SystemMonitor is notified. 107 // device SystemMonitor is notified.
109 void AddNewMount(const FilePath& mount_device, const FilePath& mount_point); 108 void AddNewMount(const FilePath& mount_device, const FilePath& mount_point);
110 109
111 // Removes media device with a given device id.
112 void RemoveMediaMount(const std::string& device_id);
113
114 // Whether Init() has been called or not. 110 // Whether Init() has been called or not.
115 bool initialized_; 111 bool initialized_;
116 112
117 // Mtab file that lists the mount points. 113 // Mtab file that lists the mount points.
118 const FilePath mtab_path_; 114 const FilePath mtab_path_;
119 115
120 // Watcher for |mtab_path_|. 116 // Watcher for |mtab_path_|.
121 base::files::FilePathWatcher file_watcher_; 117 base::files::FilePathWatcher file_watcher_;
122 118
123 // Set of known file systems that we care about. 119 // Set of known file systems that we care about.
(...skipping 13 matching lines...) Expand all
137 // to notify about it's departure and notify about another one of it's mount 133 // to notify about it's departure and notify about another one of it's mount
138 // points. 134 // points.
139 MountPriorityMap mount_priority_map_; 135 MountPriorityMap mount_priority_map_;
140 136
141 DISALLOW_COPY_AND_ASSIGN(RemovableDeviceNotificationsLinux); 137 DISALLOW_COPY_AND_ASSIGN(RemovableDeviceNotificationsLinux);
142 }; 138 };
143 139
144 } // namespace chrome 140 } // namespace chrome
145 141
146 #endif // CHROME_BROWSER_MEDIA_GALLERY_REMOVABLE_DEVICE_NOTIFICATIONS_LINUX_H_ 142 #endif // CHROME_BROWSER_MEDIA_GALLERY_REMOVABLE_DEVICE_NOTIFICATIONS_LINUX_H_
OLDNEW
« no previous file with comments | « no previous file | chrome/browser/media_gallery/removable_device_notifications_linux.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698