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

Side by Side 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, 2 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 unified diff | 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 »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "components/test_runner/test_runner.h" 5 #include "components/test_runner/test_runner.h"
6 6
7 #include <limits> 7 #include <limits>
8 8
9 #include "base/logging.h" 9 #include "base/logging.h"
10 #include "components/test_runner/mock_credential_manager_client.h" 10 #include "components/test_runner/mock_credential_manager_client.h"
(...skipping 278 matching lines...) Expand 10 before | Expand all | Expand 10 after
289 void LayoutAndPaintAsyncThen(v8::Local<v8::Function> callback); 289 void LayoutAndPaintAsyncThen(v8::Local<v8::Function> callback);
290 void GetManifestThen(v8::Local<v8::Function> callback); 290 void GetManifestThen(v8::Local<v8::Function> callback);
291 void CapturePixelsAsyncThen(v8::Local<v8::Function> callback); 291 void CapturePixelsAsyncThen(v8::Local<v8::Function> callback);
292 void CopyImageAtAndCapturePixelsAsyncThen(int x, 292 void CopyImageAtAndCapturePixelsAsyncThen(int x,
293 int y, 293 int y,
294 v8::Local<v8::Function> callback); 294 v8::Local<v8::Function> callback);
295 void SetCustomTextOutput(std::string output); 295 void SetCustomTextOutput(std::string output);
296 void SetViewSourceForFrame(const std::string& name, bool enabled); 296 void SetViewSourceForFrame(const std::string& name, bool enabled);
297 void SetBluetoothMockDataSet(const std::string& dataset_name); 297 void SetBluetoothMockDataSet(const std::string& dataset_name);
298 void SetBluetoothManualChooser(); 298 void SetBluetoothManualChooser();
299 std::vector<std::string> GetBluetoothManualChooserEvents(); 299 void GetBluetoothManualChooserEvents(v8::Local<v8::Function> callback);
300 void SendBluetoothManualChooserEvent(const std::string& event, 300 void SendBluetoothManualChooserEvent(const std::string& event,
301 const std::string& argument); 301 const std::string& argument);
302 void SetGeofencingMockProvider(bool service_available); 302 void SetGeofencingMockProvider(bool service_available);
303 void ClearGeofencingMockProvider(); 303 void ClearGeofencingMockProvider();
304 void SetGeofencingMockPosition(double latitude, double longitude); 304 void SetGeofencingMockPosition(double latitude, double longitude);
305 void SetPermission(const std::string& name, 305 void SetPermission(const std::string& name,
306 const std::string& value, 306 const std::string& value,
307 const std::string& origin, 307 const std::string& origin,
308 const std::string& embedding_origin); 308 const std::string& embedding_origin);
309 void DispatchBeforeInstallPromptEvent( 309 void DispatchBeforeInstallPromptEvent(
(...skipping 1033 matching lines...) Expand 10 before | Expand all | Expand 10 after
1343 void TestRunnerBindings::SetBluetoothMockDataSet(const std::string& name) { 1343 void TestRunnerBindings::SetBluetoothMockDataSet(const std::string& name) {
1344 if (runner_) 1344 if (runner_)
1345 runner_->SetBluetoothMockDataSet(name); 1345 runner_->SetBluetoothMockDataSet(name);
1346 } 1346 }
1347 1347
1348 void TestRunnerBindings::SetBluetoothManualChooser() { 1348 void TestRunnerBindings::SetBluetoothManualChooser() {
1349 if (runner_) 1349 if (runner_)
1350 runner_->SetBluetoothManualChooser(); 1350 runner_->SetBluetoothManualChooser();
1351 } 1351 }
1352 1352
1353 std::vector<std::string> TestRunnerBindings::GetBluetoothManualChooserEvents() { 1353 void TestRunnerBindings::GetBluetoothManualChooserEvents(
1354 v8::Local<v8::Function> callback) {
1354 if (runner_) 1355 if (runner_)
1355 return runner_->GetBluetoothManualChooserEvents(); 1356 return runner_->GetBluetoothManualChooserEvents(callback);
1356 return std::vector<std::string>(1, "No Test Runner");
1357 } 1357 }
1358 1358
1359 void TestRunnerBindings::SendBluetoothManualChooserEvent( 1359 void TestRunnerBindings::SendBluetoothManualChooserEvent(
1360 const std::string& event, 1360 const std::string& event,
1361 const std::string& argument) { 1361 const std::string& argument) {
1362 if (runner_) 1362 if (runner_)
1363 runner_->SendBluetoothManualChooserEvent(event, argument); 1363 runner_->SendBluetoothManualChooserEvent(event, argument);
1364 } 1364 }
1365 1365
1366 void TestRunnerBindings::SetPOSIXLocale(const std::string& locale) { 1366 void TestRunnerBindings::SetPOSIXLocale(const std::string& locale) {
(...skipping 1472 matching lines...) Expand 10 before | Expand all | Expand 10 after
2839 } 2839 }
2840 2840
2841 void TestRunner::SetBluetoothMockDataSet(const std::string& name) { 2841 void TestRunner::SetBluetoothMockDataSet(const std::string& name) {
2842 delegate_->SetBluetoothMockDataSet(name); 2842 delegate_->SetBluetoothMockDataSet(name);
2843 } 2843 }
2844 2844
2845 void TestRunner::SetBluetoothManualChooser() { 2845 void TestRunner::SetBluetoothManualChooser() {
2846 delegate_->SetBluetoothManualChooser(); 2846 delegate_->SetBluetoothManualChooser();
2847 } 2847 }
2848 2848
2849 std::vector<std::string> TestRunner::GetBluetoothManualChooserEvents() { 2849 void TestRunner::GetBluetoothManualChooserEvents(
2850 return delegate_->GetBluetoothManualChooserEvents(); 2850 v8::Local<v8::Function> callback) {
2851 scoped_ptr<InvokeCallbackTask> task(new InvokeCallbackTask(this, callback));
2852 return delegate_->GetBluetoothManualChooserEvents(
2853 base::Bind(&TestRunner::GetBluetoothManualChooserEventsCallback,
2854 weak_factory_.GetWeakPtr(), base::Passed(&task)));
2851 } 2855 }
2852 2856
2853 void TestRunner::SendBluetoothManualChooserEvent(const std::string& event, 2857 void TestRunner::SendBluetoothManualChooserEvent(const std::string& event,
2854 const std::string& argument) { 2858 const std::string& argument) {
2855 delegate_->SendBluetoothManualChooserEvent(event, argument); 2859 delegate_->SendBluetoothManualChooserEvent(event, argument);
2856 } 2860 }
2857 2861
2858 void TestRunner::SetGeofencingMockProvider(bool service_available) { 2862 void TestRunner::SetGeofencingMockProvider(bool service_available) {
2859 delegate_->SetGeofencingMockProvider(service_available); 2863 delegate_->SetGeofencingMockProvider(service_available);
2860 } 2864 }
(...skipping 194 matching lines...) Expand 10 before | Expand all | Expand 10 after
3055 return; 3059 return;
3056 3060
3057 v8::Context::Scope context_scope(context); 3061 v8::Context::Scope context_scope(context);
3058 v8::Local<v8::Value> argv[1]; 3062 v8::Local<v8::Value> argv[1];
3059 argv[0] = v8::Boolean::New(isolate, canceled); 3063 argv[0] = v8::Boolean::New(isolate, canceled);
3060 3064
3061 task->SetArguments(1, argv); 3065 task->SetArguments(1, argv);
3062 InvokeCallback(task.Pass()); 3066 InvokeCallback(task.Pass());
3063 } 3067 }
3064 3068
3069 void TestRunner::GetBluetoothManualChooserEventsCallback(
3070 scoped_ptr<InvokeCallbackTask> task,
3071 const std::vector<std::string>& events) {
3072 // Build the V8 context.
3073 v8::Isolate* isolate = blink::mainThreadIsolate();
3074 v8::HandleScope handle_scope(isolate);
3075 v8::Local<v8::Context> context =
3076 web_view_->mainFrame()->mainWorldScriptContext();
3077 if (context.IsEmpty())
3078 return;
3079 v8::Context::Scope context_scope(context);
3080
3081 // Convert the argument.
3082 v8::Local<v8::Value> arg[1];
3083 if (!gin::TryConvertToV8(isolate, events, &arg[0]))
3084 return;
3085
3086 // Call the callback.
3087 task->SetArguments(1, arg);
3088 InvokeCallback(task.Pass());
3089 }
3090
3065 void TestRunner::LocationChangeDone() { 3091 void TestRunner::LocationChangeDone() {
3066 web_history_item_count_ = delegate_->NavigationEntryCount(); 3092 web_history_item_count_ = delegate_->NavigationEntryCount();
3067 3093
3068 // No more new work after the first complete load. 3094 // No more new work after the first complete load.
3069 work_queue_.set_frozen(true); 3095 work_queue_.set_frozen(true);
3070 3096
3071 if (!wait_until_done_) 3097 if (!wait_until_done_)
3072 work_queue_.ProcessWorkSoon(); 3098 work_queue_.ProcessWorkSoon();
3073 } 3099 }
3074 3100
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after
3109 } 3135 }
3110 3136
3111 void TestRunner::DidLosePointerLockInternal() { 3137 void TestRunner::DidLosePointerLockInternal() {
3112 bool was_locked = pointer_locked_; 3138 bool was_locked = pointer_locked_;
3113 pointer_locked_ = false; 3139 pointer_locked_ = false;
3114 if (was_locked) 3140 if (was_locked)
3115 web_view_->didLosePointerLock(); 3141 web_view_->didLosePointerLock();
3116 } 3142 }
3117 3143
3118 } // namespace test_runner 3144 } // namespace test_runner
OLDNEW
« 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