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

Unified Diff: extensions/browser/api/test/test_api.cc

Issue 2282063002: [Extensions] Convert some SyncExtensionFunctions (Closed)
Patch Set: revert 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « extensions/browser/api/test/test_api.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: extensions/browser/api/test/test_api.cc
diff --git a/extensions/browser/api/test/test_api.cc b/extensions/browser/api/test/test_api.cc
index 676d177e77ce875171b4db8bca70b98a8e2810bf..2eefdaf929ec57108f73a447996968cec7871387 100644
--- a/extensions/browser/api/test/test_api.cc
+++ b/extensions/browser/api/test/test_api.cc
@@ -38,27 +38,29 @@ namespace WaitForRoundTrip = api::test::WaitForRoundTrip;
TestExtensionFunction::~TestExtensionFunction() {}
-bool TestExtensionFunction::RunSync() {
+bool TestExtensionFunction::PreRunValidation(std::string* error) {
+ if (!UIThreadExtensionFunction::PreRunValidation(error))
+ return false;
if (!base::CommandLine::ForCurrentProcess()->HasSwitch(switches::kTestType)) {
- error_ = kNotTestProcessError;
+ *error = kNotTestProcessError;
return false;
}
- return RunSafe();
+ return true;
}
TestNotifyPassFunction::~TestNotifyPassFunction() {}
-bool TestNotifyPassFunction::RunSafe() {
+ExtensionFunction::ResponseAction TestNotifyPassFunction::Run() {
content::NotificationService::current()->Notify(
extensions::NOTIFICATION_EXTENSION_TEST_PASSED,
content::Source<content::BrowserContext>(dispatcher()->browser_context()),
content::NotificationService::NoDetails());
- return true;
+ return RespondNow(NoArguments());
}
TestNotifyFailFunction::~TestNotifyFailFunction() {}
-bool TestNotifyFailFunction::RunSafe() {
+ExtensionFunction::ResponseAction TestNotifyFailFunction::Run() {
std::unique_ptr<NotifyFail::Params> params(
NotifyFail::Params::Create(*args_));
EXTENSION_FUNCTION_VALIDATE(params.get());
@@ -66,16 +68,16 @@ bool TestNotifyFailFunction::RunSafe() {
extensions::NOTIFICATION_EXTENSION_TEST_FAILED,
content::Source<content::BrowserContext>(dispatcher()->browser_context()),
content::Details<std::string>(&params->message));
- return true;
+ return RespondNow(NoArguments());
}
TestLogFunction::~TestLogFunction() {}
-bool TestLogFunction::RunSafe() {
+ExtensionFunction::ResponseAction TestLogFunction::Run() {
std::unique_ptr<Log::Params> params(Log::Params::Create(*args_));
EXTENSION_FUNCTION_VALIDATE(params.get());
VLOG(1) << params->message;
- return true;
+ return RespondNow(NoArguments());
}
TestSendMessageFunction::TestSendMessageFunction() : waiting_(false) {}
@@ -139,25 +141,21 @@ TestGetConfigFunction::TestConfigState::GetInstance() {
TestGetConfigFunction::~TestGetConfigFunction() {}
-bool TestGetConfigFunction::RunSafe() {
+ExtensionFunction::ResponseAction TestGetConfigFunction::Run() {
TestConfigState* test_config_state = TestConfigState::GetInstance();
-
- if (!test_config_state->config_state()) {
- error_ = kNoTestConfigDataError;
- return false;
- }
-
- SetResult(test_config_state->config_state()->CreateDeepCopy());
- return true;
+ if (!test_config_state->config_state())
+ return RespondNow(Error(kNoTestConfigDataError));
+ return RespondNow(
+ OneArgument(test_config_state->config_state()->CreateDeepCopy()));
}
TestWaitForRoundTripFunction::~TestWaitForRoundTripFunction() {}
-bool TestWaitForRoundTripFunction::RunSafe() {
+ExtensionFunction::ResponseAction TestWaitForRoundTripFunction::Run() {
std::unique_ptr<WaitForRoundTrip::Params> params(
WaitForRoundTrip::Params::Create(*args_));
- SetResult(base::MakeUnique<base::StringValue>(params->message));
- return true;
+ return RespondNow(
+ OneArgument(base::MakeUnique<base::StringValue>(params->message)));
}
} // namespace extensions
« no previous file with comments | « extensions/browser/api/test/test_api.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698