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. |
ajl
2012/03/23 22:47:39
The style guide requires a descriptive file-level
Lei Zhang
2012/03/24 03:01:26
We don't identify the original author in Chromium,
| |
4 | 4 |
5 #ifndef CONTENT_BROWSER_MEDIA_DEVICE_NOTIFICATIONS_LINUX_H_ | 5 #ifndef CONTENT_BROWSER_MEDIA_DEVICE_NOTIFICATIONS_LINUX_H_ |
6 #define CONTENT_BROWSER_MEDIA_DEVICE_NOTIFICATIONS_LINUX_H_ | 6 #define CONTENT_BROWSER_MEDIA_DEVICE_NOTIFICATIONS_LINUX_H_ |
7 #pragma once | 7 #pragma once |
8 | 8 |
9 #include <map> | 9 #include <map> |
10 #include <set> | 10 #include <set> |
11 #include <string> | 11 #include <string> |
12 #include <utility> | 12 #include <utility> |
13 | 13 |
14 #include "base/basictypes.h" | 14 #include "base/basictypes.h" |
15 #include "base/compiler_specific.h" | 15 #include "base/compiler_specific.h" |
16 #include "base/file_path.h" | 16 #include "base/file_path.h" |
17 #include "base/files/file_path_watcher.h" | 17 #include "base/files/file_path_watcher.h" |
18 #include "base/memory/ref_counted.h" | 18 #include "base/memory/ref_counted.h" |
19 #include "base/system_monitor/system_monitor.h" | 19 #include "base/system_monitor/system_monitor.h" |
20 #include "content/common/content_export.h" | 20 #include "content/common/content_export.h" |
ajl
2012/03/23 22:47:39
Are all of these #includes actually necessary in t
Lei Zhang
2012/03/24 03:01:26
Yes, except for FilePath, which I forward declared
| |
21 | 21 |
22 namespace content { | 22 namespace content { |
23 | 23 |
24 class CONTENT_EXPORT MediaDeviceNotificationsLinux | 24 class CONTENT_EXPORT MediaDeviceNotificationsLinux |
25 : public base::RefCountedThreadSafe<MediaDeviceNotificationsLinux> { | 25 : public base::RefCountedThreadSafe<MediaDeviceNotificationsLinux> { |
26 public: | 26 public: |
27 explicit MediaDeviceNotificationsLinux(const FilePath& path); | 27 explicit MediaDeviceNotificationsLinux(const FilePath& path); |
28 | 28 |
29 // Must be called for MediaDeviceNotificationsLinux to work. | 29 // Must be called for MediaDeviceNotificationsLinux to work. |
30 void Init(); | 30 void Init(); |
31 | 31 |
32 void OnFilePathChanged(const FilePath& path); | 32 void OnFilePathChanged(const FilePath& path); |
33 | 33 |
34 private: | 34 private: |
35 friend class base::RefCountedThreadSafe<MediaDeviceNotificationsLinux>; | 35 friend class base::RefCountedThreadSafe<MediaDeviceNotificationsLinux>; |
36 | 36 |
37 typedef std::string MountDevice; | 37 typedef std::string MountDevice; |
ajl
2012/03/23 22:47:39
The use of a typedef here strikes me as superfluou
Lei Zhang
2012/03/24 03:01:26
Done.
| |
38 typedef std::string MountPoint; | 38 typedef std::string MountPoint; |
39 typedef std::pair<MountDevice, | 39 typedef std::pair<MountDevice, |
40 base::SystemMonitor::DeviceIdType> MountDeviceAndId; | 40 base::SystemMonitor::DeviceIdType> MountDeviceAndId; |
41 typedef std::map<MountPoint, MountDeviceAndId> MountMap; | 41 typedef std::map<MountPoint, MountDeviceAndId> MountMap; |
42 | 42 |
43 // A simple pass-through class. MediaDeviceNotificationsLinux cannot directly | 43 // A simple pass-through class. MediaDeviceNotificationsLinux cannot directly |
44 // inherit from FilePathWatcher::Delegate due to multiple inheritance. | 44 // inherit from FilePathWatcher::Delegate due to multiple inheritance. |
45 class WatcherDelegate : public base::files::FilePathWatcher::Delegate { | 45 class WatcherDelegate : public base::files::FilePathWatcher::Delegate { |
ajl
2012/03/23 22:47:39
Do you actually need the full definition of this c
Lei Zhang
2012/03/24 03:01:26
Done.
| |
46 public: | 46 public: |
47 explicit WatcherDelegate(MediaDeviceNotificationsLinux* notifier); | 47 explicit WatcherDelegate(MediaDeviceNotificationsLinux* notifier); |
48 | 48 |
49 // base::files::FilePathWatcher::Delegate implementation. | 49 // base::files::FilePathWatcher::Delegate implementation. |
50 virtual void OnFilePathChanged(const FilePath& path) OVERRIDE; | 50 virtual void OnFilePathChanged(const FilePath& path) OVERRIDE; |
51 | 51 |
52 private: | 52 private: |
53 friend class base::RefCountedThreadSafe<WatcherDelegate>; | 53 friend class base::RefCountedThreadSafe<WatcherDelegate>; |
54 | 54 |
55 virtual ~WatcherDelegate(); | 55 virtual ~WatcherDelegate(); |
56 MediaDeviceNotificationsLinux* notifier_; | 56 MediaDeviceNotificationsLinux* notifier_; |
ajl
2012/03/23 22:47:39
Is this owned or not? If owned, when is it delete
Lei Zhang
2012/03/24 03:01:26
Done.
| |
57 | 57 |
58 DISALLOW_COPY_AND_ASSIGN(WatcherDelegate); | 58 DISALLOW_COPY_AND_ASSIGN(WatcherDelegate); |
59 }; | 59 }; |
60 | 60 |
61 virtual ~MediaDeviceNotificationsLinux(); | 61 virtual ~MediaDeviceNotificationsLinux(); |
ajl
2012/03/23 22:47:39
For me, it would have been useful to have a commen
Lei Zhang
2012/03/24 03:01:26
Done. Ya, it seems everyone just does this without
| |
62 | 62 |
63 void InitOnFileThread(); | 63 void InitOnFileThread(); |
64 | 64 |
65 // Parse the mtab file and find all changes. | 65 // Parse the mtab file and find all changes. |
66 void UpdateMtab(); | 66 void UpdateMtab(); |
67 | 67 |
68 // Read the mtab file entries into |mtab|. | 68 // Read the mtab file entries into |mtab|. |
69 void ReadMtab(MountMap* mtab); | 69 void ReadMtab(MountMap* mtab); |
70 | 70 |
71 // For a new device mounted at |mount_point|, see if it is a media device by | 71 // For a new device mounted at |mount_point|, see if it is a media device by |
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
104 | 104 |
105 // Set of known file systems that we care about. | 105 // Set of known file systems that we care about. |
106 std::set<std::string> known_file_systems_; | 106 std::set<std::string> known_file_systems_; |
107 | 107 |
108 DISALLOW_COPY_AND_ASSIGN(MediaDeviceNotificationsLinux); | 108 DISALLOW_COPY_AND_ASSIGN(MediaDeviceNotificationsLinux); |
109 }; | 109 }; |
110 | 110 |
111 } // namespace content | 111 } // namespace content |
112 | 112 |
113 #endif // CONTENT_BROWSER_MEDIA_DEVICE_NOTIFICATIONS_LINUX_H_ | 113 #endif // CONTENT_BROWSER_MEDIA_DEVICE_NOTIFICATIONS_LINUX_H_ |
114 | |
OLD | NEW |