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

Side by Side Diff: chrome/browser/extensions/extension_file_browser_private_api.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: a 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/extensions/extension_file_browser_private_api.h" 5 #include "chrome/browser/extensions/extension_file_browser_private_api.h"
6 6
7 #include "base/base64.h" 7 #include "base/base64.h"
8 #include "base/command_line.h" 8 #include "base/command_line.h"
9 #include "base/json/json_writer.h" 9 #include "base/json/json_writer.h"
10 #include "base/logging.h" 10 #include "base/logging.h"
(...skipping 1297 matching lines...) Expand 10 before | Expand all | Expand 10 after
1308 it != mount_points.end(); 1308 it != mount_points.end();
1309 ++it) { 1309 ++it) {
1310 mounts->Append(MountPointToValue(profile_, it->second)); 1310 mounts->Append(MountPointToValue(profile_, it->second));
1311 } 1311 }
1312 #endif 1312 #endif
1313 1313
1314 SendResponse(true); 1314 SendResponse(true);
1315 return true; 1315 return true;
1316 } 1316 }
1317 1317
1318 GetSizeStatsFunction::GetSizeStatsFunction() {
1319 }
1320
1321 GetSizeStatsFunction::~GetSizeStatsFunction() {
1322 }
1323
1324 bool GetSizeStatsFunction::RunImpl() {
1325 if (args_->GetSize() != 1) {
1326 return false;
1327 }
1328
1329 std::string mount_url;
1330 if (!args_->GetString(0, &mount_url))
1331 return false;
1332
1333 UrlList mount_paths;
1334 mount_paths.push_back(GURL(mount_url));
1335
1336 BrowserThread::PostTask(
1337 BrowserThread::FILE, FROM_HERE,
1338 NewRunnableMethod(this,
1339 &GetSizeStatsFunction::GetLocalPathsOnFileThread,
1340 mount_paths, reinterpret_cast<void*>(NULL)));
1341 return true;
1342 }
1343
1344 void GetSizeStatsFunction::GetLocalPathsResponseOnUIThread(
1345 const FilePathList& files, void* context) {
1346 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
1347
1348 if (files.size() != 1) {
1349 SendResponse(false);
1350 return;
1351 }
1352
1353 BrowserThread::PostTask(
1354 BrowserThread::FILE, FROM_HERE,
1355 NewRunnableMethod(this,
1356 &GetSizeStatsFunction::CallGetSizeStatsOnFileThread,
1357 files[0].value().c_str()));
1358 }
1359
1360 void GetSizeStatsFunction::CallGetSizeStatsOnFileThread(
1361 const char* mount_path) {
1362 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::FILE));
1363
1364 size_t total_size_kb = 0;
1365 size_t remaining_size_kb = 0;
1366 #ifdef OS_CHROMEOS
1367 chromeos::CrosLibrary::Get()->GetMountLibrary()->GetSizeStatsOnFileThread(
1368 mount_path, &total_size_kb, &remaining_size_kb);
1369 #endif
1370
1371 BrowserThread::PostTask(
1372 BrowserThread::UI, FROM_HERE,
1373 NewRunnableMethod(this,
1374 &GetSizeStatsFunction::GetSizeStatsCallbackOnUIThread,
1375 mount_path, total_size_kb, remaining_size_kb));
1376 }
1377
1378 void GetSizeStatsFunction::GetSizeStatsCallbackOnUIThread(
1379 const char* mount_path, size_t total_size_kb, size_t remaining_size_kb) {
1380 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
1381
1382 base::DictionaryValue* sizes = new base::DictionaryValue();
1383 result_.reset(sizes);
1384
1385 sizes->SetInteger("totalSizeKB", total_size_kb);
1386 sizes->SetInteger("remainingSizeKB", remaining_size_kb);
1387
1388 SendResponse(true);
1389 }
1390
1318 FormatDeviceFunction::FormatDeviceFunction() { 1391 FormatDeviceFunction::FormatDeviceFunction() {
1319 } 1392 }
1320 1393
1321 FormatDeviceFunction::~FormatDeviceFunction() { 1394 FormatDeviceFunction::~FormatDeviceFunction() {
1322 } 1395 }
1323 1396
1324 bool FormatDeviceFunction::RunImpl() { 1397 bool FormatDeviceFunction::RunImpl() {
1325 if (args_->GetSize() != 1) { 1398 if (args_->GetSize() != 1) {
1326 return false; 1399 return false;
1327 } 1400 }
(...skipping 246 matching lines...) Expand 10 before | Expand all | Expand 10 after
1574 // TODO(serya): Create a new string in .grd file for this one in M13. 1647 // TODO(serya): Create a new string in .grd file for this one in M13.
1575 dict->SetString("PREVIEW_IMAGE", 1648 dict->SetString("PREVIEW_IMAGE",
1576 l10n_util::GetStringUTF16(IDS_CERT_MANAGER_VIEW_CERT_BUTTON)); 1649 l10n_util::GetStringUTF16(IDS_CERT_MANAGER_VIEW_CERT_BUTTON));
1577 dict->SetString("PLAY_MEDIA", 1650 dict->SetString("PLAY_MEDIA",
1578 l10n_util::GetStringUTF16(IDS_CONTENT_CONTEXT_PLAY)); 1651 l10n_util::GetStringUTF16(IDS_CONTENT_CONTEXT_PLAY));
1579 if (CommandLine::ForCurrentProcess()->HasSwitch(switches::kEnableArchives)) 1652 if (CommandLine::ForCurrentProcess()->HasSwitch(switches::kEnableArchives))
1580 dict->SetString("ENABLE_ARCHIVES", "true"); 1653 dict->SetString("ENABLE_ARCHIVES", "true");
1581 1654
1582 return true; 1655 return true;
1583 } 1656 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698