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

Unified Diff: chrome/browser/chromeos/cros/mount_library.h

Issue 6674043: Rewritten MountLibrary to work with non-blocking mount API calls in libcros.... (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: '' Created 9 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
« no previous file with comments | « chrome/browser/chromeos/cros/mock_mount_library.cc ('k') | chrome/browser/chromeos/cros/mount_library.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/chromeos/cros/mount_library.h
===================================================================
--- chrome/browser/chromeos/cros/mount_library.h (revision 78562)
+++ chrome/browser/chromeos/cros/mount_library.h (working copy)
@@ -7,7 +7,7 @@
#pragma once
#include <string>
-#include <vector>
+#include <map>
#include "base/observer_list.h"
#include "base/singleton.h"
@@ -16,52 +16,81 @@
namespace chromeos {
+typedef enum MountLibraryEventType {
+ MOUNT_DISK_ADDED,
+ MOUNT_DISK_REMOVED,
+ MOUNT_DISK_CHANGED,
+ MOUNT_DISK_MOUNTED,
+ MOUNT_DISK_UNMOUNTED,
+ MOUNT_DEVICE_ADDED,
+ MOUNT_DEVICE_REMOVED,
+ MOUNT_DEVICE_SCANNED
+} MountLibraryEventType;
+
// This class handles the interaction with the ChromeOS mount library APIs.
// Classes can add themselves as observers. Users can get an instance of this
// library class like this: chromeos::CrosLibrary::Get()->GetMountLibrary()
class MountLibrary {
public:
// Used to house an instance of each found mount device.
- struct Disk {
- Disk() {}
- Disk(const std::string& devicepath,
- const std::string& mountpath,
- const std::string& systempath,
- bool isparent,
- bool hasmedia)
- : device_path(devicepath),
- mount_path(mountpath),
- system_path(systempath),
- is_parent(isparent),
- has_media(hasmedia) {}
+ class Disk {
+ public:
+ Disk(const std::string& device_path,
+ const std::string& mount_path,
+ const std::string& system_path,
+ bool is_parent,
+ bool has_media,
+ bool on_boot_device)
+ : device_path_(device_path),
+ mount_path_(mount_path),
+ system_path_(system_path),
+ is_parent_(is_parent),
+ has_media_(has_media),
+ on_boot_device_(on_boot_device) {}
// The path of the device, used by devicekit-disks.
- std::string device_path;
+ const std::string& device_path() const { return device_path_; }
// The path to the mount point of this device. Will be empty if not mounted.
- std::string mount_path;
+ const std::string& mount_path() const { return mount_path_; }
// The path of the device according to the udev system.
- std::string system_path;
- // if the device is a parent device (i.e. sdb rather than sdb1)
- bool is_parent;
- // if the device has media currently
- bool has_media;
+ const std::string& system_path() const { return system_path_; }
+ // Is the device is a parent device (i.e. sdb rather than sdb1)
+ bool is_parent() const { return is_parent_; }
+ // Does the device contains media.
+ bool has_media() const { return has_media_; }
+ // Is the device ont
+ bool on_boot_device() const { return on_boot_device_; }
+
+ void set_mount_path(const char* mount_path) { mount_path_ = mount_path; }
+ void clear_mount_path() { mount_path_.clear(); }
+ private:
+ std::string device_path_;
+ std::string mount_path_;
+ std::string system_path_;
+ bool is_parent_;
+ bool has_media_;
+ bool on_boot_device_;
};
- typedef std::vector<Disk> DiskVector;
+ typedef std::map<std::string, Disk*> DiskMap;
class Observer {
public:
virtual ~Observer() {}
- virtual void MountChanged(MountLibrary* obj,
- MountEventType evt,
- const std::string& path) = 0;
+ // Async API events.
+ virtual void DiskChanged(MountLibraryEventType event,
+ const Disk* disk) = 0;
+ virtual void DeviceChanged(MountLibraryEventType event,
+ const std::string& device_path ) = 0;
};
virtual ~MountLibrary() {}
virtual void AddObserver(Observer* observer) = 0;
virtual void RemoveObserver(Observer* observer) = 0;
- virtual const DiskVector& disks() const = 0;
- virtual bool MountPath(const char* device_path) = 0;
- virtual bool IsBootPath(const char* device_path) = 0;
+ virtual const DiskMap& disks() const = 0;
+ virtual void RequestMountInfoRefresh() = 0;
+ virtual void MountPath(const char* device_path) = 0;
+ virtual void UnmountPath(const char* device_path) = 0;
+
// Factory function, creates a new instance and returns ownership.
// For normal usage, access the singleton via CrosLibrary::Get().
static MountLibrary* GetImpl(bool stub);
« no previous file with comments | « chrome/browser/chromeos/cros/mock_mount_library.cc ('k') | chrome/browser/chromeos/cros/mount_library.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698