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 2cd65da083177b01e0b0484afcc2b369ffd44fc7..5abf096d3d1f78ba44a71352f733e08781b4b611 100644 |
| --- a/chrome/browser/extensions/extension_file_browser_private_api.cc |
| +++ b/chrome/browser/extensions/extension_file_browser_private_api.cc |
| @@ -1277,6 +1277,80 @@ bool GetMountPointsFunction::RunImpl() { |
| return true; |
| } |
| +GetSizeStatsFunction::GetSizeStatsFunction() { |
| +} |
| + |
| +GetSizeStatsFunction::~GetSizeStatsFunction() { |
| +} |
| + |
| +void GetSizeStatsFunction::CallGetSizeStatsOnFileThread( |
| + const char* 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); |
| +#endif |
|
rginda
2011/09/06 21:38:58
Is this supposed to fall through to the PostTask,
tonibarzic
2011/09/06 21:45:32
it's supposed to fall through..
|
| + |
| + BrowserThread::PostTask( |
| + BrowserThread::UI, FROM_HERE, |
| + NewRunnableMethod(this, |
| + &GetSizeStatsFunction::GetSizeStatsCallbackOnUIThread, |
| + mount_path, total_size_kb, remaining_size_kb)); |
| +} |
| + |
| +void GetSizeStatsFunction::GetSizeStatsCallbackOnUIThread( |
| + const char* mount_path, size_t total_size_kb, size_t remaining_size_kb) { |
| + DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
| + |
| + base::DictionaryValue* sizes = new base::DictionaryValue(); |
| + result_.reset(sizes); |
| + |
| + sizes->SetInteger("totalSizeKB", total_size_kb); |
| + sizes->SetInteger("remainingSizeKB", remaining_size_kb); |
| + |
| + SendResponse(true); |
| +} |
| + |
| +bool GetSizeStatsFunction::RunImpl() { |
| + if (args_->GetSize() != 1) { |
| + return false; |
| + } |
| + |
| + std::string mount_url; |
| + if (!args_->GetString(0, &mount_url)) |
| + return false; |
| + |
| + UrlList mount_paths; |
| + mount_paths.push_back(GURL(mount_url)); |
| + |
| + BrowserThread::PostTask( |
| + BrowserThread::FILE, FROM_HERE, |
| + NewRunnableMethod(this, |
| + &GetSizeStatsFunction::GetLocalPathsOnFileThread, |
| + mount_paths, reinterpret_cast<void*>(NULL))); |
| + return true; |
| +} |
| + |
| +void GetSizeStatsFunction::GetLocalPathsResponseOnUIThread( |
| + const FilePathList& files, void* context) { |
| + DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
| + |
| + if (files.size() != 1) { |
| + SendResponse(false); |
| + return; |
| + } |
| + |
| + BrowserThread::PostTask( |
| + BrowserThread::FILE, FROM_HERE, |
| + NewRunnableMethod(this, |
| + &GetSizeStatsFunction::CallGetSizeStatsOnFileThread, |
| + files[0].value().c_str())); |
| + return; |
| +} |
| + |
| FormatDeviceFunction::FormatDeviceFunction() { |
| } |