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

Side by Side Diff: chrome/browser/chromeos/cros/mount_library.h

Issue 7471024: Formatting feature initial commit for ChromeOS Tree (Closed) Base URL: http://git.chromium.org/git/chromium.git@trunk
Patch Set: Another iteration Created 9 years, 4 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) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 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 #ifndef CHROME_BROWSER_CHROMEOS_CROS_MOUNT_LIBRARY_H_ 5 #ifndef CHROME_BROWSER_CHROMEOS_CROS_MOUNT_LIBRARY_H_
6 #define CHROME_BROWSER_CHROMEOS_CROS_MOUNT_LIBRARY_H_ 6 #define CHROME_BROWSER_CHROMEOS_CROS_MOUNT_LIBRARY_H_
7 #pragma once 7 #pragma once
8 8
9 #include <string> 9 #include <string>
10 #include <map> 10 #include <map>
11 11
12 #include "base/memory/singleton.h" 12 #include "base/memory/singleton.h"
13 #include "base/observer_list.h" 13 #include "base/observer_list.h"
14 #include "base/time.h" 14 #include "base/time.h"
15 #include "third_party/cros/chromeos_mount.h" 15 #include "third_party/cros/chromeos_mount.h"
16 16
17 namespace chromeos { 17 namespace chromeos {
18 18
19 typedef enum MountLibraryEventType { 19 typedef enum MountLibraryEventType {
20 MOUNT_DISK_ADDED, 20 MOUNT_DISK_ADDED,
21 MOUNT_DISK_REMOVED, 21 MOUNT_DISK_REMOVED,
22 MOUNT_DISK_CHANGED, 22 MOUNT_DISK_CHANGED,
23 MOUNT_DISK_MOUNTED, 23 MOUNT_DISK_MOUNTED,
24 MOUNT_DISK_UNMOUNTED, 24 MOUNT_DISK_UNMOUNTED,
25 MOUNT_DEVICE_ADDED, 25 MOUNT_DEVICE_ADDED,
26 MOUNT_DEVICE_REMOVED, 26 MOUNT_DEVICE_REMOVED,
27 MOUNT_DEVICE_SCANNED 27 MOUNT_DEVICE_SCANNED,
28 MOUNT_FORMATTING_STARTED,
29 MOUNT_FORMATTING_FINISHED
28 } MountLibraryEventType; 30 } MountLibraryEventType;
29 31
30 // This class handles the interaction with the ChromeOS mount library APIs. 32 // This class handles the interaction with the ChromeOS mount library APIs.
31 // Classes can add themselves as observers. Users can get an instance of this 33 // Classes can add themselves as observers. Users can get an instance of this
32 // library class like this: chromeos::CrosLibrary::Get()->GetMountLibrary() 34 // library class like this: chromeos::CrosLibrary::Get()->GetMountLibrary()
33 class MountLibrary { 35 class MountLibrary {
34 public: 36 public:
35 // Used to house an instance of each found mount device. 37 // Used to house an instance of each found mount device.
36 class Disk { 38 class Disk {
37 public: 39 public:
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after
89 std::string drive_label_; 91 std::string drive_label_;
90 std::string parent_path_; 92 std::string parent_path_;
91 DeviceType device_type_; 93 DeviceType device_type_;
92 uint64 total_size_; 94 uint64 total_size_;
93 bool is_parent_; 95 bool is_parent_;
94 bool is_read_only_; 96 bool is_read_only_;
95 bool has_media_; 97 bool has_media_;
96 bool on_boot_device_; 98 bool on_boot_device_;
97 }; 99 };
98 typedef std::map<std::string, Disk*> DiskMap; 100 typedef std::map<std::string, Disk*> DiskMap;
101 typedef std::map<std::string, std::string> PathMap;
99 102
100 typedef void(*UnmountDeviceRecursiveCallbackType)(void*, bool); 103 typedef void(*UnmountDeviceRecursiveCallbackType)(void*, bool);
101 104
102 class Observer { 105 class Observer {
103 public: 106 public:
104 virtual ~Observer() {} 107 virtual ~Observer() {}
105 // Async API events. 108 // Async API events.
106 virtual void DiskChanged(MountLibraryEventType event, 109 virtual void DiskChanged(MountLibraryEventType event,
107 const Disk* disk) = 0; 110 const Disk* disk) = 0;
108 virtual void DeviceChanged(MountLibraryEventType event, 111 virtual void DeviceChanged(MountLibraryEventType event,
109 const std::string& device_path ) = 0; 112 const std::string& device_path) = 0;
110 }; 113 };
111 114
112 virtual ~MountLibrary() {} 115 virtual ~MountLibrary() {}
113 virtual void AddObserver(Observer* observer) = 0; 116 virtual void AddObserver(Observer* observer) = 0;
114 virtual void RemoveObserver(Observer* observer) = 0; 117 virtual void RemoveObserver(Observer* observer) = 0;
115 virtual const DiskMap& disks() const = 0; 118 virtual const DiskMap& disks() const = 0;
116
117 virtual void RequestMountInfoRefresh() = 0; 119 virtual void RequestMountInfoRefresh() = 0;
120 // Mounts device given its device path
118 virtual void MountPath(const char* device_path) = 0; 121 virtual void MountPath(const char* device_path) = 0;
122 // Unmounts device given is device path
119 virtual void UnmountPath(const char* device_path) = 0; 123 virtual void UnmountPath(const char* device_path) = 0;
120 124 // Formats device given its file path, eg. /dev/*.
125 virtual void FormatUnmountedDevice(const char* file_path) = 0;
126 // Formats Device given its mount path
tbarzic 2011/07/26 22:49:50 dot
sidor 2011/07/28 00:20:51 Done.
127 virtual void FormatMountedDevice(const char* mount_path) = 0;
121 // Unmounts device_poath and all of its known children. 128 // Unmounts device_poath and all of its known children.
122 virtual void UnmountDeviceRecursive(const char* device_path, 129 virtual void UnmountDeviceRecursive(const char* device_path,
123 UnmountDeviceRecursiveCallbackType callback, void* user_data) = 0; 130 UnmountDeviceRecursiveCallbackType callback, void* user_data) = 0;
124
125 // Factory function, creates a new instance and returns ownership. 131 // Factory function, creates a new instance and returns ownership.
126 // For normal usage, access the singleton via CrosLibrary::Get(). 132 // For normal usage, access the singleton via CrosLibrary::Get().
127 static MountLibrary* GetImpl(bool stub); 133 static MountLibrary* GetImpl(bool stub);
128 }; 134 };
129 135
130 } // namespace chromeos 136 } // namespace chromeos
131 137
132 #endif // CHROME_BROWSER_CHROMEOS_CROS_MOUNT_LIBRARY_H_ 138 #endif // CHROME_BROWSER_CHROMEOS_CROS_MOUNT_LIBRARY_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698