Commit ffa615b3 authored by Sylvain Defresne's avatar Sylvain Defresne Committed by Commit Bot

Convert ui/ to use Bind() for blocks

With https://crrev.com/c/1070158, base::Bind() supports
block via base::RetainBlock(). Converts uses of the now
deprecated base::BindBlock().

Bug: 701275
Cq-Include-Trybots: luci.chromium.try:android_optional_gpu_tests_rel;luci.chromium.try:linux_optional_gpu_tests_rel;luci.chromium.try:mac_optional_gpu_tests_rel;luci.chromium.try:win_optional_gpu_tests_rel
Change-Id: I103584b54f656f10e17c8e2439e0520c7690dbfe
Reviewed-on: https://chromium-review.googlesource.com/1090912Reviewed-by: default avatarAvi Drissman <avi@chromium.org>
Commit-Queue: Sylvain Defresne <sdefresne@chromium.org>
Cr-Commit-Position: refs/heads/master@{#565956}
parent 764d6f31
...@@ -4,9 +4,9 @@ ...@@ -4,9 +4,9 @@
#import "ui/base/cocoa/menu_controller.h" #import "ui/base/cocoa/menu_controller.h"
#include "base/bind.h"
#include "base/cancelable_callback.h" #include "base/cancelable_callback.h"
#include "base/logging.h" #include "base/logging.h"
#include "base/mac/bind_objc_block.h"
#include "base/strings/sys_string_conversions.h" #include "base/strings/sys_string_conversions.h"
#include "base/threading/thread_task_runner_handle.h" #include "base/threading/thread_task_runner_handle.h"
#include "ui/base/accelerators/accelerator.h" #include "ui/base/accelerators/accelerator.h"
...@@ -262,8 +262,8 @@ NSString* const kMenuControllerMenuDidCloseNotification = ...@@ -262,8 +262,8 @@ NSString* const kMenuControllerMenuDidCloseNotification =
// likely if the -cancel happens in the delegate method. // likely if the -cancel happens in the delegate method.
NSMenu* menu = menu_; NSMenu* menu = menu_;
postedItemSelectedTask_ = postedItemSelectedTask_ = std::make_unique<base::CancelableClosure>(
std::make_unique<base::CancelableClosure>(base::BindBlock(^{ base::BindRepeating(base::RetainBlock(^{
id target = [sender target]; id target = [sender target];
if ([target respondsToSelector:@selector(itemSelected:uiEventFlags:)]) if ([target respondsToSelector:@selector(itemSelected:uiEventFlags:)])
[target itemSelected:sender uiEventFlags:uiEventFlags]; [target itemSelected:sender uiEventFlags:uiEventFlags];
...@@ -276,7 +276,7 @@ NSString* const kMenuControllerMenuDidCloseNotification = ...@@ -276,7 +276,7 @@ NSString* const kMenuControllerMenuDidCloseNotification =
// the target can not be set to nil here since that prevents re-use of // the target can not be set to nil here since that prevents re-use of
// the menu for well-behaved consumers. // the menu for well-behaved consumers.
CHECK([menu delegate]); // Note: set to nil in -dealloc. CHECK([menu delegate]); // Note: set to nil in -dealloc.
})); })));
base::ThreadTaskRunnerHandle::Get()->PostTask( base::ThreadTaskRunnerHandle::Get()->PostTask(
FROM_HERE, postedItemSelectedTask_->callback()); FROM_HERE, postedItemSelectedTask_->callback());
} }
......
...@@ -6,8 +6,8 @@ ...@@ -6,8 +6,8 @@
#include <map> #include <map>
#include "base/bind.h"
#include "base/callback_helpers.h" #include "base/callback_helpers.h"
#include "base/mac/bind_objc_block.h"
#include "base/mac/foundation_util.h" #include "base/mac/foundation_util.h"
#include "base/metrics/histogram_macros.h" #include "base/metrics/histogram_macros.h"
#include "base/trace_event/memory_allocator_dump.h" #include "base/trace_event/memory_allocator_dump.h"
...@@ -346,9 +346,10 @@ bool GLImageIOSurface::CopyTexImage(unsigned target) { ...@@ -346,9 +346,10 @@ bool GLImageIOSurface::CopyTexImage(unsigned target) {
return false; return false;
} }
glGetIntegerv(target_getter, &rgb_texture); glGetIntegerv(target_getter, &rgb_texture);
base::ScopedClosureRunner destroy_resources_runner(base::BindBlock(^{ base::ScopedClosureRunner destroy_resources_runner(
glBindTexture(target, rgb_texture); base::BindOnce(base::RetainBlock(^{
})); glBindTexture(target, rgb_texture);
})));
CGLContextObj cgl_context = CGLGetCurrentContext(); CGLContextObj cgl_context = CGLGetCurrentContext();
{ {
......
...@@ -4,8 +4,8 @@ ...@@ -4,8 +4,8 @@
#include "ui/gl/gl_image_io_surface_egl.h" #include "ui/gl/gl_image_io_surface_egl.h"
#include "base/bind.h"
#include "base/callback_helpers.h" #include "base/callback_helpers.h"
#include "base/mac/bind_objc_block.h"
#include "ui/gl/gl_context.h" #include "ui/gl/gl_context.h"
#include "ui/gl/gl_surface_egl.h" #include "ui/gl/gl_surface_egl.h"
#include "ui/gl/scoped_binders.h" #include "ui/gl/scoped_binders.h"
...@@ -196,23 +196,24 @@ bool GLImageIOSurfaceEGL::CopyTexImage(unsigned target) { ...@@ -196,23 +196,24 @@ bool GLImageIOSurfaceEGL::CopyTexImage(unsigned target) {
EGLSurface uv_surface = EGL_NO_SURFACE; EGLSurface uv_surface = EGL_NO_SURFACE;
glGetIntegerv(target_getter, &rgb_texture); glGetIntegerv(target_getter, &rgb_texture);
base::ScopedClosureRunner destroy_resources_runner(base::BindBlock(^{ base::ScopedClosureRunner destroy_resources_runner(
if (y_surface != EGL_NO_SURFACE) { base::BindOnce(base::RetainBlock(^{
EGLBoolean result = if (y_surface != EGL_NO_SURFACE) {
eglReleaseTexImage(display_, y_surface, EGL_BACK_BUFFER); EGLBoolean result =
DCHECK(result == EGL_TRUE); eglReleaseTexImage(display_, y_surface, EGL_BACK_BUFFER);
result = eglDestroySurface(display_, y_surface); DCHECK(result == EGL_TRUE);
DCHECK(result == EGL_TRUE); result = eglDestroySurface(display_, y_surface);
} DCHECK(result == EGL_TRUE);
if (uv_surface != EGL_NO_SURFACE) { }
EGLBoolean result = if (uv_surface != EGL_NO_SURFACE) {
eglReleaseTexImage(display_, uv_surface, EGL_BACK_BUFFER); EGLBoolean result =
DCHECK(result == EGL_TRUE); eglReleaseTexImage(display_, uv_surface, EGL_BACK_BUFFER);
result = eglDestroySurface(display_, uv_surface); DCHECK(result == EGL_TRUE);
DCHECK(result == EGL_TRUE); result = eglDestroySurface(display_, uv_surface);
} DCHECK(result == EGL_TRUE);
glBindTexture(target, rgb_texture); }
})); glBindTexture(target, rgb_texture);
})));
glBindTexture(GL_TEXTURE_RECTANGLE_ARB, yuv_to_rgb_converter->y_texture()); glBindTexture(GL_TEXTURE_RECTANGLE_ARB, yuv_to_rgb_converter->y_texture());
if (glGetError() != GL_NO_ERROR) { if (glGetError() != GL_NO_ERROR) {
......
...@@ -4,8 +4,8 @@ ...@@ -4,8 +4,8 @@
#import "ui/views/cocoa/views_nswindow_delegate.h" #import "ui/views/cocoa/views_nswindow_delegate.h"
#include "base/bind.h"
#include "base/logging.h" #include "base/logging.h"
#import "base/mac/bind_objc_block.h"
#include "base/threading/thread_task_runner_handle.h" #include "base/threading/thread_task_runner_handle.h"
#import "ui/views/cocoa/bridged_content_view.h" #import "ui/views/cocoa/bridged_content_view.h"
#import "ui/views/cocoa/bridged_native_widget.h" #import "ui/views/cocoa/bridged_native_widget.h"
...@@ -117,10 +117,12 @@ ...@@ -117,10 +117,12 @@
// NSWindow delegate, the call to -[NSApp beginSheet:] also took a weak // NSWindow delegate, the call to -[NSApp beginSheet:] also took a weak
// reference to the delegate, which will be destroyed when the sheet's // reference to the delegate, which will be destroyed when the sheet's
// BridgedNativeWidget is destroyed. // BridgedNativeWidget is destroyed.
base::ThreadTaskRunnerHandle::Get()->PostTask(FROM_HERE, base::BindBlock(^{ base::ThreadTaskRunnerHandle::Get()->PostTask(
[sheetParent endSheet:window]; FROM_HERE, base::BindOnce(base::RetainBlock(^{
[[self retain] release]; // Force |self| to be retained for the block. [sheetParent endSheet:window];
})); [[self retain]
release]; // Force |self| to be retained for the block.
})));
} }
DCHECK([window isEqual:[notification object]]); DCHECK([window isEqual:[notification object]]);
parent_->OnWindowWillClose(); parent_->OnWindowWillClose();
......
...@@ -8,8 +8,8 @@ ...@@ -8,8 +8,8 @@
#include <utility> #include <utility>
#include "base/bind.h"
#include "base/command_line.h" #include "base/command_line.h"
#import "base/mac/bind_objc_block.h"
#include "base/mac/foundation_util.h" #include "base/mac/foundation_util.h"
#include "base/mac/scoped_nsobject.h" #include "base/mac/scoped_nsobject.h"
#include "base/strings/sys_string_conversions.h" #include "base/strings/sys_string_conversions.h"
...@@ -416,9 +416,10 @@ void NativeWidgetMac::Close() { ...@@ -416,9 +416,10 @@ void NativeWidgetMac::Close() {
// Many tests assume that base::RunLoop().RunUntilIdle() is always sufficient // Many tests assume that base::RunLoop().RunUntilIdle() is always sufficient
// to execute a close. However, in rare cases, -performSelector:..afterDelay:0 // to execute a close. However, in rare cases, -performSelector:..afterDelay:0
// does not do this. So post a regular task. // does not do this. So post a regular task.
base::ThreadTaskRunnerHandle::Get()->PostTask(FROM_HERE, base::BindBlock(^{ base::ThreadTaskRunnerHandle::Get()->PostTask(
[window close]; FROM_HERE, base::BindOnce(base::RetainBlock(^{
})); [window close];
})));
} }
void NativeWidgetMac::CloseNow() { void NativeWidgetMac::CloseNow() {
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment