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

Unified Diff: chrome/browser/extensions/extension_function.cc

Issue 8588067: Refactor to allow same code to test both sync and async functions. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Fix dependencies. Created 9 years, 1 month 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/extension_function.cc
diff --git a/chrome/browser/extensions/extension_function.cc b/chrome/browser/extensions/extension_function.cc
index c87c15a6624a634eb47f2e5043cb61ac4f8bf7fd..2bd3b7294b00cc11931df721698c1083bbace517 100644
--- a/chrome/browser/extensions/extension_function.cc
+++ b/chrome/browser/extensions/extension_function.cc
@@ -128,7 +128,7 @@ void ExtensionFunction::HandleBadMessage(base::ProcessHandle process) {
}
}
UIThreadExtensionFunction::UIThreadExtensionFunction()
- : render_view_host_(NULL), profile_(NULL) {
+ : render_view_host_(NULL), profile_(NULL), delegate_(NULL) {
}
UIThreadExtensionFunction::~UIThreadExtensionFunction() {
@@ -154,13 +154,17 @@ Browser* UIThreadExtensionFunction::GetCurrentBrowser() {
}
void UIThreadExtensionFunction::SendResponse(bool success) {
- if (!render_view_host_ || !dispatcher())
- return;
+ if (delegate_) {
+ delegate_->OnSendResponse(this, success);
+ } else {
+ if (!render_view_host_ || !dispatcher())
+ return;
- SendResponseImpl(render_view_host_->process()->GetHandle(),
- render_view_host_,
- render_view_host_->routing_id(),
- success);
+ SendResponseImpl(render_view_host_->process()->GetHandle(),
+ render_view_host_,
+ render_view_host_->routing_id(),
+ success);
+ }
}
IOThreadExtensionFunction::IOThreadExtensionFunction()
@@ -187,14 +191,7 @@ void IOThreadExtensionFunction::SendResponse(bool success) {
ipc_sender(), routing_id_, success);
}
-AsyncExtensionFunction::AsyncExtensionFunction() : delegate_(NULL) {
-}
-
-void AsyncExtensionFunction::SendResponse(bool success) {
- if (delegate_)
- delegate_->OnSendResponse(this, success);
- else
- UIThreadExtensionFunction::SendResponse(success);
+AsyncExtensionFunction::AsyncExtensionFunction() {
}
AsyncExtensionFunction::~AsyncExtensionFunction() {
« no previous file with comments | « chrome/browser/extensions/extension_function.h ('k') | chrome/browser/extensions/extension_function_test_utils.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698