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

Unified Diff: content/browser/media_device_notifications_linux.h

Issue 9622020: C++ Readability Review for thestig. (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: address comments Created 8 years, 9 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 side-by-side diff with in-line comments
Download patch
Index: content/browser/media_device_notifications_linux.h
===================================================================
--- content/browser/media_device_notifications_linux.h (revision 128430)
+++ content/browser/media_device_notifications_linux.h (working copy)
@@ -2,6 +2,9 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
+// MediaDeviceNotificationsLinux listens for mount point changes and notifies
+// the SystemMonitor about the addition and deletion of media devices.
+
#ifndef CONTENT_BROWSER_MEDIA_DEVICE_NOTIFICATIONS_LINUX_H_
#define CONTENT_BROWSER_MEDIA_DEVICE_NOTIFICATIONS_LINUX_H_
#pragma once
@@ -13,12 +16,13 @@
#include "base/basictypes.h"
#include "base/compiler_specific.h"
-#include "base/file_path.h"
#include "base/files/file_path_watcher.h"
#include "base/memory/ref_counted.h"
#include "base/system_monitor/system_monitor.h"
#include "content/common/content_export.h"
+class FilePath;
+
namespace content {
class CONTENT_EXPORT MediaDeviceNotificationsLinux
@@ -30,6 +34,10 @@
void Init();
protected:
+ // Avoids code deleting the object while there are references to it.
+ // Aside from the base::RefCountedThreadSafe friend class, and derived
+ // classes, any attempts to call this dtor will result in a compile-time
+ // error.
virtual ~MediaDeviceNotificationsLinux();
virtual void OnFilePathChanged(const FilePath& path);
@@ -37,30 +45,14 @@
private:
friend class base::RefCountedThreadSafe<MediaDeviceNotificationsLinux>;
- typedef std::string MountDevice;
- typedef std::string MountPoint;
- typedef std::pair<MountDevice,
+ class WatcherDelegate;
+
+ // (mount device, device id)
+ typedef std::pair<std::string,
base::SystemMonitor::DeviceIdType> MountDeviceAndId;
- typedef std::map<MountPoint, MountDeviceAndId> MountMap;
+ // Mapping of mount points to MountDeviceAndId.
+ typedef std::map<std::string, MountDeviceAndId> MountMap;
- // A simple pass-through class. MediaDeviceNotificationsLinux cannot directly
- // inherit from FilePathWatcher::Delegate due to multiple inheritance.
- class WatcherDelegate : public base::files::FilePathWatcher::Delegate {
- public:
- explicit WatcherDelegate(MediaDeviceNotificationsLinux* notifier);
-
- // base::files::FilePathWatcher::Delegate implementation.
- virtual void OnFilePathChanged(const FilePath& path) OVERRIDE;
-
- private:
- friend class base::RefCountedThreadSafe<WatcherDelegate>;
-
- virtual ~WatcherDelegate();
- MediaDeviceNotificationsLinux* notifier_;
-
- DISALLOW_COPY_AND_ASSIGN(WatcherDelegate);
- };
-
void InitOnFileThread();
// Parse the mtab file and find all changes.
@@ -74,12 +66,12 @@
// If it is a media device, return true, otherwise return false.
// Mac OS X behaves similarly, but this is not the only heuristic it uses.
// TODO(vandebo) Try to figure out how Mac OS X decides this.
- bool IsMediaDevice(const MountPoint& mount_point);
+ bool IsMediaDevice(const std::string& mount_point);
// Add a media device with a given device and mount device. Assign it a device
// id as well.
- void AddNewDevice(const MountDevice& mount_device,
- const MountPoint& mount_point,
+ void AddNewDevice(const std::string& mount_device,
+ const std::string& mount_point,
base::SystemMonitor::DeviceIdType* device_id);
// Remove a media device with a given device id.

Powered by Google App Engine
This is Rietveld 408576698