Commit 687201f2 authored by Lei Zhang's avatar Lei Zhang Committed by Commit Bot

Change ExtensionFunction::TwoArguments() to take base::Value.

Instead of std::unique_ptr<base::Value>.

Bug: 1139221
Change-Id: Ie28bd486e0eed75cdb4287c3efd778aceac32f13
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2496034Reviewed-by: default avatarDavid Bertoni <dbertoni@chromium.org>
Commit-Queue: Lei Zhang <thestig@chromium.org>
Cr-Commit-Position: refs/heads/master@{#820863}
parent 735a9e9e
...@@ -814,8 +814,9 @@ FileManagerPrivateInternalGetCrostiniSharedPathsFunction::Run() { ...@@ -814,8 +814,9 @@ FileManagerPrivateInternalGetCrostiniSharedPathsFunction::Run() {
entry->SetBoolean("fileIsDirectory", true); entry->SetBoolean("fileIsDirectory", true);
entries->Append(std::move(entry)); entries->Append(std::move(entry));
} }
return RespondNow(TwoArguments( return RespondNow(
std::move(entries), std::make_unique<base::Value>(first_for_session))); TwoArguments(base::Value::FromUniquePtrValue(std::move(entries)),
base::Value(first_for_session)));
} }
ExtensionFunction::ResponseAction ExtensionFunction::ResponseAction
......
...@@ -901,6 +901,6 @@ void WallpaperPrivateGetSurpriseMeImageFunction::OnSurpriseMeImageFetched( ...@@ -901,6 +901,6 @@ void WallpaperPrivateGetSurpriseMeImageFunction::OnSurpriseMeImageFetched(
extensions::api::wallpaper_private::ImageInfo image_info; extensions::api::wallpaper_private::ImageInfo image_info;
ParseImageInfo(image, &image_info); ParseImageInfo(image, &image_info);
Respond(TwoArguments(image_info.ToValue(), Respond(TwoArguments(Value::FromUniquePtrValue(image_info.ToValue()),
std::make_unique<Value>(next_resume_token))); Value(next_resume_token)));
} }
...@@ -346,8 +346,9 @@ void IdentityGetAuthTokenFunction::CompleteFunctionWithResult( ...@@ -346,8 +346,9 @@ void IdentityGetAuthTokenFunction::CompleteFunctionWithResult(
for (const auto& scope : granted_scopes) for (const auto& scope : granted_scopes)
granted_scopes_value->Append(scope); granted_scopes_value->Append(scope);
CompleteAsyncRun(TwoArguments(std::make_unique<base::Value>(access_token), CompleteAsyncRun(TwoArguments(
std::move(granted_scopes_value))); base::Value(access_token),
base::Value::FromUniquePtrValue(std::move(granted_scopes_value))));
} else { } else {
CompleteAsyncRun(OneArgument(base::Value(access_token))); CompleteAsyncRun(OneArgument(base::Value(access_token)));
} }
......
...@@ -414,11 +414,10 @@ void FeedbackPrivateSendFeedbackFunction::OnAllLogsFetched( ...@@ -414,11 +414,10 @@ void FeedbackPrivateSendFeedbackFunction::OnAllLogsFetched(
void FeedbackPrivateSendFeedbackFunction::OnCompleted( void FeedbackPrivateSendFeedbackFunction::OnCompleted(
api::feedback_private::LandingPageType type, api::feedback_private::LandingPageType type,
bool success) { bool success) {
Respond(TwoArguments( Respond(TwoArguments(base::Value(feedback_private::ToString(
std::make_unique<base::Value>(feedback_private::ToString( success ? feedback_private::STATUS_SUCCESS
success ? feedback_private::STATUS_SUCCESS : feedback_private::STATUS_DELAYED)),
: feedback_private::STATUS_DELAYED)), base::Value(feedback_private::ToString(type))));
std::make_unique<base::Value>(feedback_private::ToString(type))));
if (!success) { if (!success) {
ExtensionsAPIClient::Get() ExtensionsAPIClient::Get()
->GetFeedbackPrivateDelegate() ->GetFeedbackPrivateDelegate()
......
...@@ -260,8 +260,7 @@ void HidReceiveFunction::OnFinished( ...@@ -260,8 +260,7 @@ void HidReceiveFunction::OnFinished(
const base::Optional<std::vector<uint8_t>>& buffer) { const base::Optional<std::vector<uint8_t>>& buffer) {
if (success) { if (success) {
DCHECK(buffer); DCHECK(buffer);
Respond(TwoArguments(std::make_unique<base::Value>(report_id), Respond(TwoArguments(base::Value(report_id), base::Value(*buffer)));
base::Value::ToUniquePtrValue(base::Value(*buffer))));
} else { } else {
Respond(Error(kErrorTransfer)); Respond(Error(kErrorTransfer));
} }
......
...@@ -657,8 +657,8 @@ void RuntimeRequestUpdateCheckFunction::CheckComplete( ...@@ -657,8 +657,8 @@ void RuntimeRequestUpdateCheckFunction::CheckComplete(
if (result.success) { if (result.success) {
std::unique_ptr<base::DictionaryValue> details(new base::DictionaryValue); std::unique_ptr<base::DictionaryValue> details(new base::DictionaryValue);
details->SetString("version", result.version); details->SetString("version", result.version);
Respond(TwoArguments(std::make_unique<base::Value>(result.response), Respond(TwoArguments(base::Value(result.response),
std::move(details))); base::Value::FromUniquePtrValue(std::move(details))));
} else { } else {
// HMM(kalman): Why does !success not imply Error()? // HMM(kalman): Why does !success not imply Error()?
Respond(OneArgument(base::Value(result.response))); Respond(OneArgument(base::Value(result.response)));
......
...@@ -536,11 +536,11 @@ ExtensionFunction::ResponseValue ExtensionFunction::OneArgument( ...@@ -536,11 +536,11 @@ ExtensionFunction::ResponseValue ExtensionFunction::OneArgument(
} }
ExtensionFunction::ResponseValue ExtensionFunction::TwoArguments( ExtensionFunction::ResponseValue ExtensionFunction::TwoArguments(
std::unique_ptr<base::Value> arg1, base::Value arg1,
std::unique_ptr<base::Value> arg2) { base::Value arg2) {
base::Value args(base::Value::Type::LIST); base::Value args(base::Value::Type::LIST);
args.Append(base::Value::FromUniquePtrValue(std::move(arg1))); args.Append(std::move(arg1));
args.Append(base::Value::FromUniquePtrValue(std::move(arg2))); args.Append(std::move(arg2));
return ResponseValue(new ArgumentListResponseValue(this, std::move(args))); return ResponseValue(new ArgumentListResponseValue(this, std::move(args)));
} }
......
...@@ -370,8 +370,7 @@ class ExtensionFunction : public base::RefCountedThreadSafe< ...@@ -370,8 +370,7 @@ class ExtensionFunction : public base::RefCountedThreadSafe<
// Success, two arguments |arg1| and |arg2| to pass to caller. // Success, two arguments |arg1| and |arg2| to pass to caller.
// Note that use of this function may imply you // Note that use of this function may imply you
// should be using the generated Result struct and ArgumentList. // should be using the generated Result struct and ArgumentList.
ResponseValue TwoArguments(std::unique_ptr<base::Value> arg1, ResponseValue TwoArguments(base::Value arg1, base::Value arg2);
std::unique_ptr<base::Value> arg2);
// Success, a list of arguments |results| to pass to caller. // Success, a list of arguments |results| to pass to caller.
// - a std::unique_ptr<> for convenience, since callers usually get this from // - a std::unique_ptr<> for convenience, since callers usually get this from
// the result of a Create(...) call on the generated Results struct. For // the result of a Create(...) call on the generated Results struct. For
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment