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

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

Issue 7826037: Adding support to retrieve remaining and total space on disk/file shelf. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 9 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
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 #include "chrome/browser/chromeos/cros/mount_library.h" 5 #include "chrome/browser/chromeos/cros/mount_library.h"
6 6
7 #include <set> 7 #include <set>
8 #include <vector> 8 #include <vector>
9 9
10 #include "base/message_loop.h" 10 #include "base/message_loop.h"
(...skipping 108 matching lines...) Expand 10 before | Expand all | Expand 10 after
119 void* object) OVERRIDE { 119 void* object) OVERRIDE {
120 FormatDevice(file_path, filesystem, callback, object); 120 FormatDevice(file_path, filesystem, callback, object);
121 } 121 }
122 122
123 virtual void CallGetDiskProperties(const char* device_path, 123 virtual void CallGetDiskProperties(const char* device_path,
124 GetDiskPropertiesCallback callback, 124 GetDiskPropertiesCallback callback,
125 void* object) OVERRIDE { 125 void* object) OVERRIDE {
126 GetDiskProperties(device_path, callback, object); 126 GetDiskProperties(device_path, callback, object);
127 } 127 }
128 128
129 virtual void CallGetSizeStats(const char* mount_path,
130 GetSizeStatsCallback callback,
131 void* object) OVERRIDE {
132 GetMountPointSizeStats(mount_path, callback, object);
133 }
134
129 virtual MountEventConnection MonitorCrosDisks(MountEventMonitor monitor, 135 virtual MountEventConnection MonitorCrosDisks(MountEventMonitor monitor,
130 MountCompletedMonitor mount_completed_monitor, 136 MountCompletedMonitor mount_completed_monitor,
131 void* object) OVERRIDE { 137 void* object) OVERRIDE {
132 return MonitorAllMountEvents(monitor, mount_completed_monitor, object); 138 return MonitorAllMountEvents(monitor, mount_completed_monitor, object);
133 } 139 }
134 140
135 virtual void DisconnectCrosDisksMonitorIfSet(MountEventConnection conn) 141 virtual void DisconnectCrosDisksMonitorIfSet(MountEventConnection conn)
136 OVERRIDE { 142 OVERRIDE {
137 if (conn) 143 if (conn)
138 DisconnectMountEventMonitor(conn); 144 DisconnectMountEventMonitor(conn);
(...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after
203 OnUnmountPath(mount_path, 209 OnUnmountPath(mount_path,
204 MOUNT_METHOD_ERROR_LOCAL, 210 MOUNT_METHOD_ERROR_LOCAL,
205 kLibraryNotLoaded); 211 kLibraryNotLoaded);
206 return; 212 return;
207 } 213 }
208 214
209 libcros_proxy_->CallUnmountPath(mount_path, &UnmountMountPointCallback, 215 libcros_proxy_->CallUnmountPath(mount_path, &UnmountMountPointCallback,
210 this); 216 this);
211 } 217 }
212 218
219 virtual void GetSizeStats(const char* mount_path,
220 CallbackDelegate* callback_delegate) OVERRIDE {
221 CHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
222 if (!CrosLibrary::Get()->EnsureLoaded()) {
223 GetSizeStatsCallback(callback_delegate, mount_path, 0, 0,
224 MOUNT_METHOD_ERROR_LOCAL, kLibraryNotLoaded);
225 return;
226 }
227
228 libcros_proxy_->CallGetSizeStats(mount_path, &GetSizeStatsCallback,
zel 2011/09/02 21:37:34 You might want to inline that routine here as well
tonibarzic 2011/09/02 21:59:01 It seemed like a good idea to keep system calls in
zel 2011/09/02 22:00:58 We should move such functionality here into mount_
229 callback_delegate);
230 }
231
213 virtual void FormatUnmountedDevice(const char* file_path) OVERRIDE { 232 virtual void FormatUnmountedDevice(const char* file_path) OVERRIDE {
214 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); 233 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
215 if (!CrosLibrary::Get()->EnsureLoaded()) { 234 if (!CrosLibrary::Get()->EnsureLoaded()) {
216 OnFormatDevice(file_path, 235 OnFormatDevice(file_path,
217 false, 236 false,
218 MOUNT_METHOD_ERROR_LOCAL, 237 MOUNT_METHOD_ERROR_LOCAL,
219 kLibraryNotLoaded); 238 kLibraryNotLoaded);
220 return; 239 return;
221 } 240 }
222 for (MountLibrary::DiskMap::iterator it = disks_.begin(); 241 for (MountLibrary::DiskMap::iterator it = disks_.begin();
(...skipping 143 matching lines...) Expand 10 before | Expand all | Expand 10 after
366 // Callback for UnmountRemovableDevice method. 385 // Callback for UnmountRemovableDevice method.
367 static void UnmountMountPointCallback(void* object, 386 static void UnmountMountPointCallback(void* object,
368 const char* mount_path, 387 const char* mount_path,
369 MountMethodErrorType error, 388 MountMethodErrorType error,
370 const char* error_message) { 389 const char* error_message) {
371 DCHECK(object); 390 DCHECK(object);
372 MountLibraryImpl* self = static_cast<MountLibraryImpl*>(object); 391 MountLibraryImpl* self = static_cast<MountLibraryImpl*>(object);
373 self->OnUnmountPath(mount_path, error, error_message); 392 self->OnUnmountPath(mount_path, error, error_message);
374 } 393 }
375 394
395 static void GetSizeStatsCallback(void* object,
396 const char* mount_path,
397 size_t total_size_kb,
398 size_t remaining_size_kb,
399 MountMethodErrorType error,
400 const char* error_message) {
401 DCHECK(object);
402 CallbackDelegate* callback = static_cast<CallbackDelegate*>(object);
403
404 callback->GetSizeStatsCallback(mount_path,
405 error == MOUNT_METHOD_ERROR_NONE, total_size_kb, remaining_size_kb);
406 }
407
376 // Callback for FormatRemovableDevice method. 408 // Callback for FormatRemovableDevice method.
377 static void FormatDeviceCallback(void* object, 409 static void FormatDeviceCallback(void* object,
378 const char* file_path, 410 const char* file_path,
379 bool success, 411 bool success,
380 MountMethodErrorType error, 412 MountMethodErrorType error,
381 const char* error_message) { 413 const char* error_message) {
382 DCHECK(object); 414 DCHECK(object);
383 MountLibraryImpl* self = static_cast<MountLibraryImpl*>(object); 415 MountLibraryImpl* self = static_cast<MountLibraryImpl*>(object);
384 const char* device_path = self->FilePathToDevicePath(file_path); 416 const char* device_path = self->FilePathToDevicePath(file_path);
385 if (!device_path) { 417 if (!device_path) {
(...skipping 410 matching lines...) Expand 10 before | Expand all | Expand 10 after
796 virtual void AddObserver(Observer* observer) OVERRIDE {} 828 virtual void AddObserver(Observer* observer) OVERRIDE {}
797 virtual void RemoveObserver(Observer* observer) OVERRIDE {} 829 virtual void RemoveObserver(Observer* observer) OVERRIDE {}
798 virtual const DiskMap& disks() const OVERRIDE { return disks_; } 830 virtual const DiskMap& disks() const OVERRIDE { return disks_; }
799 virtual const MountPointMap& mount_points() const OVERRIDE { 831 virtual const MountPointMap& mount_points() const OVERRIDE {
800 return mount_points_; 832 return mount_points_;
801 } 833 }
802 virtual void RequestMountInfoRefresh() OVERRIDE {} 834 virtual void RequestMountInfoRefresh() OVERRIDE {}
803 virtual void MountPath(const char* source_path, MountType type, 835 virtual void MountPath(const char* source_path, MountType type,
804 const MountPathOptions& options) OVERRIDE {} 836 const MountPathOptions& options) OVERRIDE {}
805 virtual void UnmountPath(const char* mount_path) OVERRIDE {} 837 virtual void UnmountPath(const char* mount_path) OVERRIDE {}
838 virtual void GetSizeStats(const char* mount_path,
839 CallbackDelegate* callback_delegate) OVERRIDE {}
806 virtual void FormatUnmountedDevice(const char* device_path) OVERRIDE {} 840 virtual void FormatUnmountedDevice(const char* device_path) OVERRIDE {}
807 virtual void FormatMountedDevice(const char* mount_path) OVERRIDE {} 841 virtual void FormatMountedDevice(const char* mount_path) OVERRIDE {}
808 virtual void UnmountDeviceRecursive(const char* device_path, 842 virtual void UnmountDeviceRecursive(const char* device_path,
809 UnmountDeviceRecursiveCallbackType callback, void* user_data) 843 UnmountDeviceRecursiveCallbackType callback, void* user_data)
810 OVERRIDE {} 844 OVERRIDE {}
811 private: 845 private:
812 // The list of disks found. 846 // The list of disks found.
813 DiskMap disks_; 847 DiskMap disks_;
814 MountPointMap mount_points_; 848 MountPointMap mount_points_;
815 849
816 DISALLOW_COPY_AND_ASSIGN(MountLibraryStubImpl); 850 DISALLOW_COPY_AND_ASSIGN(MountLibraryStubImpl);
817 }; 851 };
818 852
819 // static 853 // static
820 MountLibrary* MountLibrary::GetImpl(bool stub) { 854 MountLibrary* MountLibrary::GetImpl(bool stub) {
821 if (stub) 855 if (stub)
822 return new MountLibraryStubImpl(); 856 return new MountLibraryStubImpl();
823 else 857 else
824 return new MountLibraryImpl(); 858 return new MountLibraryImpl();
825 } 859 }
826 860
827 } // namespace chromeos 861 } // namespace chromeos
828 862
829 // Allows InvokeLater without adding refcounting. This class is a Singleton and 863 // Allows InvokeLater without adding refcounting. This class is a Singleton and
830 // won't be deleted until it's last InvokeLater is run. 864 // won't be deleted until it's last InvokeLater is run.
831 DISABLE_RUNNABLE_METHOD_REFCOUNT(chromeos::MountLibraryImpl); 865 DISABLE_RUNNABLE_METHOD_REFCOUNT(chromeos::MountLibraryImpl);
832 866
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698