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

Unified Diff: extensions/browser/extension_function.cc

Issue 2351823004: [Extensions] Consolidate ExtensionFunction::SendResponse()s (Closed)
Patch Set: lazyboy's Created 4 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « extensions/browser/extension_function.h ('k') | extensions/browser/quota_service_unittest.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: extensions/browser/extension_function.cc
diff --git a/extensions/browser/extension_function.cc b/extensions/browser/extension_function.cc
index 2ae214106f4cff0be94992fc35c3bbe208874b90..7216a9ef0c79b38a2212baca7809bc95ba653c1e 100644
--- a/extensions/browser/extension_function.cc
+++ b/extensions/browser/extension_function.cc
@@ -301,7 +301,7 @@ bool ExtensionFunction::HasPermission() {
void ExtensionFunction::OnQuotaExceeded(const std::string& violation_error) {
error_ = violation_error;
- SendResponse(false);
+ SendResponseImpl(false);
}
void ExtensionFunction::SetArgs(const base::ListValue* args) {
@@ -407,7 +407,8 @@ ExtensionFunction::ResponseValue ExtensionFunction::BadMessage() {
ExtensionFunction::ResponseAction ExtensionFunction::RespondNow(
ResponseValue result) {
return ResponseAction(new RespondNowAction(
- std::move(result), base::Bind(&ExtensionFunction::SendResponse, this)));
+ std::move(result),
+ base::Bind(&ExtensionFunction::SendResponseImpl, this)));
}
ExtensionFunction::ResponseAction ExtensionFunction::RespondLater() {
@@ -421,7 +422,7 @@ ExtensionFunction::ResponseAction ExtensionFunction::ValidationFailure(
}
void ExtensionFunction::Respond(ResponseValue result) {
- SendResponse(result->Apply());
+ SendResponseImpl(result->Apply());
}
bool ExtensionFunction::PreRunValidation(std::string* error) {
@@ -448,6 +449,8 @@ bool ExtensionFunction::HasOptionalArgument(size_t index) {
void ExtensionFunction::SendResponseImpl(bool success) {
DCHECK(!response_callback_.is_null());
+ DCHECK(!did_respond_) << name_;
+ did_respond_ = true;
ResponseType response = success ? SUCCEEDED : FAILED;
if (bad_message_) {
@@ -462,10 +465,8 @@ void ExtensionFunction::SendResponseImpl(bool success) {
response_callback_.Run(response, *results_, GetError(), histogram_value());
LogUma(success, timer_.Elapsed(), histogram_value_);
-}
-void ExtensionFunction::OnRespondingLater(ResponseValue value) {
- SendResponse(value->Apply());
+ OnResponded();
}
UIThreadExtensionFunction::UIThreadExtensionFunction()
@@ -548,11 +549,7 @@ content::WebContents* UIThreadExtensionFunction::GetSenderWebContents() {
content::WebContents::FromRenderFrameHost(render_frame_host_) : nullptr;
}
-void UIThreadExtensionFunction::SendResponse(bool success) {
- DCHECK(!did_respond_) << name_;
- did_respond_ = true;
- SendResponseImpl(success);
-
+void UIThreadExtensionFunction::OnResponded() {
if (!transferred_blob_uuids_.empty()) {
render_frame_host_->Send(
new ExtensionMsg_TransferBlobs(transferred_blob_uuids_));
@@ -590,12 +587,6 @@ void IOThreadExtensionFunction::Destruct() const {
BrowserThread::DeleteOnIOThread::Destruct(this);
}
-void IOThreadExtensionFunction::SendResponse(bool success) {
- DCHECK(!did_respond_) << name_;
- did_respond_ = true;
- SendResponseImpl(success);
-}
-
AsyncExtensionFunction::AsyncExtensionFunction() {
}
@@ -619,3 +610,7 @@ bool AsyncExtensionFunction::ValidationFailure(
AsyncExtensionFunction* function) {
return false;
}
+
+void AsyncExtensionFunction::SendResponse(bool success) {
+ Respond(success ? ArgumentList(std::move(results_)) : Error(error_));
+}
« no previous file with comments | « extensions/browser/extension_function.h ('k') | extensions/browser/quota_service_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698