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

Side by Side Diff: chrome/browser/extensions/api/downloads/downloads_api.cc

Issue 2252233002: Make downloads_api functions synchronous (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: disable tests on chrome os Created 4 years, 4 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
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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/api/downloads/downloads_api.h" 5 #include "chrome/browser/extensions/api/downloads/downloads_api.h"
6 6
7 #include <stddef.h> 7 #include <stddef.h>
8 #include <stdint.h> 8 #include <stdint.h>
9 #include <memory> 9 #include <memory>
10 #include <set> 10 #include <set>
(...skipping 1305 matching lines...) Expand 10 before | Expand all | Expand 10 after
1316 case DownloadDangerPrompt::DISMISS: 1316 case DownloadDangerPrompt::DISMISS:
1317 break; 1317 break;
1318 } 1318 }
1319 SendResponse(error_.empty()); 1319 SendResponse(error_.empty());
1320 } 1320 }
1321 1321
1322 DownloadsShowFunction::DownloadsShowFunction() {} 1322 DownloadsShowFunction::DownloadsShowFunction() {}
1323 1323
1324 DownloadsShowFunction::~DownloadsShowFunction() {} 1324 DownloadsShowFunction::~DownloadsShowFunction() {}
1325 1325
1326 bool DownloadsShowFunction::RunAsync() { 1326 bool DownloadsShowFunction::RunSync() {
1327 std::unique_ptr<downloads::Show::Params> params( 1327 std::unique_ptr<downloads::Show::Params> params(
1328 downloads::Show::Params::Create(*args_)); 1328 downloads::Show::Params::Create(*args_));
1329 EXTENSION_FUNCTION_VALIDATE(params.get()); 1329 EXTENSION_FUNCTION_VALIDATE(params.get());
1330 DownloadItem* download_item = 1330 DownloadItem* download_item =
1331 GetDownload(GetProfile(), include_incognito(), params->download_id); 1331 GetDownload(GetProfile(), include_incognito(), params->download_id);
1332 if (InvalidId(download_item, &error_)) 1332 if (InvalidId(download_item, &error_))
1333 return false; 1333 return false;
1334 download_item->ShowDownloadInShell(); 1334 download_item->ShowDownloadInShell();
1335 RecordApiFunctions(DOWNLOADS_FUNCTION_SHOW); 1335 RecordApiFunctions(DOWNLOADS_FUNCTION_SHOW);
1336 return true; 1336 return true;
1337 } 1337 }
1338 1338
1339 DownloadsShowDefaultFolderFunction::DownloadsShowDefaultFolderFunction() {} 1339 DownloadsShowDefaultFolderFunction::DownloadsShowDefaultFolderFunction() {}
1340 1340
1341 DownloadsShowDefaultFolderFunction::~DownloadsShowDefaultFolderFunction() {} 1341 DownloadsShowDefaultFolderFunction::~DownloadsShowDefaultFolderFunction() {}
1342 1342
1343 bool DownloadsShowDefaultFolderFunction::RunAsync() { 1343 bool DownloadsShowDefaultFolderFunction::RunSync() {
1344 DownloadManager* manager = NULL; 1344 DownloadManager* manager = NULL;
1345 DownloadManager* incognito_manager = NULL; 1345 DownloadManager* incognito_manager = NULL;
1346 GetManagers(GetProfile(), include_incognito(), &manager, &incognito_manager); 1346 GetManagers(GetProfile(), include_incognito(), &manager, &incognito_manager);
1347 platform_util::OpenItem( 1347 platform_util::OpenItem(
1348 GetProfile(), DownloadPrefs::FromDownloadManager(manager)->DownloadPath(), 1348 GetProfile(), DownloadPrefs::FromDownloadManager(manager)->DownloadPath(),
1349 platform_util::OPEN_FOLDER, platform_util::OpenOperationCallback()); 1349 platform_util::OPEN_FOLDER, platform_util::OpenOperationCallback());
1350 RecordApiFunctions(DOWNLOADS_FUNCTION_SHOW_DEFAULT_FOLDER); 1350 RecordApiFunctions(DOWNLOADS_FUNCTION_SHOW_DEFAULT_FOLDER);
1351 return true; 1351 return true;
1352 } 1352 }
1353 1353
(...skipping 19 matching lines...) Expand all
1373 return false; 1373 return false;
1374 download_item->OpenDownload(); 1374 download_item->OpenDownload();
1375 RecordApiFunctions(DOWNLOADS_FUNCTION_OPEN); 1375 RecordApiFunctions(DOWNLOADS_FUNCTION_OPEN);
1376 return true; 1376 return true;
1377 } 1377 }
1378 1378
1379 DownloadsDragFunction::DownloadsDragFunction() {} 1379 DownloadsDragFunction::DownloadsDragFunction() {}
1380 1380
1381 DownloadsDragFunction::~DownloadsDragFunction() {} 1381 DownloadsDragFunction::~DownloadsDragFunction() {}
1382 1382
1383 bool DownloadsDragFunction::RunAsync() { 1383 bool DownloadsDragFunction::RunSync() {
1384 std::unique_ptr<downloads::Drag::Params> params( 1384 std::unique_ptr<downloads::Drag::Params> params(
1385 downloads::Drag::Params::Create(*args_)); 1385 downloads::Drag::Params::Create(*args_));
1386 EXTENSION_FUNCTION_VALIDATE(params.get()); 1386 EXTENSION_FUNCTION_VALIDATE(params.get());
1387 DownloadItem* download_item = 1387 DownloadItem* download_item =
1388 GetDownload(GetProfile(), include_incognito(), params->download_id); 1388 GetDownload(GetProfile(), include_incognito(), params->download_id);
1389 content::WebContents* web_contents = 1389 content::WebContents* web_contents =
1390 dispatcher()->GetVisibleWebContents(); 1390 dispatcher()->GetVisibleWebContents();
1391 if (InvalidId(download_item, &error_) || 1391 if (InvalidId(download_item, &error_) ||
1392 Fault(!web_contents, errors::kInvisibleContext, &error_)) 1392 Fault(!web_contents, errors::kInvisibleContext, &error_))
1393 return false; 1393 return false;
(...skipping 517 matching lines...) Expand 10 before | Expand all | Expand 10 after
1911 return; 1911 return;
1912 base::Time now(base::Time::Now()); 1912 base::Time now(base::Time::Now());
1913 int delta = now.ToTimeT() - last_checked_removal_.ToTimeT(); 1913 int delta = now.ToTimeT() - last_checked_removal_.ToTimeT();
1914 if (delta <= kFileExistenceRateLimitSeconds) 1914 if (delta <= kFileExistenceRateLimitSeconds)
1915 return; 1915 return;
1916 last_checked_removal_ = now; 1916 last_checked_removal_ = now;
1917 manager->CheckForHistoryFilesRemoval(); 1917 manager->CheckForHistoryFilesRemoval();
1918 } 1918 }
1919 1919
1920 } // namespace extensions 1920 } // namespace extensions
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698