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

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: 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 1259 matching lines...) Expand 10 before | Expand all | Expand 10 after
1270 it != mount_points.end(); 1270 it != mount_points.end();
1271 ++it) { 1271 ++it) {
1272 mounts->Append(MountPointToValue(profile_, it->second)); 1272 mounts->Append(MountPointToValue(profile_, it->second));
1273 } 1273 }
1274 #endif 1274 #endif
1275 1275
1276 SendResponse(true); 1276 SendResponse(true);
1277 return true; 1277 return true;
1278 } 1278 }
1279 1279
1280 GetSizeStatsFunction::GetSizeStatsFunction() {
1281 }
1282
1283 GetSizeStatsFunction::~GetSizeStatsFunction() {
1284 }
1285
1286 #ifdef OS_CHROMEOS
1287 void GetSizeStatsFunction::GetSizeStatsCallback(const char* mount_path,
1288 bool success, size_t total_size_kb, size_t remaining_size_kb) {
1289 if (!success) {
1290 SendResponse(false);
1291 return;
1292 }
1293
1294 base::DictionaryValue* sizes = new base::DictionaryValue();
1295 result_.reset(sizes);
1296
1297 sizes->SetInteger("totalSizeKB", total_size_kb);
1298 sizes->SetInteger("remainingSizeKB", remaining_size_kb);
1299
1300 SendResponse(true);
1301
1302 Release(); // Balances the AddRef taken in GetLocalPathsOnUIThread.
1303 }
1304 #endif
1305
1306 bool GetSizeStatsFunction::RunImpl() {
1307 if (args_->GetSize() != 1) {
1308 return false;
1309 }
1310
1311 std::string mount_url;
1312 if (!args_->GetString(0, &mount_url)) {
zel 2011/09/02 21:37:34 nit: no {}
tonibarzic 2011/09/02 21:59:01 Done.
1313 return false;
1314 }
1315
1316 UrlList mount_paths;
1317 mount_paths.push_back(GURL(mount_url));
1318
1319 BrowserThread::PostTask(
1320 BrowserThread::FILE, FROM_HERE,
1321 NewRunnableMethod(this,
1322 &GetSizeStatsFunction::GetLocalPathsOnFileThread,
1323 mount_paths, reinterpret_cast<void*>(NULL)));
1324 return true;
1325 }
1326
1327 void GetSizeStatsFunction::GetLocalPathsResponseOnUIThread(
1328 const FilePathList& files, void* context) {
1329 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
1330
1331 if (files.size() != 1) {
1332 SendResponse(false);
1333 return;
1334 }
1335
1336 #ifdef OS_CHROMEOS
1337 chromeos::CrosLibrary::Get()->GetMountLibrary()->GetSizeStats(
1338 files[0].value().c_str(), this /*MountLibrary::CallbackDelegate*/);
1339 AddRef(); // Balanced by the Release in GetSizeStatsCallback.
1340 return;
1341 #endif
1342
1343 // If we are not on ChromeOs, respond false.
1344 SendResponse(false);
1345 }
1346
1280 FormatDeviceFunction::FormatDeviceFunction() { 1347 FormatDeviceFunction::FormatDeviceFunction() {
1281 } 1348 }
1282 1349
1283 FormatDeviceFunction::~FormatDeviceFunction() { 1350 FormatDeviceFunction::~FormatDeviceFunction() {
1284 } 1351 }
1285 1352
1286 bool FormatDeviceFunction::RunImpl() { 1353 bool FormatDeviceFunction::RunImpl() {
1287 if (args_->GetSize() != 1) { 1354 if (args_->GetSize() != 1) {
1288 return false; 1355 return false;
1289 } 1356 }
(...skipping 244 matching lines...) Expand 10 before | Expand all | Expand 10 after
1534 // TODO(serya): Create a new string in .grd file for this one in M13. 1601 // TODO(serya): Create a new string in .grd file for this one in M13.
1535 dict->SetString("PREVIEW_IMAGE", 1602 dict->SetString("PREVIEW_IMAGE",
1536 l10n_util::GetStringUTF16(IDS_CERT_MANAGER_VIEW_CERT_BUTTON)); 1603 l10n_util::GetStringUTF16(IDS_CERT_MANAGER_VIEW_CERT_BUTTON));
1537 dict->SetString("PLAY_MEDIA", 1604 dict->SetString("PLAY_MEDIA",
1538 l10n_util::GetStringUTF16(IDS_CONTENT_CONTEXT_PLAY)); 1605 l10n_util::GetStringUTF16(IDS_CONTENT_CONTEXT_PLAY));
1539 if (CommandLine::ForCurrentProcess()->HasSwitch(switches::kEnableArchives)) 1606 if (CommandLine::ForCurrentProcess()->HasSwitch(switches::kEnableArchives))
1540 dict->SetString("ENABLE_ARCHIVES", "true"); 1607 dict->SetString("ENABLE_ARCHIVES", "true");
1541 1608
1542 return true; 1609 return true;
1543 } 1610 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698