Replace NewCefRunnable* usage with base::Bind and fix CefCreateClosureTask typo (issue #1336).

git-svn-id: https://chromiumembedded.googlecode.com/svn/trunk@1776 5089003a-bbd8-11dd-ad1f-f1f9622dbc98
This commit is contained in:
Marshall Greenblatt 2014-07-15 18:10:40 +00:00
parent 646ae3310f
commit 1a819fe284
22 changed files with 101 additions and 111 deletions

View File

@ -85,7 +85,7 @@
// Create a CefTask that wraps a base::Closure. Can be used in combination with // Create a CefTask that wraps a base::Closure. Can be used in combination with
// CefTaskRunner. // CefTaskRunner.
/// ///
CefRefPtr<CefTask> CefCreateClosureRask(const base::Closure& closure); CefRefPtr<CefTask> CefCreateClosureTask(const base::Closure& closure);
/// ///
// Post a Closure for execution on the specified thread. // Post a Closure for execution on the specified thread.

View File

@ -28,7 +28,7 @@ class CefClosureTask : public CefTask {
} // namespace } // namespace
CefRefPtr<CefTask> CefCreateClosureRask(const base::Closure& closure) { CefRefPtr<CefTask> CefCreateClosureTask(const base::Closure& closure) {
return new CefClosureTask(closure); return new CefClosureTask(closure);
} }

View File

@ -7,9 +7,10 @@
#include <map> #include <map>
#include <set> #include <set>
#include "include/base/cef_bind.h"
#include "include/base/cef_macros.h" #include "include/base/cef_macros.h"
#include "include/cef_runnable.h"
#include "include/cef_task.h" #include "include/cef_task.h"
#include "include/wrapper/cef_closure_task.h"
#include "include/wrapper/cef_helpers.h" #include "include/wrapper/cef_helpers.h"
#include "libcef_dll/wrapper/cef_browser_info_map.h" #include "libcef_dll/wrapper/cef_browser_info_map.h"
@ -87,16 +88,14 @@ class CefMessageRouterBrowserSideImpl : public CefMessageRouterBrowserSide {
if (!CefCurrentlyOn(TID_UI)) { if (!CefCurrentlyOn(TID_UI)) {
// Must execute on the UI thread to access member variables. // Must execute on the UI thread to access member variables.
CefPostTask(TID_UI, CefPostTask(TID_UI,
NewCefRunnableMethod(this, &CallbackImpl::Success, response)); base::Bind(&CallbackImpl::Success, this, response));
return; return;
} }
if (router_) { if (router_) {
CefPostTask(TID_UI, CefPostTask(TID_UI,
NewCefRunnableMethod( base::Bind(&CefMessageRouterBrowserSideImpl::OnCallbackSuccess,
router_.get(), router_, browser_id_, query_id_, response));
&CefMessageRouterBrowserSideImpl::OnCallbackSuccess,
browser_id_, query_id_, response));
if (!persistent_) { if (!persistent_) {
// Non-persistent callbacks are only good for a single use. // Non-persistent callbacks are only good for a single use.
@ -110,17 +109,16 @@ class CefMessageRouterBrowserSideImpl : public CefMessageRouterBrowserSide {
if (!CefCurrentlyOn(TID_UI)) { if (!CefCurrentlyOn(TID_UI)) {
// Must execute on the UI thread to access member variables. // Must execute on the UI thread to access member variables.
CefPostTask(TID_UI, CefPostTask(TID_UI,
NewCefRunnableMethod(this, &CallbackImpl::Failure, base::Bind(&CallbackImpl::Failure, this,
error_code, error_message)); error_code, error_message));
return; return;
} }
if (router_) { if (router_) {
CefPostTask(TID_UI, CefPostTask(TID_UI,
NewCefRunnableMethod( base::Bind(&CefMessageRouterBrowserSideImpl::OnCallbackFailure,
router_.get(), router_, browser_id_, query_id_, error_code,
&CefMessageRouterBrowserSideImpl::OnCallbackFailure, error_message));
browser_id_, query_id_, error_code, error_message));
// Failure always invalidates the callback. // Failure always invalidates the callback.
router_ = NULL; router_ = NULL;
@ -494,9 +492,8 @@ class CefMessageRouterBrowserSideImpl : public CefMessageRouterBrowserSide {
if (!CefCurrentlyOn(TID_UI)) { if (!CefCurrentlyOn(TID_UI)) {
// Must execute on the UI thread. // Must execute on the UI thread.
CefPostTask(TID_UI, CefPostTask(TID_UI,
NewCefRunnableMethod(this, base::Bind(&CefMessageRouterBrowserSideImpl::CancelPendingFor, this,
&CefMessageRouterBrowserSideImpl::CancelPendingFor, browser, handler, notify_renderer));
browser, handler, notify_renderer));
return; return;
} }
@ -843,16 +840,16 @@ class CefMessageRouterRendererSideImpl : public CefMessageRouterRendererSide {
DCHECK_EQ(args->GetSize(), 4U); DCHECK_EQ(args->GetSize(), 4U);
const CefString& response = args->GetString(3); const CefString& response = args->GetString(3);
CefPostTask(TID_RENDERER, CefPostTask(TID_RENDERER,
NewCefRunnableMethod(this, base::Bind(
&CefMessageRouterRendererSideImpl::ExecuteSuccessCallback, &CefMessageRouterRendererSideImpl::ExecuteSuccessCallback, this,
browser->GetIdentifier(), context_id, request_id, response)); browser->GetIdentifier(), context_id, request_id, response));
} else { } else {
DCHECK_EQ(args->GetSize(), 5U); DCHECK_EQ(args->GetSize(), 5U);
int error_code = args->GetInt(3); int error_code = args->GetInt(3);
const CefString& error_message = args->GetString(4); const CefString& error_message = args->GetString(4);
CefPostTask(TID_RENDERER, CefPostTask(TID_RENDERER,
NewCefRunnableMethod(this, base::Bind(
&CefMessageRouterRendererSideImpl::ExecuteFailureCallback, &CefMessageRouterRendererSideImpl::ExecuteFailureCallback, this,
browser->GetIdentifier(), context_id, request_id, error_code, browser->GetIdentifier(), context_id, request_id, error_code,
error_message)); error_message));
} }

View File

@ -10,11 +10,12 @@
#include "base/files/scoped_temp_dir.h" #include "base/files/scoped_temp_dir.h"
#include "base/synchronization/waitable_event.h" #include "base/synchronization/waitable_event.h"
#include "include/base/cef_bind.h"
#include "include/base/cef_logging.h" #include "include/base/cef_logging.h"
#include "include/base/cef_ref_counted.h" #include "include/base/cef_ref_counted.h"
#include "include/cef_cookie.h" #include "include/cef_cookie.h"
#include "include/cef_runnable.h"
#include "include/cef_scheme.h" #include "include/cef_scheme.h"
#include "include/wrapper/cef_closure_task.h"
#include "testing/gtest/include/gtest/gtest.h" #include "testing/gtest/include/gtest/gtest.h"
#include "tests/unittests/test_handler.h" #include "tests/unittests/test_handler.h"
#include "tests/unittests/test_suite.h" #include "tests/unittests/test_suite.h"
@ -74,8 +75,7 @@ class TestVisitor : public CefCookieVisitor {
void SetCookies(CefRefPtr<CefCookieManager> manager, void SetCookies(CefRefPtr<CefCookieManager> manager,
const CefString& url, CookieVector& cookies, const CefString& url, CookieVector& cookies,
base::WaitableEvent& event) { base::WaitableEvent& event) {
CefPostTask(TID_IO, NewCefRunnableFunction(IOT_Set, manager, url, CefPostTask(TID_IO, base::Bind(IOT_Set, manager, url, &cookies, &event));
&cookies, &event));
event.Wait(); event.Wait();
} }
@ -83,8 +83,8 @@ void SetCookies(CefRefPtr<CefCookieManager> manager,
void DeleteCookies(CefRefPtr<CefCookieManager> manager, void DeleteCookies(CefRefPtr<CefCookieManager> manager,
const CefString& url, const CefString& cookie_name, const CefString& url, const CefString& cookie_name,
base::WaitableEvent& event) { base::WaitableEvent& event) {
CefPostTask(TID_IO, NewCefRunnableFunction(IOT_Delete, manager, url, CefPostTask(TID_IO,
cookie_name, &event)); base::Bind(IOT_Delete, manager, url, cookie_name, &event));
event.Wait(); event.Wait();
} }
@ -191,8 +191,8 @@ void VerifyNoCookies(CefRefPtr<CefCookieManager> manager,
// Delete all system cookies. // Delete all system cookies.
void DeleteAllCookies(CefRefPtr<CefCookieManager> manager, void DeleteAllCookies(CefRefPtr<CefCookieManager> manager,
base::WaitableEvent& event) { base::WaitableEvent& event) {
CefPostTask(TID_IO, NewCefRunnableFunction(IOT_Delete, manager, CefString(), CefPostTask(TID_IO,
CefString(), &event)); base::Bind(IOT_Delete, manager, CefString(), CefString(), &event));
event.Wait(); event.Wait();
} }

View File

@ -5,7 +5,8 @@
// Include this first to avoid type conflicts with CEF headers. // Include this first to avoid type conflicts with CEF headers.
#include "tests/unittests/chromium_includes.h" #include "tests/unittests/chromium_includes.h"
#include "include/cef_runnable.h" #include "include/base/cef_bind.h"
#include "include/wrapper/cef_closure_task.h"
#include "testing/gtest/include/gtest/gtest.h" #include "testing/gtest/include/gtest/gtest.h"
#include "tests/unittests/test_handler.h" #include "tests/unittests/test_handler.h"
#include "tests/unittests/test_util.h" #include "tests/unittests/test_util.h"
@ -116,8 +117,7 @@ class DialogTestHandler : public TestHandler {
if (config_.callback_async) { if (config_.callback_async) {
CefPostTask(TID_UI, CefPostTask(TID_UI,
NewCefRunnableMethod(this, &DialogTestHandler::ExecuteCallback, base::Bind(&DialogTestHandler::ExecuteCallback, this, callback));
callback));
} else { } else {
ExecuteCallback(callback); ExecuteCallback(callback);
} }

View File

@ -7,7 +7,6 @@
// Include this first to avoid type conflicts with CEF headers. // Include this first to avoid type conflicts with CEF headers.
#include "tests/unittests/chromium_includes.h" #include "tests/unittests/chromium_includes.h"
#include "include/cef_runnable.h"
#include "testing/gtest/include/gtest/gtest.h" #include "testing/gtest/include/gtest/gtest.h"
#include "tests/unittests/test_handler.h" #include "tests/unittests/test_handler.h"

View File

@ -7,8 +7,9 @@
#include "base/synchronization/waitable_event.h" #include "base/synchronization/waitable_event.h"
#include "include/base/cef_bind.h"
#include "include/cef_geolocation.h" #include "include/cef_geolocation.h"
#include "include/cef_runnable.h" #include "include/wrapper/cef_closure_task.h"
#include "testing/gtest/include/gtest/gtest.h" #include "testing/gtest/include/gtest/gtest.h"
#include "tests/unittests/test_handler.h" #include "tests/unittests/test_handler.h"
#include "tests/unittests/test_util.h" #include "tests/unittests/test_util.h"
@ -98,8 +99,7 @@ class GeolocationTestHandler : public TestHandler {
ExecuteCallback(callback); ExecuteCallback(callback);
} else { } else {
CefPostTask(TID_UI, CefPostTask(TID_UI,
NewCefRunnableMethod(this, &GeolocationTestHandler::ExecuteCallback, base::Bind(&GeolocationTestHandler::ExecuteCallback, this, callback));
callback));
} }
return true; return true;

View File

@ -5,7 +5,8 @@
// Include this first to avoid type conflicts with CEF headers. // Include this first to avoid type conflicts with CEF headers.
#include "tests/unittests/chromium_includes.h" #include "tests/unittests/chromium_includes.h"
#include "include/cef_runnable.h" #include "include/base/cef_bind.h"
#include "include/wrapper/cef_closure_task.h"
#include "testing/gtest/include/gtest/gtest.h" #include "testing/gtest/include/gtest/gtest.h"
#include "tests/unittests/test_handler.h" #include "tests/unittests/test_handler.h"
@ -127,7 +128,7 @@ class JSDialogTestHandler : public TestHandler {
} else if (mode_ == MODE_RUN_DELAYED) { } else if (mode_ == MODE_RUN_DELAYED) {
// Continue asynchronously. // Continue asynchronously.
CefPostTask(TID_UI, CefPostTask(TID_UI,
NewCefRunnableMethod(this, &JSDialogTestHandler::Continue, callback)); base::Bind(&JSDialogTestHandler::Continue, this, callback));
} }
return true; return true;
@ -151,7 +152,7 @@ class JSDialogTestHandler : public TestHandler {
} else if (mode_ == MODE_RUN_DELAYED) { } else if (mode_ == MODE_RUN_DELAYED) {
// Continue asynchronously. // Continue asynchronously.
CefPostTask(TID_UI, CefPostTask(TID_UI,
NewCefRunnableMethod(this, &JSDialogTestHandler::Continue, callback)); base::Bind(&JSDialogTestHandler::Continue, this, callback));
} }
return true; return true;

View File

@ -5,7 +5,8 @@
// Include this first to avoid type conflicts with CEF headers. // Include this first to avoid type conflicts with CEF headers.
#include "tests/unittests/chromium_includes.h" #include "tests/unittests/chromium_includes.h"
#include "include/cef_runnable.h" #include "include/base/cef_bind.h"
#include "include/wrapper/cef_closure_task.h"
#include "testing/gtest/include/gtest/gtest.h" #include "testing/gtest/include/gtest/gtest.h"
#include "tests/unittests/routing_test_handler.h" #include "tests/unittests/routing_test_handler.h"
@ -146,7 +147,7 @@ class LifeSpanTestHandler : public RoutingTestHandler {
// the window. // the window.
void ScheduleDelayClose() { void ScheduleDelayClose() {
CefPostDelayedTask(TID_UI, CefPostDelayedTask(TID_UI,
NewCefRunnableMethod(this, &LifeSpanTestHandler::DelayClose), 100); base::Bind(&LifeSpanTestHandler::DelayClose, this), 100);
} }
void DelayClose() { void DelayClose() {

View File

@ -11,9 +11,10 @@
#include "base/strings/stringprintf.h" #include "base/strings/stringprintf.h"
#include "include/base/cef_bind.h"
#include "include/base/cef_weak_ptr.h" #include "include/base/cef_weak_ptr.h"
#include "include/cef_v8.h" #include "include/cef_v8.h"
#include "include/cef_runnable.h" #include "include/wrapper/cef_closure_task.h"
#include "testing/gtest/include/gtest/gtest.h" #include "testing/gtest/include/gtest/gtest.h"
#include "tests/unittests/routing_test_handler.h" #include "tests/unittests/routing_test_handler.h"
#include "tests/cefclient/client_app.h" #include "tests/cefclient/client_app.h"
@ -211,7 +212,7 @@ class MRTestHandler : public TestHandler {
#if defined(TIMEOUT_ENABLED) #if defined(TIMEOUT_ENABLED)
// Time out the test after a reasonable period of time. // Time out the test after a reasonable period of time.
CefPostDelayedTask(TID_UI, CefPostDelayedTask(TID_UI,
NewCefRunnableMethod(this, &MRTestHandler::DestroyTest), base::Bind(&MRTestHandler::DestroyTest, this),
4000); 4000);
#endif #endif
} }
@ -542,8 +543,7 @@ class SingleQueryTestHandler : public SingleLoadTestHandler {
ExecuteCallback(); ExecuteCallback();
} else { } else {
CefPostTask(TID_UI, CefPostTask(TID_UI,
NewCefRunnableMethod(this, base::Bind(&SingleQueryTestHandler::ExecuteCallback, this));
&SingleQueryTestHandler::ExecuteCallback));
} }
} }
@ -767,8 +767,8 @@ class SinglePersistentQueryTestHandler : public SingleLoadTestHandler {
ExecuteCallback(); ExecuteCallback();
} else { } else {
CefPostTask(TID_UI, CefPostTask(TID_UI,
NewCefRunnableMethod(this, base::Bind(&SinglePersistentQueryTestHandler::ExecuteCallback,
&SinglePersistentQueryTestHandler::ExecuteCallback)); this));
} }
} }
@ -1851,8 +1851,7 @@ class MultiQuerySingleFrameTestHandler :
if (!SignalCompletionWhenAllBrowsersClose()) { if (!SignalCompletionWhenAllBrowsersClose()) {
// Complete asynchronously so the call stack has a chance to unwind. // Complete asynchronously so the call stack has a chance to unwind.
CefPostTask(TID_UI, CefPostTask(TID_UI,
NewCefRunnableMethod(this, base::Bind(&MultiQuerySingleFrameTestHandler::TestComplete, this));
&MultiQuerySingleFrameTestHandler::TestComplete));
} }
} }

View File

@ -8,9 +8,10 @@
// Include this first to avoid type conflicts with CEF headers. // Include this first to avoid type conflicts with CEF headers.
#include "tests/unittests/chromium_includes.h" #include "tests/unittests/chromium_includes.h"
#include "include/base/cef_bind.h"
#include "include/cef_callback.h" #include "include/cef_callback.h"
#include "include/cef_runnable.h"
#include "include/cef_scheme.h" #include "include/cef_scheme.h"
#include "include/wrapper/cef_closure_task.h"
#include "testing/gtest/include/gtest/gtest.h" #include "testing/gtest/include/gtest/gtest.h"
#include "tests/cefclient/client_app.h" #include "tests/cefclient/client_app.h"
#include "tests/unittests/test_handler.h" #include "tests/unittests/test_handler.h"
@ -1864,7 +1865,7 @@ class PopupNavTestHandler : public TestHandler {
if (!allow_) { if (!allow_) {
// Wait a bit to make sure the popup window isn't created. // Wait a bit to make sure the popup window isn't created.
CefPostDelayedTask(TID_UI, CefPostDelayedTask(TID_UI,
NewCefRunnableMethod(this, &PopupNavTestHandler::DestroyTest), 200); base::Bind(&PopupNavTestHandler::DestroyTest, this), 200);
} }
} else if (url == kPopupNavPopupUrl) { } else if (url == kPopupNavPopupUrl) {
if (allow_) { if (allow_) {
@ -1930,8 +1931,8 @@ class BrowseNavTestHandler : public TestHandler {
// Time out the test after a reasonable period of time. // Time out the test after a reasonable period of time.
CefPostDelayedTask(TID_UI, CefPostDelayedTask(TID_UI,
NewCefRunnableMethod(this, &BrowseNavTestHandler::DestroyTest), base::Bind(&BrowseNavTestHandler::DestroyTest, this),
2000); 2000);
} }
virtual bool OnBeforeBrowse(CefRefPtr<CefBrowser> browser, virtual bool OnBeforeBrowse(CefRefPtr<CefBrowser> browser,

View File

@ -8,9 +8,10 @@
#include "ui/events/keycodes/keyboard_codes.h" #include "ui/events/keycodes/keyboard_codes.h"
#include "ui/events/keycodes/keyboard_code_conversion.h" #include "ui/events/keycodes/keyboard_code_conversion.h"
#include "include/base/cef_bind.h"
#include "include/base/cef_logging.h" #include "include/base/cef_logging.h"
#include "include/cef_runnable.h"
#include "include/cef_v8.h" #include "include/cef_v8.h"
#include "include/wrapper/cef_closure_task.h"
#include "include/wrapper/cef_stream_resource_handler.h" #include "include/wrapper/cef_stream_resource_handler.h"
#include "tests/cefclient/client_app.h" #include "tests/cefclient/client_app.h"
#include "tests/cefclient/resource_util.h" #include "tests/cefclient/resource_util.h"
@ -229,8 +230,8 @@ class OSRTestHandler : public RoutingTestHandler,
// Each test has a 5 second timeout. After this timeout it will be destroyed // Each test has a 5 second timeout. After this timeout it will be destroyed
// and the test will fail. DestroyTest will be called at the timeout even // and the test will fail. DestroyTest will be called at the timeout even
// if the test is already destroyed and this is fine. // if the test is already destroyed and this is fine.
CefPostDelayedTask(TID_UI, NewCefRunnableMethod(this, CefPostDelayedTask(TID_UI, base::Bind(&OSRTestHandler::DestroyTest, this),
&OSRTestHandler::DestroyTest), 5000); 5000);
#endif // DEBUGGER_ATTACHED #endif // DEBUGGER_ATTACHED
} }
@ -936,10 +937,8 @@ class OSRTestHandler : public RoutingTestHandler,
void DestroySucceededTestSoon() { void DestroySucceededTestSoon() {
if (succeeded()) if (succeeded())
return; return;
if (++event_count_ == event_total_) { if (++event_count_ == event_total_)
CefPostTask(TID_UI, NewCefRunnableMethod(this, CefPostTask(TID_UI, base::Bind(&OSRTestHandler::DestroyTest, this));
&OSRTestHandler::DestroyTest));
}
} }
void ExpandDropDown() { void ExpandDropDown() {

View File

@ -5,9 +5,10 @@
// Include this first to avoid type conflicts with CEF headers. // Include this first to avoid type conflicts with CEF headers.
#include "tests/unittests/chromium_includes.h" #include "tests/unittests/chromium_includes.h"
#include "include/base/cef_bind.h"
#include "include/cef_request_context.h" #include "include/cef_request_context.h"
#include "include/cef_request_context_handler.h" #include "include/cef_request_context_handler.h"
#include "include/cef_runnable.h" #include "include/wrapper/cef_closure_task.h"
#include "testing/gtest/include/gtest/gtest.h" #include "testing/gtest/include/gtest/gtest.h"
#include "tests/unittests/test_handler.h" #include "tests/unittests/test_handler.h"
@ -158,7 +159,7 @@ class CookieTestHandler : public TestHandler {
virtual ~TestVisitor() { virtual ~TestVisitor() {
// Destroy the test. // Destroy the test.
CefPostTask(TID_UI, CefPostTask(TID_UI,
NewCefRunnableMethod(handler_, &CookieTestHandler::DestroyTest)); base::Bind(&CookieTestHandler::DestroyTest, handler_));
} }
virtual bool Visit(const CefCookie& cookie, int count, int total, virtual bool Visit(const CefCookie& cookie, int count, int total,
@ -366,7 +367,7 @@ class PopupTestHandler : public TestHandler {
virtual ~TestVisitor() { virtual ~TestVisitor() {
// Destroy the test. // Destroy the test.
CefPostTask(TID_UI, CefPostTask(TID_UI,
NewCefRunnableMethod(handler_, &PopupTestHandler::DestroyTest)); base::Bind(&PopupTestHandler::DestroyTest, handler_));
} }
virtual bool Visit(const CefCookie& cookie, int count, int total, virtual bool Visit(const CefCookie& cookie, int count, int total,

View File

@ -7,8 +7,9 @@
#include "base/strings/stringprintf.h" #include "base/strings/stringprintf.h"
#include "include/base/cef_bind.h"
#include "include/cef_cookie.h" #include "include/cef_cookie.h"
#include "include/cef_runnable.h" #include "include/wrapper/cef_closure_task.h"
#include "testing/gtest/include/gtest/gtest.h" #include "testing/gtest/include/gtest/gtest.h"
#include "tests/cefclient/client_app.h" #include "tests/cefclient/client_app.h"
#include "tests/unittests/test_handler.h" #include "tests/unittests/test_handler.h"
@ -269,7 +270,7 @@ class NetNotifyTestHandler : public TestHandler {
virtual ~TestVisitor() { virtual ~TestVisitor() {
// Destroy the test. // Destroy the test.
CefPostTask(TID_UI, CefPostTask(TID_UI,
NewCefRunnableMethod(handler_, &NetNotifyTestHandler::DestroyTest)); base::Bind(&NetNotifyTestHandler::DestroyTest, handler_));
} }
virtual bool Visit(const CefCookie& cookie, int count, int total, virtual bool Visit(const CefCookie& cookie, int count, int total,

View File

@ -7,8 +7,9 @@
// Include this first to avoid type conflicts with CEF headers. // Include this first to avoid type conflicts with CEF headers.
#include "tests/unittests/chromium_includes.h" #include "tests/unittests/chromium_includes.h"
#include "include/base/cef_bind.h"
#include "include/cef_request.h" #include "include/cef_request.h"
#include "include/cef_runnable.h" #include "include/wrapper/cef_closure_task.h"
#include "testing/gtest/include/gtest/gtest.h" #include "testing/gtest/include/gtest/gtest.h"
#include "tests/cefclient/client_app.h" #include "tests/cefclient/client_app.h"
#include "tests/unittests/test_handler.h" #include "tests/unittests/test_handler.h"
@ -492,9 +493,8 @@ class TypeTestHandler : public TestHandler {
CreateBrowser(std::string(kTypeTestOrigin) + "main.html"); CreateBrowser(std::string(kTypeTestOrigin) + "main.html");
// Time out the test after a reasonable period of time. // Time out the test after a reasonable period of time.
CefPostDelayedTask(TID_UI, CefPostDelayedTask(TID_UI, base::Bind(&TypeTestHandler::DestroyTest, this),
NewCefRunnableMethod(this, &TypeTestHandler::DestroyTest), 2000);
2000);
} }
virtual bool OnBeforeBrowse(CefRefPtr<CefBrowser> browser, virtual bool OnBeforeBrowse(CefRefPtr<CefBrowser> browser,
@ -523,7 +523,7 @@ class TypeTestHandler : public TestHandler {
completed_browser_side_ = true; completed_browser_side_ = true;
// Destroy the test on the UI thread. // Destroy the test on the UI thread.
CefPostTask(TID_UI, CefPostTask(TID_UI,
NewCefRunnableMethod(this, &TypeTestHandler::DestroyTestIfComplete)); base::Bind(&TypeTestHandler::DestroyTestIfComplete, this));
} }
return TestHandler::GetResourceHandler(browser, frame, request); return TestHandler::GetResourceHandler(browser, frame, request);

View File

@ -11,13 +11,11 @@
#include "include/cef_app.h" #include "include/cef_app.h"
#include "include/cef_task.h" #include "include/cef_task.h"
#include "include/wrapper/cef_helpers.h" #include "include/wrapper/cef_helpers.h"
#include "include/wrapper/cef_closure_task.h"
#include "tests/cefclient/client_app.h" #include "tests/cefclient/client_app.h"
#include "tests/unittests/test_handler.h" #include "tests/unittests/test_handler.h"
#include "tests/unittests/test_suite.h" #include "tests/unittests/test_suite.h"
// Include after base/bind.h to avoid name collisions with cef_tuple.h.
#include "include/cef_runnable.h"
#if defined(OS_WIN) #if defined(OS_WIN)
#include "include/cef_sandbox_win.h" #include "include/cef_sandbox_win.h"
#endif #endif
@ -41,7 +39,7 @@ class CefTestThread : public base::Thread {
base::PlatformThread::Sleep(base::TimeDelta::FromMilliseconds(100)); base::PlatformThread::Sleep(base::TimeDelta::FromMilliseconds(100));
// Quit the CEF message loop. // Quit the CEF message loop.
CefPostTask(TID_UI, NewCefRunnableFunction(CefQuitMessageLoop)); CefPostTask(TID_UI, base::Bind(&CefQuitMessageLoop));
} }
int retval() { return retval_; } int retval() { return retval_; }
@ -124,7 +122,7 @@ int main(int argc, char* argv[]) {
// Start the tests from the UI thread so that any pending UI tasks get a // Start the tests from the UI thread so that any pending UI tasks get a
// chance to execute first. // chance to execute first.
CefPostTask(TID_UI, NewCefRunnableFunction(RunTests, thread.get())); CefPostTask(TID_UI, base::Bind(&RunTests, thread.get()));
// Run the CEF message loop. // Run the CEF message loop.
CefRunMessageLoop(); CefRunMessageLoop();

View File

@ -7,10 +7,11 @@
// Include this first to avoid type conflicts with CEF headers. // Include this first to avoid type conflicts with CEF headers.
#include "tests/unittests/chromium_includes.h" #include "tests/unittests/chromium_includes.h"
#include "include/base/cef_bind.h"
#include "include/cef_origin_whitelist.h" #include "include/cef_origin_whitelist.h"
#include "include/cef_callback.h" #include "include/cef_callback.h"
#include "include/cef_runnable.h"
#include "include/cef_scheme.h" #include "include/cef_scheme.h"
#include "include/wrapper/cef_closure_task.h"
#include "tests/unittests/test_handler.h" #include "tests/unittests/test_handler.h"
namespace { namespace {
@ -194,7 +195,7 @@ class ClientSchemeHandler : public CefResourceHandler {
if (test_results_->delay > 0) { if (test_results_->delay > 0) {
// Continue after the delay. // Continue after the delay.
CefPostDelayedTask(TID_IO, CefPostDelayedTask(TID_IO,
NewCefRunnableMethod(callback.get(), &CefCallback::Continue), base::Bind(&CefCallback::Continue, callback),
test_results_->delay); test_results_->delay);
} else { } else {
// Continue immediately. // Continue immediately.
@ -254,8 +255,8 @@ class ClientSchemeHandler : public CefResourceHandler {
if (!has_delayed_) { if (!has_delayed_) {
// Continue after a delay. // Continue after a delay.
CefPostDelayedTask(TID_IO, CefPostDelayedTask(TID_IO,
NewCefRunnableMethod(this, base::Bind(&ClientSchemeHandler::ContinueAfterDelay,
&ClientSchemeHandler::ContinueAfterDelay, callback), this, callback),
test_results_->delay); test_results_->delay);
bytes_read = 0; bytes_read = 0;
return true; return true;

View File

@ -9,8 +9,9 @@
// Include this first to avoid type conflicts with CEF headers. // Include this first to avoid type conflicts with CEF headers.
#include "tests/unittests/chromium_includes.h" #include "tests/unittests/chromium_includes.h"
#include "include/cef_runnable.h" #include "include/base/cef_bind.h"
#include "include/cef_stream.h" #include "include/cef_stream.h"
#include "include/wrapper/cef_closure_task.h"
#include "include/wrapper/cef_stream_resource_handler.h" #include "include/wrapper/cef_stream_resource_handler.h"
#include "testing/gtest/include/gtest/gtest.h" #include "testing/gtest/include/gtest/gtest.h"
#include "tests/unittests/routing_test_handler.h" #include "tests/unittests/routing_test_handler.h"
@ -108,7 +109,7 @@ class ReadTestHandler : public RoutingTestHandler {
#if defined(TIMEOUT_ENABLED) #if defined(TIMEOUT_ENABLED)
// Time out the test after a reasonable period of time. // Time out the test after a reasonable period of time.
CefPostDelayedTask(TID_UI, CefPostDelayedTask(TID_UI,
NewCefRunnableMethod(this, &ReadTestHandler::DestroyTest), 3000); base::Bind(&ReadTestHandler::DestroyTest, this), 3000);
#endif #endif
} }

View File

@ -7,9 +7,10 @@
#include "tests/unittests/test_handler.h" #include "tests/unittests/test_handler.h"
#include "include/base/cef_bind.h"
#include "include/cef_command_line.h" #include "include/cef_command_line.h"
#include "include/cef_runnable.h"
#include "include/cef_stream.h" #include "include/cef_stream.h"
#include "include/wrapper/cef_closure_task.h"
#include "include/wrapper/cef_stream_resource_handler.h" #include "include/wrapper/cef_stream_resource_handler.h"
namespace { namespace {
@ -202,7 +203,7 @@ void TestHandler::SetupComplete() {
void TestHandler::DestroyTest() { void TestHandler::DestroyTest() {
if (!CefCurrentlyOn(TID_UI)) { if (!CefCurrentlyOn(TID_UI)) {
CefPostTask(TID_UI, NewCefRunnableMethod(this, &TestHandler::DestroyTest)); CefPostTask(TID_UI, base::Bind(&TestHandler::DestroyTest, this));
return; return;
} }
@ -236,8 +237,7 @@ void TestHandler::AddResource(const std::string& url,
const std::string& mimeType) { const std::string& mimeType) {
if (!CefCurrentlyOn(TID_IO)) { if (!CefCurrentlyOn(TID_IO)) {
CefPostTask(TID_IO, CefPostTask(TID_IO,
NewCefRunnableMethod(this, &TestHandler::AddResource, url, content, base::Bind(&TestHandler::AddResource, this, url, content, mimeType));
mimeType));
return; return;
} }
@ -253,8 +253,7 @@ void TestHandler::AddResource(const std::string& url,
void TestHandler::ClearResources() { void TestHandler::ClearResources() {
if (!CefCurrentlyOn(TID_IO)) { if (!CefCurrentlyOn(TID_IO)) {
CefPostTask(TID_IO, CefPostTask(TID_IO, base::Bind(&TestHandler::ClearResources, this));
NewCefRunnableMethod(this, &TestHandler::ClearResources));
return; return;
} }
@ -263,7 +262,7 @@ void TestHandler::ClearResources() {
void TestHandler::TestComplete() { void TestHandler::TestComplete() {
if (!CefCurrentlyOn(TID_UI)) { if (!CefCurrentlyOn(TID_UI)) {
CefPostTask(TID_UI, NewCefRunnableMethod(this, &TestHandler::TestComplete)); CefPostTask(TID_UI, base::Bind(&TestHandler::TestComplete, this));
return; return;
} }
@ -276,13 +275,13 @@ void TestHandler::TestComplete() {
void WaitForThread(CefThreadId thread_id) { void WaitForThread(CefThreadId thread_id) {
base::WaitableEvent event(true, false); base::WaitableEvent event(true, false);
CefPostTask(thread_id, NewCefRunnableFunction(&NotifyEvent, &event)); CefPostTask(thread_id, base::Bind(&NotifyEvent, &event));
event.Wait(); event.Wait();
} }
void WaitForThread(CefRefPtr<CefTaskRunner> task_runner) { void WaitForThread(CefRefPtr<CefTaskRunner> task_runner) {
base::WaitableEvent event(true, false); base::WaitableEvent event(true, false);
task_runner->PostTask(NewCefRunnableFunction(&NotifyEvent, &event)); task_runner->PostTask(CefCreateClosureTask(base::Bind(&NotifyEvent, &event)));
event.Wait(); event.Wait();
} }

View File

@ -8,10 +8,11 @@
#include "base/file_util.h" #include "base/file_util.h"
#include "base/synchronization/waitable_event.h" #include "base/synchronization/waitable_event.h"
#include "include/cef_runnable.h" #include "include/base/cef_bind.h"
#include "include/base/cef_trace_event.h"
#include "include/cef_task.h" #include "include/cef_task.h"
#include "include/cef_trace.h" #include "include/cef_trace.h"
#include "include/base/cef_trace_event.h" #include "include/wrapper/cef_closure_task.h"
#include "testing/gtest/include/gtest/gtest.h" #include "testing/gtest/include/gtest/gtest.h"
#include "tests/unittests/test_handler.h" #include "tests/unittests/test_handler.h"
@ -93,8 +94,7 @@ class TracingTestHandler : public CefEndTracingCallback,
base::FilePath file_path(tracing_file); base::FilePath file_path(tracing_file);
CefPostTask(TID_FILE, CefPostTask(TID_FILE,
NewCefRunnableMethod(this, &TracingTestHandler::ReadTracingFile, base::Bind(&TracingTestHandler::ReadTracingFile, this, file_path));
file_path));
} }
void RunTracing() { void RunTracing() {
@ -324,8 +324,7 @@ class TracingTestHandler : public CefEndTracingCallback,
void ExecuteTest() { void ExecuteTest() {
// Run the test. // Run the test.
CefPostTask(TID_UI, CefPostTask(TID_UI, base::Bind(&TracingTestHandler::RunTracing, this));
NewCefRunnableMethod(this, &TracingTestHandler::RunTracing));
// Wait for the test to complete. // Wait for the test to complete.
completion_event_.Wait(); completion_event_.Wait();

View File

@ -17,15 +17,12 @@
#include "include/cef_scheme.h" #include "include/cef_scheme.h"
#include "include/cef_task.h" #include "include/cef_task.h"
#include "include/cef_urlrequest.h" #include "include/cef_urlrequest.h"
#include "include/wrapper/cef_closure_task.h"
#include "testing/gtest/include/gtest/gtest.h" #include "testing/gtest/include/gtest/gtest.h"
#include "tests/cefclient/client_app.h" #include "tests/cefclient/client_app.h"
#include "tests/unittests/test_handler.h" #include "tests/unittests/test_handler.h"
#include "tests/unittests/test_util.h" #include "tests/unittests/test_util.h"
// Include after base/bind.h to avoid name collisions with cef_tuple.h.
#include "include/cef_runnable.h"
// How to add a new test: // How to add a new test:
// 1. Add a new value to the RequestTestMode enumeration. // 1. Add a new value to the RequestTestMode enumeration.
// 2. Add methods to set up and run the test in RequestTestRunner. // 2. Add methods to set up and run the test in RequestTestRunner.
@ -1010,8 +1007,7 @@ class RequestTestHandler : public TestHandler,
} else { } else {
// Execute on the IO thread. // Execute on the IO thread.
CefPostTask(TID_IO, CefPostTask(TID_IO,
NewCefRunnableMethod(this, &RequestTestHandler::SetTestCookie, base::Bind(&RequestTestHandler::SetTestCookie, this, event));
event));
} }
} }
@ -1027,8 +1023,7 @@ class RequestTestHandler : public TestHandler,
} else { } else {
// Execute on the IO thread. // Execute on the IO thread.
CefPostTask(TID_IO, CefPostTask(TID_IO,
NewCefRunnableMethod(this, &RequestTestHandler::ClearTestCookie, base::Bind(&RequestTestHandler::ClearTestCookie, this, event));
event));
} }
} }
@ -1107,8 +1102,7 @@ class InvalidURLTestClient : public CefURLRequestClient {
} }
void RunTest() { void RunTest() {
CefPostTask(TID_UI, CefPostTask(TID_UI, base::Bind(&InvalidURLTestClient::RunOnUIThread, this));
NewCefRunnableMethod(this, &InvalidURLTestClient::RunOnUIThread));
// Wait for the test to complete. // Wait for the test to complete.
event_.Wait(); event_.Wait();
@ -1119,7 +1113,7 @@ class InvalidURLTestClient : public CefURLRequestClient {
// Let the call stack unwind before signaling completion. // Let the call stack unwind before signaling completion.
CefPostTask(TID_UI, CefPostTask(TID_UI,
NewCefRunnableMethod(this, &InvalidURLTestClient::CompleteOnUIThread)); base::Bind(&InvalidURLTestClient::CompleteOnUIThread, this));
} }
virtual void OnUploadProgress(CefRefPtr<CefURLRequest> request, virtual void OnUploadProgress(CefRefPtr<CefURLRequest> request,

View File

@ -7,9 +7,10 @@
// Include this first to avoid type conflicts with CEF headers. // Include this first to avoid type conflicts with CEF headers.
#include "tests/unittests/chromium_includes.h" #include "tests/unittests/chromium_includes.h"
#include "include/cef_runnable.h" #include "include/base/cef_bind.h"
#include "include/cef_task.h" #include "include/cef_task.h"
#include "include/cef_v8.h" #include "include/cef_v8.h"
#include "include/wrapper/cef_closure_task.h"
#include "tests/cefclient/client_app.h" #include "tests/cefclient/client_app.h"
#include "testing/gtest/include/gtest/gtest.h" #include "testing/gtest/include/gtest/gtest.h"
#include "tests/unittests/test_handler.h" #include "tests/unittests/test_handler.h"
@ -1816,8 +1817,7 @@ class V8RendererTest : public ClientApp::RenderDelegate,
test_context_ = test_context_ =
browser_->GetMainFrame()->GetV8Context(); browser_->GetMainFrame()->GetV8Context();
test_object_ = CefV8Value::CreateArray(10); test_object_ = CefV8Value::CreateArray(10);
CefPostTask(TID_RENDERER, CefPostTask(TID_RENDERER, base::Bind(&V8RendererTest::DestroyTest, this));
NewCefRunnableMethod(this, &V8RendererTest::DestroyTest));
} }
} }
@ -1861,8 +1861,7 @@ class V8RendererTest : public ClientApp::RenderDelegate,
const std::string& message_name = message->GetName(); const std::string& message_name = message->GetName();
if (message_name == kV8RunTestMsg) { if (message_name == kV8RunTestMsg) {
// Run the test asynchronously. // Run the test asynchronously.
CefPostTask(TID_RENDERER, CefPostTask(TID_RENDERER, base::Bind(&V8RendererTest::RunTest, this));
NewCefRunnableMethod(this, &V8RendererTest::RunTest));
return true; return true;
} }
return false; return false;