Chromium Code Reviews| Index: chrome/browser/extensions/extension_file_browser_private_api.cc |
| diff --git a/chrome/browser/extensions/extension_file_browser_private_api.cc b/chrome/browser/extensions/extension_file_browser_private_api.cc |
| index 05f1988551e27a183eaef0c672bc8de938627b15..82c065661cede3a90a049060838e349aa38c23e1 100644 |
| --- a/chrome/browser/extensions/extension_file_browser_private_api.cc |
| +++ b/chrome/browser/extensions/extension_file_browser_private_api.cc |
| @@ -50,10 +50,6 @@ |
| #include "webkit/fileapi/file_system_types.h" |
| #include "webkit/fileapi/file_system_util.h" |
| -#ifdef OS_CHROMEOS |
| -#include "chrome/browser/chromeos/cros/cros_library.h" |
| -#endif |
| - |
| using content::BrowserThread; |
| // Error messages. |
| @@ -267,12 +263,13 @@ void UpdateFileHandlerUsageStats(Profile* profile, const std::string& task_id) { |
| #ifdef OS_CHROMEOS |
| base::DictionaryValue* MountPointToValue(Profile* profile, |
| - const chromeos::MountLibrary::MountPointInfo& mount_point_info) { |
| + const chromeos::disks::DiskMountManager::MountPointInfo& mount_point_info) { |
| base::DictionaryValue *mount_info = new base::DictionaryValue(); |
| mount_info->SetString("mountType", |
| - chromeos::MountLibrary::MountTypeToString(mount_point_info.mount_type)); |
| + chromeos::disks::DiskMountManager::MountTypeToString( |
| + mount_point_info.mount_type)); |
| if (mount_point_info.mount_type == chromeos::MOUNT_TYPE_ARCHIVE) { |
| GURL source_url; |
| @@ -296,7 +293,7 @@ base::DictionaryValue* MountPointToValue(Profile* profile, |
| } |
| mount_info->SetString("mountCondition", |
| - chromeos::MountLibrary::MountConditionToString( |
| + chromeos::disks::DiskMountManager::MountConditionToString( |
| mount_point_info.mount_condition)); |
| return mount_info; |
| @@ -1191,6 +1188,7 @@ AddMountFunction::~AddMountFunction() { |
| } |
| bool AddMountFunction::RunImpl() { |
| + // The third argument is simply ignored. |
|
hashimoto
2011/11/15 12:39:25
MountPathOptions declared in chromeos_mount.h is n
tbarzic
2011/11/15 19:52:38
it's not yet used (this will be needed for network
satorux1
2011/11/15 21:20:24
Let's add it back when needed. :) Hopefully this c
|
| if (args_->GetSize() != 2 && args_->GetSize() != 3) { |
| error_ = "Invalid argument count"; |
| return false; |
| @@ -1210,33 +1208,12 @@ bool AddMountFunction::RunImpl() { |
| file_paths.push_back(GURL(file_url)); |
| #if defined(OS_CHROMEOS) |
| - chromeos::MountPathOptions options; |
| - if (args_->GetSize() == 3) { |
| - DictionaryValue *dict; |
| - if (!args_->GetDictionary(2, &dict)) { |
| - NOTREACHED(); |
| - } |
| - |
| - for (base::DictionaryValue::key_iterator it = dict->begin_keys(); |
| - it != dict->end_keys(); |
| - ++it) { |
| - std::string value; |
| - if (!dict->GetString(*it, &value)) { |
| - NOTREACHED(); |
| - } |
| - |
| - options.push_back(chromeos::MountPathOptions::value_type((*it).c_str(), |
| - value.c_str())); |
| - } |
| - } |
| - |
| - MountParamaters* params = new MountParamaters(mount_type_str, options); |
| + // |context| is deleted in GetLocalPathsResponseOnUIThread |
| + std::string* context = new std::string(mount_type_str); |
|
satorux1
2011/11/15 21:20:24
This void* context hack is ugly. I think you can r
hashimoto
2011/11/16 04:28:15
Done.
|
| BrowserThread::PostTask( |
| BrowserThread::FILE, FROM_HERE, |
| - base::Bind( |
| - &AddMountFunction::GetLocalPathsOnFileThread, |
| - this, |
| - file_paths, reinterpret_cast<void*>(params))); |
| + base::Bind(&AddMountFunction::GetLocalPathsOnFileThread, this, file_paths, |
| + context)); |
|
satorux1
2011/11/15 21:20:24
can you pass mount_type_str directly?
hashimoto
2011/11/16 04:28:15
Done.
|
| #endif // OS_CHROMEOS |
| return true; |
| @@ -1253,24 +1230,22 @@ void AddMountFunction::GetLocalPathsResponseOnUIThread( |
| } |
| #ifdef OS_CHROMEOS |
| - scoped_ptr<MountParamaters> params( |
| - reinterpret_cast<MountParamaters*>(context)); |
| - const std::string& mount_type_str = params->mount_type; |
| - const chromeos::MountPathOptions& options = params->mount_options; |
| + scoped_ptr<std::string> mount_type_str( |
| + reinterpret_cast<std::string*>(context)); |
| FilePath::StringType source_file = files[0].value(); |
| - chromeos::MountLibrary *mount_lib = |
| - chromeos::CrosLibrary::Get()->GetMountLibrary(); |
| + chromeos::disks::DiskMountManager* disk_mount_manager = |
| + chromeos::disks::DiskMountManager::GetInstance(); |
| chromeos::MountType mount_type = |
| - mount_lib->MountTypeFromString(mount_type_str); |
| + disk_mount_manager->MountTypeFromString(*mount_type_str); |
| if (mount_type == chromeos::MOUNT_TYPE_INVALID) { |
| error_ = "Invalid mount type"; |
| SendResponse(false); |
| return; |
| } |
| - mount_lib->MountPath(source_file.data(), mount_type, options); |
| + disk_mount_manager->MountPath(source_file.data(), mount_type); |
| #endif |
| SendResponse(true); |
| @@ -1313,8 +1288,8 @@ void RemoveMountFunction::GetLocalPathsResponseOnUIThread( |
| return; |
| } |
| #ifdef OS_CHROMEOS |
| - chromeos::CrosLibrary::Get()->GetMountLibrary()->UnmountPath( |
| - files[0].value().c_str()); |
| + chromeos::disks::DiskMountManager::GetInstance()->UnmountPath( |
| + files[0].value()); |
| #endif |
| SendResponse(true); |
| @@ -1334,12 +1309,12 @@ bool GetMountPointsFunction::RunImpl() { |
| result_.reset(mounts); |
| #ifdef OS_CHROMEOS |
| - chromeos::MountLibrary *mount_lib = |
| - chromeos::CrosLibrary::Get()->GetMountLibrary(); |
| - chromeos::MountLibrary::MountPointMap mount_points = |
| - mount_lib->mount_points(); |
| + chromeos::disks::DiskMountManager* disk_mount_manager = |
| + chromeos::disks::DiskMountManager::GetInstance(); |
| + chromeos::disks::DiskMountManager::MountPointMap mount_points = |
| + disk_mount_manager->mount_points(); |
| - for (chromeos::MountLibrary::MountPointMap::const_iterator it = |
| + for (chromeos::disks::DiskMountManager::MountPointMap::const_iterator it = |
| mount_points.begin(); |
| it != mount_points.end(); |
| ++it) { |
| @@ -1392,18 +1367,18 @@ void GetSizeStatsFunction::GetLocalPathsResponseOnUIThread( |
| base::Bind( |
| &GetSizeStatsFunction::CallGetSizeStatsOnFileThread, |
| this, |
| - files[0].value().c_str())); |
| + files[0].value())); |
| } |
| void GetSizeStatsFunction::CallGetSizeStatsOnFileThread( |
| - const char* mount_path) { |
| + const std::string& mount_path) { |
| DCHECK(BrowserThread::CurrentlyOn(BrowserThread::FILE)); |
| size_t total_size_kb = 0; |
| size_t remaining_size_kb = 0; |
| #ifdef OS_CHROMEOS |
| - chromeos::CrosLibrary::Get()->GetMountLibrary()->GetSizeStatsOnFileThread( |
| - mount_path, &total_size_kb, &remaining_size_kb); |
| + chromeos::disks::DiskMountManager::GetInstance()-> |
| + GetSizeStatsOnFileThread(mount_path, &total_size_kb, &remaining_size_kb); |
| #endif |
| BrowserThread::PostTask( |
| @@ -1415,7 +1390,9 @@ void GetSizeStatsFunction::CallGetSizeStatsOnFileThread( |
| } |
| void GetSizeStatsFunction::GetSizeStatsCallbackOnUIThread( |
| - const char* mount_path, size_t total_size_kb, size_t remaining_size_kb) { |
| + const std::string& mount_path, |
| + size_t total_size_kb, |
| + size_t remaining_size_kb) { |
| DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
| base::DictionaryValue* sizes = new base::DictionaryValue(); |
| @@ -1466,8 +1443,8 @@ void FormatDeviceFunction::GetLocalPathsResponseOnUIThread( |
| } |
| #ifdef OS_CHROMEOS |
| - chromeos::CrosLibrary::Get()->GetMountLibrary()->FormatMountedDevice( |
| - files[0].value().c_str()); |
| + chromeos::disks::DiskMountManager::GetInstance()->FormatMountedDevice( |
| + files[0].value()); |
| #endif |
| SendResponse(true); |
| @@ -1491,14 +1468,14 @@ bool GetVolumeMetadataFunction::RunImpl() { |
| } |
| #ifdef OS_CHROMEOS |
| - chromeos::MountLibrary* mount_lib = |
| - chromeos::CrosLibrary::Get()->GetMountLibrary(); |
| - chromeos::MountLibrary::DiskMap::const_iterator volume_it = |
| - mount_lib->disks().find(volume_device_path); |
| + chromeos::disks::DiskMountManager* disk_mount_manager = |
| + chromeos::disks::DiskMountManager::GetInstance(); |
| + chromeos::disks::DiskMountManager::DiskMap::const_iterator volume_it = |
| + disk_mount_manager->disks().find(volume_device_path); |
| - if (volume_it != mount_lib->disks().end() && |
| + if (volume_it != disk_mount_manager->disks().end() && |
| !volume_it->second->is_hidden()) { |
| - chromeos::MountLibrary::Disk* volume = volume_it->second; |
| + chromeos::disks::DiskMountManager::Disk* volume = volume_it->second; |
| DictionaryValue* volume_info = new DictionaryValue(); |
| result_.reset(volume_info); |
| // Localising mount path. |
| @@ -1517,7 +1494,7 @@ bool GetVolumeMetadataFunction::RunImpl() { |
| volume_info->SetString("driveLabel", volume->drive_label()); |
| volume_info->SetString("deviceType", |
| DeviceTypeToString(volume->device_type())); |
| - volume_info->SetInteger("totalSize", volume->total_size()); |
| + volume_info->SetInteger("totalSize", volume->total_size_in_bytes()); |
| volume_info->SetBoolean("isParent", volume->is_parent()); |
| volume_info->SetBoolean("isReadOnly", volume->is_read_only()); |
| volume_info->SetBoolean("hasMedia", volume->has_media()); |