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

Unified Diff: components/test_runner/test_runner.cc

Issue 1351393002: Make getBluetoothManualChooserEvents() asynchronous. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@lkcr
Patch Set: Go back to the callback interface. Created 5 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 | « components/test_runner/test_runner.h ('k') | components/test_runner/web_test_delegate.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: components/test_runner/test_runner.cc
diff --git a/components/test_runner/test_runner.cc b/components/test_runner/test_runner.cc
index 0d1315789a530d5f3e18753177e223deedc47dd7..00dc1455dc90fb731098d1676419c0ba05f21fd9 100644
--- a/components/test_runner/test_runner.cc
+++ b/components/test_runner/test_runner.cc
@@ -296,7 +296,7 @@ class TestRunnerBindings : public gin::Wrappable<TestRunnerBindings> {
void SetViewSourceForFrame(const std::string& name, bool enabled);
void SetBluetoothMockDataSet(const std::string& dataset_name);
void SetBluetoothManualChooser();
- std::vector<std::string> GetBluetoothManualChooserEvents();
+ void GetBluetoothManualChooserEvents(v8::Local<v8::Function> callback);
void SendBluetoothManualChooserEvent(const std::string& event,
const std::string& argument);
void SetGeofencingMockProvider(bool service_available);
@@ -1350,10 +1350,10 @@ void TestRunnerBindings::SetBluetoothManualChooser() {
runner_->SetBluetoothManualChooser();
}
-std::vector<std::string> TestRunnerBindings::GetBluetoothManualChooserEvents() {
+void TestRunnerBindings::GetBluetoothManualChooserEvents(
+ v8::Local<v8::Function> callback) {
if (runner_)
- return runner_->GetBluetoothManualChooserEvents();
- return std::vector<std::string>(1, "No Test Runner");
+ return runner_->GetBluetoothManualChooserEvents(callback);
}
void TestRunnerBindings::SendBluetoothManualChooserEvent(
@@ -2846,8 +2846,12 @@ void TestRunner::SetBluetoothManualChooser() {
delegate_->SetBluetoothManualChooser();
}
-std::vector<std::string> TestRunner::GetBluetoothManualChooserEvents() {
- return delegate_->GetBluetoothManualChooserEvents();
+void TestRunner::GetBluetoothManualChooserEvents(
+ v8::Local<v8::Function> callback) {
+ scoped_ptr<InvokeCallbackTask> task(new InvokeCallbackTask(this, callback));
+ return delegate_->GetBluetoothManualChooserEvents(
+ base::Bind(&TestRunner::GetBluetoothManualChooserEventsCallback,
+ weak_factory_.GetWeakPtr(), base::Passed(&task)));
}
void TestRunner::SendBluetoothManualChooserEvent(const std::string& event,
@@ -3062,6 +3066,28 @@ void TestRunner::DispatchBeforeInstallPromptCallback(
InvokeCallback(task.Pass());
}
+void TestRunner::GetBluetoothManualChooserEventsCallback(
+ scoped_ptr<InvokeCallbackTask> task,
+ const std::vector<std::string>& events) {
+ // Build the V8 context.
+ v8::Isolate* isolate = blink::mainThreadIsolate();
+ v8::HandleScope handle_scope(isolate);
+ v8::Local<v8::Context> context =
+ web_view_->mainFrame()->mainWorldScriptContext();
+ if (context.IsEmpty())
+ return;
+ v8::Context::Scope context_scope(context);
+
+ // Convert the argument.
+ v8::Local<v8::Value> arg[1];
+ if (!gin::TryConvertToV8(isolate, events, &arg[0]))
+ return;
+
+ // Call the callback.
+ task->SetArguments(1, arg);
+ InvokeCallback(task.Pass());
+}
+
void TestRunner::LocationChangeDone() {
web_history_item_count_ = delegate_->NavigationEntryCount();
« no previous file with comments | « components/test_runner/test_runner.h ('k') | components/test_runner/web_test_delegate.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698