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

Unified Diff: chrome/browser/extensions/api/downloads/downloads_api.cc

Issue 1871713002: Convert //chrome/browser/extensions from scoped_ptr to std::unique_ptr (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Rebase and fix header Created 4 years, 8 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 side-by-side diff with in-line comments
Download patch
Index: chrome/browser/extensions/api/downloads/downloads_api.cc
diff --git a/chrome/browser/extensions/api/downloads/downloads_api.cc b/chrome/browser/extensions/api/downloads/downloads_api.cc
index a765a0e4a9d5cd508b24470d6ef85855e75f3582..7c87a6f10c9cd44df4046e405e3c6f6b57d1a773 100644
--- a/chrome/browser/extensions/api/downloads/downloads_api.cc
+++ b/chrome/browser/extensions/api/downloads/downloads_api.cc
@@ -245,7 +245,7 @@ std::string TimeToISO8601(const base::Time& t) {
exploded.millisecond);
}
-scoped_ptr<base::DictionaryValue> DownloadItemToJSON(
+std::unique_ptr<base::DictionaryValue> DownloadItemToJSON(
DownloadItem* download_item,
Profile* profile) {
base::DictionaryValue* json = new base::DictionaryValue();
@@ -298,7 +298,7 @@ scoped_ptr<base::DictionaryValue> DownloadItemToJSON(
}
// TODO(benjhayden): Implement fileSize.
json->SetDouble(kFileSizeKey, download_item->GetTotalBytes());
- return scoped_ptr<base::DictionaryValue>(json);
+ return std::unique_ptr<base::DictionaryValue>(json);
}
class DownloadFileIconExtractorImpl : public DownloadFileIconExtractor {
@@ -540,7 +540,7 @@ void RunDownloadQuery(
return;
}
- scoped_ptr<base::DictionaryValue> query_in_value(query_in.ToValue());
+ std::unique_ptr<base::DictionaryValue> query_in_value(query_in.ToValue());
for (base::DictionaryValue::Iterator query_json_field(*query_in_value.get());
!query_json_field.IsAtEnd(); query_json_field.Advance()) {
FilterTypeMap::const_iterator filter_type =
@@ -598,7 +598,7 @@ class ExtensionDownloadsEventRouterData : public base::SupportsUserData::Data {
explicit ExtensionDownloadsEventRouterData(
DownloadItem* download_item,
- scoped_ptr<base::DictionaryValue> json_item)
+ std::unique_ptr<base::DictionaryValue> json_item)
: updated_(0),
changed_fired_(0),
json_(std::move(json_item)),
@@ -617,7 +617,7 @@ class ExtensionDownloadsEventRouterData : public base::SupportsUserData::Data {
}
const base::DictionaryValue& json() const { return *json_.get(); }
- void set_json(scoped_ptr<base::DictionaryValue> json_item) {
+ void set_json(std::unique_ptr<base::DictionaryValue> json_item) {
json_ = std::move(json_item);
}
@@ -836,7 +836,7 @@ class ExtensionDownloadsEventRouterData : public base::SupportsUserData::Data {
int updated_;
int changed_fired_;
- scoped_ptr<base::DictionaryValue> json_;
+ std::unique_ptr<base::DictionaryValue> json_;
base::Closure filename_no_change_;
ExtensionDownloadsEventRouter::FilenameChangedCallback filename_change_;
@@ -851,8 +851,8 @@ class ExtensionDownloadsEventRouterData : public base::SupportsUserData::Data {
determined_conflict_action_;
DeterminerInfo determiner_;
- scoped_ptr<base::WeakPtrFactory<ExtensionDownloadsEventRouterData> >
- weak_ptr_factory_;
+ std::unique_ptr<base::WeakPtrFactory<ExtensionDownloadsEventRouterData>>
+ weak_ptr_factory_;
DISALLOW_COPY_AND_ASSIGN(ExtensionDownloadsEventRouterData);
};
@@ -945,7 +945,7 @@ DownloadsDownloadFunction::DownloadsDownloadFunction() {}
DownloadsDownloadFunction::~DownloadsDownloadFunction() {}
bool DownloadsDownloadFunction::RunAsync() {
- scoped_ptr<downloads::Download::Params> params(
+ std::unique_ptr<downloads::Download::Params> params(
downloads::Download::Params::Create(*args_));
EXTENSION_FUNCTION_VALIDATE(params.get());
const downloads::DownloadOptions& options = params->options;
@@ -957,7 +957,7 @@ bool DownloadsDownloadFunction::RunAsync() {
if (include_incognito() && GetProfile()->HasOffTheRecordProfile())
current_profile = GetProfile()->GetOffTheRecordProfile();
- scoped_ptr<content::DownloadUrlParameters> download_params(
+ std::unique_ptr<content::DownloadUrlParameters> download_params(
new content::DownloadUrlParameters(
download_url, render_frame_host()->GetProcess()->GetID(),
render_view_host_do_not_use()->GetRoutingID(),
@@ -1042,8 +1042,8 @@ void DownloadsDownloadFunction::OnStarted(
ExtensionDownloadsEventRouterData::Get(item);
if (!data) {
data = new ExtensionDownloadsEventRouterData(
- item,
- scoped_ptr<base::DictionaryValue>(new base::DictionaryValue()));
+ item, std::unique_ptr<base::DictionaryValue>(
+ new base::DictionaryValue()));
}
data->CreatorSuggestedFilename(
creator_suggested_filename, creator_conflict_action);
@@ -1062,7 +1062,7 @@ DownloadsSearchFunction::DownloadsSearchFunction() {}
DownloadsSearchFunction::~DownloadsSearchFunction() {}
bool DownloadsSearchFunction::RunSync() {
- scoped_ptr<downloads::Search::Params> params(
+ std::unique_ptr<downloads::Search::Params> params(
downloads::Search::Params::Create(*args_));
EXTENSION_FUNCTION_VALIDATE(params.get());
DownloadManager* manager = NULL;
@@ -1094,10 +1094,9 @@ bool DownloadsSearchFunction::RunSync() {
uint32_t download_id = download_item->GetId();
bool off_record = ((incognito_manager != NULL) &&
(incognito_manager->GetDownload(download_id) != NULL));
- scoped_ptr<base::DictionaryValue> json_item(
- DownloadItemToJSON(*it,
- off_record ? GetProfile()->GetOffTheRecordProfile()
- : GetProfile()->GetOriginalProfile()));
+ std::unique_ptr<base::DictionaryValue> json_item(DownloadItemToJSON(
+ *it, off_record ? GetProfile()->GetOffTheRecordProfile()
+ : GetProfile()->GetOriginalProfile()));
json_results->Append(json_item.release());
}
SetResult(json_results);
@@ -1110,7 +1109,7 @@ DownloadsPauseFunction::DownloadsPauseFunction() {}
DownloadsPauseFunction::~DownloadsPauseFunction() {}
bool DownloadsPauseFunction::RunSync() {
- scoped_ptr<downloads::Pause::Params> params(
+ std::unique_ptr<downloads::Pause::Params> params(
downloads::Pause::Params::Create(*args_));
EXTENSION_FUNCTION_VALIDATE(params.get());
DownloadItem* download_item =
@@ -1131,7 +1130,7 @@ DownloadsResumeFunction::DownloadsResumeFunction() {}
DownloadsResumeFunction::~DownloadsResumeFunction() {}
bool DownloadsResumeFunction::RunSync() {
- scoped_ptr<downloads::Resume::Params> params(
+ std::unique_ptr<downloads::Resume::Params> params(
downloads::Resume::Params::Create(*args_));
EXTENSION_FUNCTION_VALIDATE(params.get());
DownloadItem* download_item =
@@ -1152,7 +1151,7 @@ DownloadsCancelFunction::DownloadsCancelFunction() {}
DownloadsCancelFunction::~DownloadsCancelFunction() {}
bool DownloadsCancelFunction::RunSync() {
- scoped_ptr<downloads::Resume::Params> params(
+ std::unique_ptr<downloads::Resume::Params> params(
downloads::Resume::Params::Create(*args_));
EXTENSION_FUNCTION_VALIDATE(params.get());
DownloadItem* download_item =
@@ -1171,7 +1170,7 @@ DownloadsEraseFunction::DownloadsEraseFunction() {}
DownloadsEraseFunction::~DownloadsEraseFunction() {}
bool DownloadsEraseFunction::RunSync() {
- scoped_ptr<downloads::Erase::Params> params(
+ std::unique_ptr<downloads::Erase::Params> params(
downloads::Erase::Params::Create(*args_));
EXTENSION_FUNCTION_VALIDATE(params.get());
DownloadManager* manager = NULL;
@@ -1204,7 +1203,7 @@ DownloadsRemoveFileFunction::~DownloadsRemoveFileFunction() {
}
bool DownloadsRemoveFileFunction::RunAsync() {
- scoped_ptr<downloads::RemoveFile::Params> params(
+ std::unique_ptr<downloads::RemoveFile::Params> params(
downloads::RemoveFile::Params::Create(*args_));
EXTENSION_FUNCTION_VALIDATE(params.get());
DownloadItem* download_item =
@@ -1237,7 +1236,7 @@ DownloadsAcceptDangerFunction::OnPromptCreatedCallback*
DownloadsAcceptDangerFunction::on_prompt_created_ = NULL;
bool DownloadsAcceptDangerFunction::RunAsync() {
- scoped_ptr<downloads::AcceptDanger::Params> params(
+ std::unique_ptr<downloads::AcceptDanger::Params> params(
downloads::AcceptDanger::Params::Create(*args_));
EXTENSION_FUNCTION_VALIDATE(params.get());
PromptOrWait(params->download_id, 10);
@@ -1311,7 +1310,7 @@ DownloadsShowFunction::DownloadsShowFunction() {}
DownloadsShowFunction::~DownloadsShowFunction() {}
bool DownloadsShowFunction::RunAsync() {
- scoped_ptr<downloads::Show::Params> params(
+ std::unique_ptr<downloads::Show::Params> params(
downloads::Show::Params::Create(*args_));
EXTENSION_FUNCTION_VALIDATE(params.get());
DownloadItem* download_item =
@@ -1343,7 +1342,7 @@ DownloadsOpenFunction::DownloadsOpenFunction() {}
DownloadsOpenFunction::~DownloadsOpenFunction() {}
bool DownloadsOpenFunction::RunSync() {
- scoped_ptr<downloads::Open::Params> params(
+ std::unique_ptr<downloads::Open::Params> params(
downloads::Open::Params::Create(*args_));
EXTENSION_FUNCTION_VALIDATE(params.get());
DownloadItem* download_item =
@@ -1368,7 +1367,7 @@ DownloadsDragFunction::DownloadsDragFunction() {}
DownloadsDragFunction::~DownloadsDragFunction() {}
bool DownloadsDragFunction::RunAsync() {
- scoped_ptr<downloads::Drag::Params> params(
+ std::unique_ptr<downloads::Drag::Params> params(
downloads::Drag::Params::Create(*args_));
EXTENSION_FUNCTION_VALIDATE(params.get());
DownloadItem* download_item =
@@ -1396,7 +1395,7 @@ DownloadsSetShelfEnabledFunction::DownloadsSetShelfEnabledFunction() {}
DownloadsSetShelfEnabledFunction::~DownloadsSetShelfEnabledFunction() {}
bool DownloadsSetShelfEnabledFunction::RunSync() {
- scoped_ptr<downloads::SetShelfEnabled::Params> params(
+ std::unique_ptr<downloads::SetShelfEnabled::Params> params(
downloads::SetShelfEnabled::Params::Create(*args_));
EXTENSION_FUNCTION_VALIDATE(params.get());
if (!extension()->permissions_data()->HasAPIPermission(
@@ -1462,7 +1461,7 @@ void DownloadsGetFileIconFunction::SetIconExtractorForTesting(
}
bool DownloadsGetFileIconFunction::RunAsync() {
- scoped_ptr<downloads::GetFileIcon::Params> params(
+ std::unique_ptr<downloads::GetFileIcon::Params> params(
downloads::GetFileIcon::Params::Create(*args_));
EXTENSION_FUNCTION_VALIDATE(params.get());
const downloads::GetFileIconOptions* options =
@@ -1754,7 +1753,7 @@ void ExtensionDownloadsEventRouter::OnDownloadCreated(
downloads::OnDeterminingFilename::kEventName))) {
return;
}
- scoped_ptr<base::DictionaryValue> json_item(
+ std::unique_ptr<base::DictionaryValue> json_item(
DownloadItemToJSON(download_item, profile_));
DispatchEvent(events::DOWNLOADS_ON_CREATED, downloads::OnCreated::kEventName,
true, Event::WillDispatchCallback(), json_item->DeepCopy());
@@ -1781,11 +1780,11 @@ void ExtensionDownloadsEventRouter::OnDownloadUpdated(
// or else an event listener was added.
data = new ExtensionDownloadsEventRouterData(
download_item,
- scoped_ptr<base::DictionaryValue>(new base::DictionaryValue()));
+ std::unique_ptr<base::DictionaryValue>(new base::DictionaryValue()));
}
- scoped_ptr<base::DictionaryValue> new_json(DownloadItemToJSON(
- download_item, profile_));
- scoped_ptr<base::DictionaryValue> delta(new base::DictionaryValue());
+ std::unique_ptr<base::DictionaryValue> new_json(
+ DownloadItemToJSON(download_item, profile_));
+ std::unique_ptr<base::DictionaryValue> delta(new base::DictionaryValue());
delta->SetInteger(kIdKey, download_item->GetId());
std::set<std::string> new_fields;
bool changed = false;
@@ -1854,11 +1853,11 @@ void ExtensionDownloadsEventRouter::DispatchEvent(
DCHECK_CURRENTLY_ON(BrowserThread::UI);
if (!EventRouter::Get(profile_))
return;
- scoped_ptr<base::ListValue> args(new base::ListValue());
+ std::unique_ptr<base::ListValue> args(new base::ListValue());
args->Append(arg);
std::string json_args;
base::JSONWriter::Write(*args, &json_args);
- scoped_ptr<Event> event(
+ std::unique_ptr<Event> event(
new Event(histogram_value, event_name, std::move(args)));
// The downloads system wants to share on-record events with off-record
// extension renderers even in incognito_split_mode because that's how

Powered by Google App Engine
This is Rietveld 408576698