Index: branches/2020Q3/www/chromium/Makefile =================================================================== --- branches/2020Q3/www/chromium/Makefile (revision 545068) +++ branches/2020Q3/www/chromium/Makefile (revision 545069) @@ -1,358 +1,358 @@ # Created by: Florent Thoumie # $FreeBSD$ PORTNAME= chromium -PORTVERSION= 84.0.4147.105 +PORTVERSION= 84.0.4147.125 CATEGORIES?= www java MASTER_SITES= https://commondatastorage.googleapis.com/chromium-browser-official/ \ LOCAL/cpm/chromium/:fonts DISTFILES= ${DISTNAME}${EXTRACT_SUFX} MAINTAINER?= chromium@FreeBSD.org COMMENT?= Google web browser based on WebKit LICENSE= BSD3CLAUSE LGPL21 MPL11 LICENSE_COMB= multi BUILD_DEPENDS= bash:shells/bash \ ${PYTHON_PKGNAMEPREFIX}Jinja2>0:devel/py-Jinja2@${PY_FLAVOR} \ ${PYTHON_PKGNAMEPREFIX}ply>0:devel/py-ply@${PY_FLAVOR} \ .if !defined(GN_ONLY) BUILD_DEPENDS+= gperf:devel/gperf \ ffmpeg>=3.2.2,1:multimedia/ffmpeg \ flock:sysutils/flock \ node:www/node \ xcb-proto>0:x11/xcb-proto \ ${LOCALBASE}/bin/ar:devel/binutils \ ${LOCALBASE}/include/linux/videodev2.h:multimedia/v4l_compat \ ${LOCALBASE}/share/usbids/usb.ids:misc/usbids \ ${PYTHON_PKGNAMEPREFIX}html5lib>0:www/py-html5lib@${PY_FLAVOR} .endif .if !defined(GN_ONLY) LIB_DEPENDS= libatk-bridge-2.0.so:accessibility/at-spi2-atk \ libatspi.so:accessibility/at-spi2-core \ libspeechd.so:accessibility/speech-dispatcher \ libsnappy.so:archivers/snappy \ libFLAC.so:audio/flac \ libopus.so:audio/opus \ libspeex.so:audio/speex \ libdbus-1.so:devel/dbus \ libdbus-glib-1.so:devel/dbus-glib \ libicuuc.so:devel/icu \ libjsoncpp.so:devel/jsoncpp \ libpci.so:devel/libpci \ libnspr4.so:devel/nspr \ libre2.so:devel/re2 \ libcairo.so:graphics/cairo \ libdrm.so:graphics/libdrm \ libexif.so:graphics/libexif \ libpng.so:graphics/png \ libwebp.so:graphics/webp \ libavcodec.so:multimedia/ffmpeg \ libopenh264.so:multimedia/openh264 \ libfreetype.so:print/freetype2 \ libharfbuzz.so:print/harfbuzz \ libharfbuzz-icu.so:print/harfbuzz-icu \ libgcrypt.so:security/libgcrypt \ libsecret-1.so:security/libsecret \ libnss3.so:security/nss \ libexpat.so:textproc/expat2 \ libfontconfig.so:x11-fonts/fontconfig RUN_DEPENDS= xdg-open:devel/xdg-utils \ noto-basic>0:x11-fonts/noto-basic BROKEN_FreeBSD_11_aarch64= components/safe_browsing_db/v4_rice.cc:120:18: use of overloaded operator '&' is ambiguous ONLY_FOR_ARCHS= aarch64 amd64 i386 .endif .if defined(GN_ONLY) USES= compiler:c++14-lang dos2unix localbase:ldflags ninja pkgconfig \ python:2.7,build shebangfix tar:xz .else USES= bison cpe desktop-file-utils dos2unix gl gnome jpeg localbase:ldflags \ ninja perl5 pkgconfig python:2.7,build shebangfix tar:xz xorg .endif MAKE_ARGS= -C out/${BUILDTYPE} BINARY_ALIAS= python=${PYTHON_CMD} DOS2UNIX_FILES= third_party/skia/third_party/vulkanmemoryallocator/include/vk_mem_alloc.h .if !defined(GN_ONLY) CPE_VENDOR= google CPE_PRODUCT= chrome USE_GL= gl USE_LDCONFIG= ${DATADIR} USE_PERL5= build USE_XORG= x11 xcb xcomposite xcursor xext xdamage xfixes xi \ xorgproto xrandr xrender xscrnsaver xtst USE_GNOME= atk dconf glib20 gtk30 libxml2 libxslt SHEBANG_FILES= chrome/tools/build/linux/chrome-wrapper buildtools/linux64/clang-format ALL_TARGET= chrome INSTALLS_ICONS= yes .endif EXTRA_PATCHES+= ${FILESDIR}/extra-patch-clang # TODO bz@ : install libwidevinecdm.so (see third_party/widevine/cdm/BUILD.gn) # # Run "./out/${BUILDTYPE}/gn args out/${BUILDTYPE} --list" for all variables. # Some parts don't have use_system_* flag, and can be turned on/off by using # replace_gn_files.py script, some parts just turned on/off for target host # OS "target_os == is_bsd", like libusb, libpci. GN_ARGS+= clang_use_chrome_plugins=false \ enable_hangout_services_extension=true \ enable_nacl=false \ enable_one_click_signin=true \ enable_remoting=false \ fieldtrial_testing_like_official_build=true \ is_clang=true \ toolkit_views=true \ treat_warnings_as_errors=false \ use_allocator="none" \ use_allocator_shim=false \ use_aura=true \ use_custom_libcxx=false \ use_gnome_keyring=false \ use_lld=true \ use_sysroot=false \ use_system_freetype=true \ use_system_harfbuzz=true \ use_system_libjpeg=true \ extra_cxxflags="${CXXFLAGS}" \ extra_ldflags="${LDFLAGS}" # TODO: investigate building with these options: # use_system_minigbm GN_BOOTSTRAP_FLAGS= --no-clean --no-rebuild --skip-generate-buildfiles # FreeBSD Chromium Api Key # Set up Google API keys, see http://www.chromium.org/developers/how-tos/api-keys . # Note: these are for FreeBSD use ONLY. For your own distribution, # please get your own set of keys. GN_ARGS+= google_api_key="AIzaSyBsp9n41JLW8jCokwn7vhoaMejDFRd1mp8" \ google_default_client_id="996322985003.apps.googleusercontent.com" \ google_default_client_secret="IR1za9-1VK0zZ0f_O8MVFicn" .if !defined(GN_ONLY) SUB_FILES= chromium-browser.desktop chrome pkg-message SUB_LIST+= COMMENT="${COMMENT}" OPTIONS_DEFINE= CODECS CUPS DEBUG DRIVER KERBEROS TEST CODECS_DESC= Compile and enable patented codecs like H.264 DRIVER_DESC= Install chromedriver OPTIONS_GROUP= AUDIO OPTIONS_GROUP_AUDIO= ALSA PULSEAUDIO SNDIO OPTIONS_DEFAULT= ALSA CODECS CUPS DRIVER KERBEROS OPTIONS_SUB= yes ALSA_LIB_DEPENDS= libasound.so:audio/alsa-lib ALSA_RUN_DEPENDS= ${LOCALBASE}/lib/alsa-lib/libasound_module_pcm_oss.so:audio/alsa-plugins \ alsa-lib>=1.1.1_1:audio/alsa-lib ALSA_VARS= GN_ARGS+=use_alsa=true ALSA_VARS_OFF= GN_ARGS+=use_alsa=false CODECS_VARS= GN_ARGS+=ffmpeg_branding="Chrome" \ GN_ARGS+=proprietary_codecs=true CODECS_VARS_OFF= GN_ARGS+=ffmpeg_branding="Chromium" \ GN_ARGS+=proprietary_codecs=false CUPS_LIB_DEPENDS= libcups.so:print/cups CUPS_VARS= GN_ARGS+=use_cups=true CUPS_VARS_OFF= GN_ARGS+=use_cups=false DEBUG_VARS= BUILDTYPE=Debug \ GN_ARGS+=is_debug=true \ GN_ARGS+=is_component_build=false \ GN_ARGS+=symbol_level=1 \ GN_BOOTSTRAP_FLAGS+=--debug \ WANTSPACE="lots of free disk space (~ 13GB)" DEBUG_VARS_OFF= BUILDTYPE=Release \ GN_ARGS+=blink_symbol_level=0 \ GN_ARGS+=is_debug=false \ GN_ARGS+=is_official_build=true \ GN_ARGS+=symbol_level=0 \ WANTSPACE="a fair amount of free disk space (~ 6.5GB)" DRIVER_MAKE_ARGS= chromedriver KERBEROS_VARS= GN_ARGS+=use_kerberos=true KERBEROS_VARS_OFF= GN_ARGS+=use_kerberos=false PULSEAUDIO_LIB_DEPENDS= libpulse.so:audio/pulseaudio PULSEAUDIO_VARS= GN_ARGS+=use_pulseaudio=true PULSEAUDIO_VARS_OFF= GN_ARGS+=use_pulseaudio=false # With SNDIO=on we exclude audio_manager_linux from the build (see # media/audio/BUILD.gn) and use audio_manager_openbsd which does not # support falling back to ALSA or PulseAudio. SNDIO_PREVENTS= ALSA PULSEAUDIO SNDIO_LIB_DEPENDS= libsndio.so:audio/sndio SNDIO_VARS= GN_ARGS+=use_sndio=true SNDIO_VARS_OFF= GN_ARGS+=use_sndio=false .endif .include "Makefile.tests" TEST_ALL_TARGET= ${TEST_TARGETS} TEST_DISTFILES= ${PORTNAME}-${DISTVERSION}-testdata${EXTRACT_SUFX} \ test_fonts${EXTRACT_SUFX}:fonts .include # swiftshader/lib/{libEGL.so,libGLESv2.so} is x86 only .if ${ARCH} == aarch64 PLIST_SUB+= NOT_AARCH64="@comment " .else PLIST_SUB+= NOT_AARCH64="" .endif # Make better javascript with java .if !defined(GN_ONLY) JAVA_BUILD= yes JAVA_VERSION= 1.8 USE_JAVA= yes .endif # Allow relocations against read-only segments (override lld default) LDFLAGS_i386= -Wl,-znotext # TODO: -isystem, would be just as ugly as this approach, but more reliably # build would fail without C_INCLUDE_PATH/CPLUS_INCLUDE_PATH env var set. MAKE_ENV+= C_INCLUDE_PATH=${LOCALBASE}/include \ CPLUS_INCLUDE_PATH=${LOCALBASE}/include .if !defined(GN_ONLY) pre-everything:: @${ECHO_MSG} @${ECHO_MSG} "To build Chromium, you should have around 2GB of memory" @${ECHO_MSG} "and ${WANTSPACE}." @${ECHO_MSG} post-extract-TEST-on: @${MKDIR} ${WRKSRC}/third_party/test_fonts/test_fonts @${MV} ${WRKDIR}/test_fonts ${WRKSRC}/third_party/test_fonts/ post-patch: @${REINPLACE_CMD} -e 's|@@PACKAGE@@|chromium|' \ -e 's|@@MENUNAME@@|Chromium Web Browser|' \ ${WRKSRC}/chrome/app/resources/manpage.1.in post-patch-SNDIO-on: @${MKDIR} ${WRKSRC}/media/audio/sndio ${WRKSRC}/media/audio/openbsd @${CP} ${FILESDIR}/sndio_output.* ${WRKSRC}/media/audio/sndio @${CP} ${FILESDIR}/sndio_input.* ${WRKSRC}/media/audio/sndio @${CP} ${FILESDIR}/audio_manager_openbsd.* ${WRKSRC}/media/audio/openbsd pre-configure: # We used to remove bundled libraries to be sure that chromium uses # system libraries and not shipped ones. # cd ${WRKSRC} && ${PYTHON_CMD} \ #./build/linux/unbundle/remove_bundled_libraries.py [list of preserved] cd ${WRKSRC} && ${SETENV} ${CONFIGURE_ENV} ${PYTHON_CMD} \ ./build/linux/unbundle/replace_gn_files.py --system-libraries \ ffmpeg flac fontconfig freetype harfbuzz-ng libdrm libpng libwebp libxml libxslt openh264 opus snappy || ${FALSE} # We need the site package from xcbgen, which installs as python3.x (really: default version), while the chromium # build still needs to use python2.7. It works, because xcbgen can run with both versions, but we want to avoid # having the pre-compiled pyc files from 2.7 in the 3.x site packages # Remove this as soon as chromium uses python3.x as well @${MKDIR} ${WRKDIR}/site-packages/xcbgen ${CP} ${PYTHONBASE}/lib/python${PYTHON_DEFAULT}/site-packages/xcbgen/*.py \ ${WRKDIR}/site-packages/xcbgen .endif do-configure: # GN generator bootstrapping and generating ninja files cd ${WRKSRC} && ${SETENV} ${CONFIGURE_ENV} CC=${CC} CXX=${CXX} LD=${CXX} \ READELF=${READELF} AR=${AR} NM=${NM} ${PYTHON_CMD} \ ./tools/gn/bootstrap/bootstrap.py ${GN_BOOTSTRAP_FLAGS} .if !defined(GN_ONLY) cd ${WRKSRC} && ${SETENV} ${CONFIGURE_ENV} ./out/${BUILDTYPE}/gn \ gen --args='${GN_ARGS}' out/${BUILDTYPE} # Setup nodejs dependency @${MKDIR} ${WRKSRC}/third_party/node/freebsd/node-freebsd-x64/bin ${LN} -sf ${LOCALBASE}/bin/node ${WRKSRC}/third_party/node/freebsd/node-freebsd-x64/bin/node # Setup java dependency on amd64 and i386 .if ${ARCH} == amd64 || ${ARCH} == i386 @${MKDIR} ${WRKDIR}/bin ${LN} -sf ${LOCALBASE}/openjdk8/bin/java ${WRKDIR}/bin/java .endif # Setup buildtools/freebsd @${MKDIR} ${WRKSRC}/buildtools/freebsd ${LN} -sf ${WRKSRC}/buildtools/linux64/clang-format ${WRKSRC}/buildtools/freebsd ${LN} -sf ${WRKSRC}/out/${BUILDTYPE}/gn ${WRKSRC}/buildtools/freebsd .endif do-test-TEST-on: .for t in ${TEST_TARGETS} cd ${WRKSRC}/out/${BUILDTYPE} && ${SETENV} LC_ALL=en_US.UTF-8 \ ./${t} --gtest_filter=-${EXCLUDE_${t}:ts:} || ${TRUE} .endfor .if !defined(GN_ONLY) do-install: @${MKDIR} ${STAGEDIR}${DATADIR} ${INSTALL_MAN} ${WRKSRC}/chrome/app/resources/manpage.1.in \ ${STAGEDIR}${MANPREFIX}/man/man1/chrome.1 ${CP} ${WRKSRC}/chrome/app/theme/chromium/product_logo_22_mono.png ${WRKSRC}/chrome/app/theme/chromium/product_logo_22.png .for s in 22 24 48 64 128 256 @${MKDIR} ${STAGEDIR}${PREFIX}/share/icons/hicolor/${s}x${s}/apps ${INSTALL_DATA} ${WRKSRC}/chrome/app/theme/chromium/product_logo_${s}.png \ ${STAGEDIR}${PREFIX}/share/icons/hicolor/${s}x${s}/apps/chrome.png .endfor ${INSTALL_DATA} ${WRKSRC}/out/${BUILDTYPE}/*.png ${STAGEDIR}${DATADIR} ${INSTALL_DATA} ${WRKSRC}/out/${BUILDTYPE}/*.pak ${STAGEDIR}${DATADIR} .for d in protoc mksnapshot ${INSTALL_PROGRAM} ${WRKSRC}/out/${BUILDTYPE}/${d} ${STAGEDIR}${DATADIR} .endfor .for d in icudtl.dat snapshot_blob.bin v8_context_snapshot.bin ${INSTALL_DATA} ${WRKSRC}/out/${BUILDTYPE}/${d} ${STAGEDIR}${DATADIR} .endfor ${INSTALL_PROGRAM} ${WRKSRC}/out/${BUILDTYPE}/chrome \ ${STAGEDIR}${DATADIR} cd ${WRKSRC}/out/${BUILDTYPE} && \ ${COPYTREE_SHARE} "locales resources" ${STAGEDIR}${DATADIR} @${MKDIR} ${STAGEDIR}${DESKTOPDIR} ${INSTALL_DATA} ${WRKDIR}/chromium-browser.desktop \ ${STAGEDIR}${DESKTOPDIR} ${INSTALL_SCRIPT} ${WRKDIR}/chrome ${STAGEDIR}${PREFIX}/bin ${INSTALL_SCRIPT} ${WRKSRC}/chrome/tools/build/linux/chrome-wrapper \ ${STAGEDIR}${DATADIR} # ANGLE, EGL, Vk .for f in libEGL.so libGLESv2.so libVkICD_mock_icd.so ${INSTALL_LIB} ${WRKSRC}/out/${BUILDTYPE}/${f} ${STAGEDIR}${DATADIR} .endfor .if ${BUILDTYPE} == Debug ${INSTALL_LIB} ${WRKSRC}/out/${BUILDTYPE}/libVkLayer_khronos_validation.so ${STAGEDIR}${DATADIR} .endif # SwiftShader .if ${ARCH} != aarch64 @${MKDIR} ${STAGEDIR}${DATADIR}/swiftshader ${INSTALL_LIB} ${WRKSRC}/out/${BUILDTYPE}/libvk_swiftshader.so ${STAGEDIR}${DATADIR} .for g in libEGL.so libGLESv2.so ${INSTALL_LIB} ${WRKSRC}/out/${BUILDTYPE}/swiftshader/${g} \ ${STAGEDIR}${DATADIR}/swiftshader .endfor .endif post-install-DEBUG-on: ${INSTALL_LIB} ${WRKSRC}/out/${BUILDTYPE}/*.so \ ${STAGEDIR}${DATADIR} ${INSTALL_PROGRAM} ${WRKSRC}/out/${BUILDTYPE}/character_data_generator \ ${STAGEDIR}${DATADIR} post-install-DRIVER-on: ${INSTALL_PROGRAM} ${WRKSRC}/out/${BUILDTYPE}/chromedriver \ ${STAGEDIR}${PREFIX}/bin .endif .include Index: branches/2020Q3/www/chromium/distinfo =================================================================== --- branches/2020Q3/www/chromium/distinfo (revision 545068) +++ branches/2020Q3/www/chromium/distinfo (revision 545069) @@ -1,7 +1,7 @@ -TIMESTAMP = 1595931907 -SHA256 (chromium-84.0.4147.105.tar.xz) = caf4ebeb2a2333454c3067a2534aeecaab5029aa78fc0d8b27f79ad3b9c5ccac -SIZE (chromium-84.0.4147.105.tar.xz) = 845167500 -SHA256 (chromium-84.0.4147.105-testdata.tar.xz) = 571cfaa82ea28413b22e65907d0ecdb055e02142f8e1b86f3fe2f1bb9557ac03 -SIZE (chromium-84.0.4147.105-testdata.tar.xz) = 257190208 +TIMESTAMP = 1597145794 +SHA256 (chromium-84.0.4147.125.tar.xz) = 98439626cf2d8d3d8f9486d08a99cbc1e4981b3f3427a072d5eaaf6ded4daff5 +SIZE (chromium-84.0.4147.125.tar.xz) = 846433536 +SHA256 (chromium-84.0.4147.125-testdata.tar.xz) = 7058620db4c8b20034fa3d9416046366921971c77e71c5d65697453d0ce7b3a5 +SIZE (chromium-84.0.4147.125-testdata.tar.xz) = 257151900 SHA256 (test_fonts.tar.xz) = cf9cbe3b7f1c4c42d426bddc65ec178d333ad7e205a36fe0a606a3c0c545ece1 SIZE (test_fonts.tar.xz) = 200040 Index: branches/2020Q3/www/chromium/files/patch-services_device_hid_hid__connection__freebsd.cc =================================================================== --- branches/2020Q3/www/chromium/files/patch-services_device_hid_hid__connection__freebsd.cc (revision 545068) +++ branches/2020Q3/www/chromium/files/patch-services_device_hid_hid__connection__freebsd.cc (revision 545069) @@ -1,243 +1,243 @@ ---- services/device/hid/hid_connection_freebsd.cc.orig 2019-05-04 09:19:19 UTC -+++ services/device/hid/hid_connection_freebsd.cc +--- services/device/hid/hid_connection_freebsd.cc.orig 2020-07-18 19:40:14.410523000 -0700 ++++ services/device/hid/hid_connection_freebsd.cc 2020-07-21 19:49:59.569331000 -0700 @@ -0,0 +1,240 @@ +// Copyright (c) 2014 The Chromium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +#include "services/device/hid/hid_connection_freebsd.h" + +#include +#include + +#include "base/bind.h" +#include "base/files/file_descriptor_watcher_posix.h" +#include "base/location.h" +#include "base/numerics/safe_math.h" +#include "base/posix/eintr_wrapper.h" +#include "base/single_thread_task_runner.h" +#include "base/strings/stringprintf.h" +#include "base/task/post_task.h" +#include "base/threading/scoped_blocking_call.h" +#include "base/threading/thread_restrictions.h" +#include "base/threading/thread_task_runner_handle.h" +#include "components/device_event_log/device_event_log.h" +#include "services/device/hid/hid_service.h" + +namespace device { + -+class HidConnectionFreeBSD::BlockingTaskHelper { ++class HidConnectionFreeBSD::BlockingTaskRunnerHelper { + public: -+ BlockingTaskHelper(base::ScopedFD fd, ++ BlockingTaskRunnerHelper(base::ScopedFD fd, + scoped_refptr device_info, + base::WeakPtr connection) + : fd_(std::move(fd)), + connection_(connection), + origin_task_runner_(base::ThreadTaskRunnerHandle::Get()) { + DETACH_FROM_SEQUENCE(sequence_checker_); + // Report buffers must always have room for the report ID. + report_buffer_size_ = device_info->max_input_report_size() + 1; + has_report_id_ = device_info->has_report_id(); + } + -+ ~BlockingTaskHelper() { DCHECK_CALLED_ON_VALID_SEQUENCE(sequence_checker_); } ++ ~BlockingTaskRunnerHelper() { DCHECK_CALLED_ON_VALID_SEQUENCE(sequence_checker_); } + + // Starts the FileDescriptorWatcher that reads input events from the device. + // Must be called on a thread that has a base::MessageLoopForIO. + void Start() { + DCHECK_CALLED_ON_VALID_SEQUENCE(sequence_checker_); + base::internal::AssertBlockingAllowed(); + + file_watcher_ = base::FileDescriptorWatcher::WatchReadable( -+ fd_.get(), base::Bind(&BlockingTaskHelper::OnFileCanReadWithoutBlocking, ++ fd_.get(), base::Bind(&BlockingTaskRunnerHelper::OnFileCanReadWithoutBlocking, + base::Unretained(this))); + } + + void Write(scoped_refptr buffer, + WriteCallback callback) { + DCHECK_CALLED_ON_VALID_SEQUENCE(sequence_checker_); + base::ScopedBlockingCall scoped_blocking_call( + FROM_HERE, base::BlockingType::MAY_BLOCK); + + auto data = buffer->front(); + size_t size = buffer->size(); + // if report id is 0, it shouldn't be included + if (data[0] == 0) { + data++; + size--; + } + + ssize_t result = HANDLE_EINTR(write(fd_.get(), data, size)); + if (result < 0) { + HID_PLOG(EVENT) << "Write failed"; + origin_task_runner_->PostTask(FROM_HERE, base::BindOnce(std::move(callback), false)); + } else { + if (static_cast(result) != size) + HID_LOG(EVENT) << "Incomplete HID write: " << result << " != " << size; + origin_task_runner_->PostTask(FROM_HERE, base::BindOnce(std::move(callback), true)); + } + } + + void GetFeatureReport(uint8_t report_id, + scoped_refptr buffer, + ReadCallback callback) { + DCHECK_CALLED_ON_VALID_SEQUENCE(sequence_checker_); + base::ScopedBlockingCall scoped_blocking_call( + FROM_HERE, base::BlockingType::MAY_BLOCK); + struct usb_gen_descriptor ugd; + ugd.ugd_report_type = UHID_FEATURE_REPORT; + ugd.ugd_data = buffer->front(); + ugd.ugd_maxlen = buffer->size(); + int result = HANDLE_EINTR( + ioctl(fd_.get(), USB_GET_REPORT, &ugd)); + if (result < 0) { + HID_PLOG(EVENT) << "Failed to get feature report"; + origin_task_runner_->PostTask(FROM_HERE, + base::BindOnce(std::move(callback), false, nullptr, 0)); + } else if (result == 0) { + HID_LOG(EVENT) << "Get feature result too short."; + origin_task_runner_->PostTask(FROM_HERE, + base::BindOnce(std::move(callback), false, nullptr, 0)); + } else { + origin_task_runner_->PostTask(FROM_HERE, + base::BindOnce(std::move(callback), true, buffer, result)); + } + } + + void SendFeatureReport(scoped_refptr buffer, + WriteCallback callback) { + DCHECK_CALLED_ON_VALID_SEQUENCE(sequence_checker_); + struct usb_gen_descriptor ugd; + ugd.ugd_report_type = UHID_FEATURE_REPORT; + ugd.ugd_data = buffer->front(); + ugd.ugd_maxlen = buffer->size(); + // FreeBSD does not require report id if it's not used + if (buffer->front()[0] == 0) { + ugd.ugd_data = buffer->front() + 1; + ugd.ugd_maxlen = buffer->size() - 1; + } else { + ugd.ugd_data = buffer->front(); + ugd.ugd_maxlen = buffer->size(); + } + int result = HANDLE_EINTR( + ioctl(fd_.get(), USB_SET_REPORT, &ugd)); + if (result < 0) { + HID_PLOG(EVENT) << "Failed to send feature report"; + origin_task_runner_->PostTask(FROM_HERE, + base::BindOnce(std::move(callback), false)); + } else { + origin_task_runner_->PostTask(FROM_HERE, + base::BindOnce(std::move(callback), true)); + } + } + + private: + void OnFileCanReadWithoutBlocking() { + DCHECK_CALLED_ON_VALID_SEQUENCE(sequence_checker_); + + scoped_refptr buffer(new base::RefCountedBytes(report_buffer_size_)); + unsigned char* data = buffer->front(); + size_t length = report_buffer_size_; + if (!has_report_id_) { + // FreeBSD will not prefix the buffer with a report ID if report IDs are not + // used by the device. Prefix the buffer with 0. + *data++ = 0; + length--; + } + + ssize_t bytes_read = HANDLE_EINTR(read(fd_.get(), data, length)); + if (bytes_read < 0) { + if (errno != EAGAIN) { + HID_PLOG(EVENT) << "Read failed"; + // This assumes that the error is unrecoverable and disables reading + // from the device until it has been re-opened. + // TODO(reillyg): Investigate starting and stopping the file descriptor + // watcher in response to pending read requests so that per-request + // errors can be returned to the client. + file_watcher_.reset(); + } + return; + } + if (!has_report_id_) { + // Behave as if the byte prefixed above as the the report ID was read. + bytes_read++; + } + + origin_task_runner_->PostTask( + FROM_HERE, base::BindOnce(&HidConnectionFreeBSD::ProcessInputReport, + connection_, buffer, bytes_read)); + } + + SEQUENCE_CHECKER(sequence_checker_); + base::ScopedFD fd_; + size_t report_buffer_size_; + bool has_report_id_; + base::WeakPtr connection_; + const scoped_refptr origin_task_runner_; + std::unique_ptr file_watcher_; + -+ DISALLOW_COPY_AND_ASSIGN(BlockingTaskHelper); ++ DISALLOW_COPY_AND_ASSIGN(BlockingTaskRunnerHelper); +}; + +HidConnectionFreeBSD::HidConnectionFreeBSD( + scoped_refptr device_info, + base::ScopedFD fd, + scoped_refptr blocking_task_runner) + : HidConnection(device_info), -+ blocking_task_runner_(std::move(blocking_task_runner)), -+ weak_factory_(this) { -+ helper_ = std::make_unique(std::move(fd), device_info, -+ weak_factory_.GetWeakPtr()); ++ helper_(nullptr, base::OnTaskRunnerDeleter(blocking_task_runner)), ++ blocking_task_runner_(std::move(blocking_task_runner)) { ++ helper_.reset(new BlockingTaskRunnerHelper(std::move(fd), device_info, ++ weak_factory_.GetWeakPtr())); + blocking_task_runner_->PostTask( -+ FROM_HERE, base::BindOnce(&BlockingTaskHelper::Start, ++ FROM_HERE, base::BindOnce(&BlockingTaskRunnerHelper::Start, + base::Unretained(helper_.get()))); +} + +HidConnectionFreeBSD::~HidConnectionFreeBSD() {} + +void HidConnectionFreeBSD::PlatformClose() { + // By closing the device on the blocking task runner 1) the requirement that + // base::ScopedFD is destroyed on a thread where I/O is allowed is satisfied + // and 2) any tasks posted to this task runner that refer to this file will + // complete before it is closed. + blocking_task_runner_->DeleteSoon(FROM_HERE, helper_.release()); +} + +void HidConnectionFreeBSD::PlatformWrite(scoped_refptr buffer, + WriteCallback callback) { + + blocking_task_runner_->PostTask( + FROM_HERE, -+ base::BindOnce(&BlockingTaskHelper::Write, base::Unretained(helper_.get()), ++ base::BindOnce(&BlockingTaskRunnerHelper::Write, base::Unretained(helper_.get()), + buffer, std::move(callback))); +} + +void HidConnectionFreeBSD::PlatformGetFeatureReport(uint8_t report_id, + ReadCallback callback) { + // The first byte of the destination buffer is the report ID being requested + // and is overwritten by the feature report. + DCHECK_GT(device_info()->max_feature_report_size(), 0u); + scoped_refptr buffer( + new base::RefCountedBytes(device_info()->max_feature_report_size() + 1)); + if (report_id != 0) + buffer->data()[0] = report_id; + + blocking_task_runner_->PostTask( + FROM_HERE, -+ base::BindOnce(&BlockingTaskHelper::GetFeatureReport, ++ base::BindOnce(&BlockingTaskRunnerHelper::GetFeatureReport, + base::Unretained(helper_.get()), report_id, + buffer, std::move(callback))); +} + +void HidConnectionFreeBSD::PlatformSendFeatureReport( + scoped_refptr buffer, + WriteCallback callback) { + base::ScopedBlockingCall scoped_blocking_call( + FROM_HERE, base::BlockingType::MAY_BLOCK); + blocking_task_runner_->PostTask( + FROM_HERE, -+ base::BindOnce(&BlockingTaskHelper::SendFeatureReport, ++ base::BindOnce(&BlockingTaskRunnerHelper::SendFeatureReport, + base::Unretained(helper_.get()), buffer, std::move(callback))); +} + +} // namespace device Index: branches/2020Q3/www/chromium/files/patch-services_device_hid_hid__connection__freebsd.h =================================================================== --- branches/2020Q3/www/chromium/files/patch-services_device_hid_hid__connection__freebsd.h (revision 545068) +++ branches/2020Q3/www/chromium/files/patch-services_device_hid_hid__connection__freebsd.h (revision 545069) @@ -1,71 +1,68 @@ ---- services/device/hid/hid_connection_freebsd.h.orig 2019-05-01 15:21:27 UTC -+++ services/device/hid/hid_connection_freebsd.h -@@ -0,0 +1,68 @@ +--- services/device/hid/hid_connection_freebsd.h.orig 2020-07-18 19:40:14.412550000 -0700 ++++ services/device/hid/hid_connection_freebsd.h 2020-07-21 19:15:28.613027000 -0700 +@@ -0,0 +1,65 @@ +// Copyright (c) 2014 The Chromium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +#ifndef DEVICE_HID_HID_CONNECTION_FREEBSD_H_ +#define DEVICE_HID_HID_CONNECTION_FREEBSD_H_ + +#include +#include + +#include "base/files/scoped_file.h" +#include "base/macros.h" -+#include "base/memory/ptr_util.h" -+#include "base/memory/ref_counted_memory.h" +#include "base/memory/weak_ptr.h" -+#include "base/sequence_checker.h" ++#include "base/memory/ref_counted_memory.h" ++#include "base/sequenced_task_runner.h" +#include "services/device/hid/hid_connection.h" + +namespace base { +class SequencedTaskRunner; +} + +namespace net { +class IOBuffer; +} + +namespace device { + +class HidConnectionFreeBSD : public HidConnection { + public: + HidConnectionFreeBSD( + scoped_refptr device_info, + base::ScopedFD fd, + scoped_refptr blocking_task_runner); + + private: + friend class base::RefCountedThreadSafe; -+ class BlockingTaskHelper; ++ class BlockingTaskRunnerHelper; + + ~HidConnectionFreeBSD() override; + + // HidConnection implementation. + void PlatformClose() override; + void PlatformWrite(scoped_refptr buffer, + WriteCallback callback) override; + void PlatformGetFeatureReport(uint8_t report_id, + ReadCallback callback) override; + void PlatformSendFeatureReport(scoped_refptr buffer, + WriteCallback callback) override; + + // |helper_| lives on the sequence to which |blocking_task_runner_| posts + // tasks so all calls must be posted there including this object's + // destruction. -+ std::unique_ptr helper_; ++ std::unique_ptr helper_; + + const scoped_refptr blocking_task_runner_; + const scoped_refptr task_runner_; + -+ SEQUENCE_CHECKER(sequence_checker_); -+ -+ base::WeakPtrFactory weak_factory_; ++ base::WeakPtrFactory weak_factory_{this}; + + DISALLOW_COPY_AND_ASSIGN(HidConnectionFreeBSD); +}; + +} // namespace device + +#endif // DEVICE_HID_HID_CONNECTION_FREEBSD_H_ Index: branches/2020Q3/www/chromium/files/patch-services_device_hid_hid__service__freebsd.cc =================================================================== --- branches/2020Q3/www/chromium/files/patch-services_device_hid_hid__service__freebsd.cc (revision 545068) +++ branches/2020Q3/www/chromium/files/patch-services_device_hid_hid__service__freebsd.cc (revision 545069) @@ -1,386 +1,385 @@ ---- services/device/hid/hid_service_freebsd.cc.orig 2020-03-17 15:11:01 UTC -+++ services/device/hid/hid_service_freebsd.cc -@@ -0,0 +1,383 @@ +--- services/device/hid/hid_service_freebsd.cc.orig 2020-07-18 19:40:14.415772000 -0700 ++++ services/device/hid/hid_service_freebsd.cc 2020-07-21 20:00:55.322907000 -0700 +@@ -0,0 +1,382 @@ +// Copyright 2014 The Chromium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +#include "services/device/hid/hid_service_freebsd.h" + +#include +#include +#include +#include + +#include +#include +#include + +#include "base/bind.h" +#include "base/files/file_descriptor_watcher_posix.h" +#include "base/files/file_enumerator.h" +#include "base/files/file_util.h" +#include "base/files/file.h" +#include "base/location.h" +#include "base/logging.h" +#include "base/posix/eintr_wrapper.h" +#include "base/single_thread_task_runner.h" +#include "base/stl_util.h" +#include "base/strings/pattern.h" +#include "base/strings/stringprintf.h" +#include "base/strings/sys_string_conversions.h" +#include "base/strings/string_util.h" +#include "base/strings/string_split.h" +#include "base/task/post_task.h" +#include "base/threading/scoped_blocking_call.h" +#include "base/threading/thread_task_runner_handle.h" +#include "components/device_event_log/device_event_log.h" +#include "services/device/hid/hid_connection_freebsd.h" + +const int kMaxPermissionChecks = 5; + +namespace device { + +struct HidServiceFreeBSD::ConnectParams { + ConnectParams(scoped_refptr device_info, + ConnectCallback callback) + : device_info(std::move(device_info)), + callback(std::move(callback)), + task_runner(base::ThreadTaskRunnerHandle::Get()), + blocking_task_runner( -+ base::CreateSequencedTaskRunner(kBlockingTaskTraits)) {} ++ base::ThreadPool::CreateSequencedTaskRunner(kBlockingTaskTraits)) {} + ~ConnectParams() {} + + scoped_refptr device_info; + ConnectCallback callback; + scoped_refptr task_runner; + scoped_refptr blocking_task_runner; + base::ScopedFD fd; +}; + -+class HidServiceFreeBSD::BlockingTaskHelper { ++class HidServiceFreeBSD::BlockingTaskRunnerHelper { + public: -+ BlockingTaskHelper(base::WeakPtr service) ++ BlockingTaskRunnerHelper(base::WeakPtr service) + : service_(std::move(service)), + task_runner_(base::ThreadTaskRunnerHandle::Get()) { + DETACH_FROM_SEQUENCE(sequence_checker_); + + timer_.reset(new base::RepeatingTimer()); + devd_buffer_ = new net::IOBufferWithSize(1024); + } + -+ ~BlockingTaskHelper() { ++ ~BlockingTaskRunnerHelper() { + } + + void Start() { + DCHECK_CALLED_ON_VALID_SEQUENCE(sequence_checker_); + + const base::FilePath kDevRoot("/dev"); + const std::string kUHIDPattern("/dev/uhid*"); + + base::FileEnumerator enumerator(kDevRoot, false, base::FileEnumerator::FILES); + do { + const base::FilePath next_device_path(enumerator.Next()); + const std::string next_device = next_device_path.value(); + if (next_device.empty()) + break; + + if (base::MatchPattern(next_device, kUHIDPattern)) + OnDeviceAdded(next_device.substr(5)); + } while (true); + + SetupDevdMonitor(); + + task_runner_->PostTask( + FROM_HERE, + base::Bind(&HidServiceFreeBSD::FirstEnumerationComplete, service_)); + } + + bool HaveReadWritePermissions(std::string device_id) { + std::string device_node = "/dev/" + device_id; + base::internal::AssertBlockingAllowed(); + + base::FilePath device_path(device_node); + base::File device_file; + int flags = + base::File::FLAG_OPEN | base::File::FLAG_READ | base::File::FLAG_WRITE; + device_file.Initialize(device_path, flags); + if (!device_file.IsValid()) + return false; + + return true; + } + + void OnDeviceAdded(std::string device_id) { + base::ScopedBlockingCall scoped_blocking_call( + FROM_HERE, base::BlockingType::MAY_BLOCK); + std::string device_node = "/dev/" + device_id; + uint16_t vendor_id = 0xffff; + uint16_t product_id = 0xffff; + std::string product_name = ""; + std::string serial_number = ""; + + std::vector report_descriptor; + + base::internal::AssertBlockingAllowed(); + + base::FilePath device_path(device_node); + base::File device_file; + int flags = + base::File::FLAG_OPEN | base::File::FLAG_READ | base::File::FLAG_WRITE; + device_file.Initialize(device_path, flags); + if (!device_file.IsValid()) { + HID_LOG(ERROR) << "Failed to open '" << device_node + << "': " + << base::File::ErrorToString(device_file.error_details()); + return; + } + + base::ScopedFD fd; + fd.reset(device_file.TakePlatformFile()); + + struct usb_gen_descriptor ugd; + ugd.ugd_data = NULL; + ugd.ugd_maxlen = 0xffff; + int result = HANDLE_EINTR( + ioctl(fd.get(), USB_GET_REPORT_DESC, &ugd)); + + if (result < 0) { + HID_LOG(ERROR) << "Failed to get report descriptor size"; + return; + } + + report_descriptor.resize(ugd.ugd_actlen); + + ugd.ugd_data = report_descriptor.data(); + ugd.ugd_maxlen = ugd.ugd_actlen; + result = HANDLE_EINTR( + ioctl(fd.get(), USB_GET_REPORT_DESC, &ugd)); + + if (result < 0) { + HID_LOG(ERROR) << "Failed to get report descriptor"; + return; + } + + scoped_refptr device_info(new HidDeviceInfo( + device_id, + /*physical_device_id*/"", + vendor_id, + product_id, + product_name, + serial_number, + device::mojom::HidBusType::kHIDBusTypeUSB, + report_descriptor, + device_node)); + -+ task_runner_->PostTask(FROM_HERE, base::Bind(&HidServiceFreeBSD::AddDevice, ++ task_runner_->PostTask(FROM_HERE, base::BindOnce(&HidServiceFreeBSD::AddDevice, + service_, device_info)); + } + + void OnDeviceRemoved(std::string device_id) { + base::ScopedBlockingCall scoped_blocking_call( + FROM_HERE, base::BlockingType::MAY_BLOCK); + task_runner_->PostTask( + FROM_HERE, base::Bind(&HidServiceFreeBSD::RemoveDevice, service_, + device_id)); + } + + private: + + void CheckPendingPermissionChange() { + base::internal::AssertBlockingAllowed(); + std::map::iterator it; + for (it = permissions_checks_attempts_.begin(); it != permissions_checks_attempts_.end();) { + std::string device_name = it->first; + bool keep = true; + if (HaveReadWritePermissions(device_name)) { + OnDeviceAdded(device_name); + keep = false; + } + else if (it->second-- <= 0) { + HID_LOG(ERROR) << "Still don't have write permissions to '" << device_name + << "' after " << kMaxPermissionChecks << " attempts"; + keep = false; + } + + if (keep) + ++it; + else + permissions_checks_attempts_.erase(it++); + } + + if (permissions_checks_attempts_.empty()) + timer_->Stop(); + } + + void SetupDevdMonitor() { + base::internal::AssertBlockingAllowed(); + + int devd_fd = socket(AF_UNIX, SOCK_SEQPACKET, 0); + if (devd_fd < 0) + return; + + struct sockaddr_un sa; + + sa.sun_family = AF_UNIX; + strlcpy(sa.sun_path, "/var/run/devd.seqpacket.pipe", sizeof(sa.sun_path)); + if (connect(devd_fd, (struct sockaddr *) &sa, sizeof(sa)) < 0) { + close(devd_fd); + return; + } + + devd_fd_.reset(devd_fd); + file_watcher_ = base::FileDescriptorWatcher::WatchReadable( -+ devd_fd_.get(), base::Bind(&BlockingTaskHelper::OnDevdMessageCanBeRead, ++ devd_fd_.get(), base::Bind(&BlockingTaskRunnerHelper::OnDevdMessageCanBeRead, + base::Unretained(this))); + } + + void OnDevdMessageCanBeRead() { + DCHECK_CALLED_ON_VALID_SEQUENCE(sequence_checker_); + ssize_t bytes_read = HANDLE_EINTR(recv(devd_fd_.get(), devd_buffer_->data(), + devd_buffer_->size() - 1, MSG_WAITALL)); + if (bytes_read < 0) { + if (errno != EAGAIN) { + HID_LOG(ERROR) << "Read failed"; + file_watcher_.reset(); + } + return; + } + + devd_buffer_->data()[bytes_read] = 0; + char *data = devd_buffer_->data(); + // It may take some time for devd to change permissions + // on /dev/uhidX node. So do not fail immediately if + // open fail. Retry each second for kMaxPermissionChecks + // times before giving up entirely + if (base::StartsWith(data, "+uhid", base::CompareCase::SENSITIVE)) { + std::vector parts = base::SplitString( + data, " ", base::TRIM_WHITESPACE, base::SPLIT_WANT_ALL); + if (!parts.empty()) { + std::string device_name = parts[0].substr(1); // skip '+' + if (HaveReadWritePermissions(device_name)) + OnDeviceAdded(parts[0].substr(1)); + else { + // Do not re-add to checks + if (permissions_checks_attempts_.find(device_name) == permissions_checks_attempts_.end()) { + permissions_checks_attempts_.insert(std::pair(device_name, kMaxPermissionChecks)); + timer_->Start(FROM_HERE, base::TimeDelta::FromSeconds(1), -+ this, &BlockingTaskHelper::CheckPendingPermissionChange); ++ this, &BlockingTaskRunnerHelper::CheckPendingPermissionChange); + } + } + } + } + + if (base::StartsWith(data, "-uhid", base::CompareCase::SENSITIVE)) { + std::vector parts = base::SplitString( + data, " ", base::TRIM_WHITESPACE, base::SPLIT_WANT_ALL); + if (!parts.empty()) { + std::string device_name = parts[0].substr(1); // skip '-' + auto it = permissions_checks_attempts_.find(device_name); + if (it != permissions_checks_attempts_.end()) { + permissions_checks_attempts_.erase(it); + if (permissions_checks_attempts_.empty()) + timer_->Stop(); + } + OnDeviceRemoved(parts[0].substr(1)); + } + } + } + + SEQUENCE_CHECKER(sequence_checker_); + + // This weak pointer is only valid when checked on this task runner. + base::WeakPtr service_; + scoped_refptr task_runner_; + std::unique_ptr file_watcher_; + std::unique_ptr timer_; + base::ScopedFD devd_fd_; + scoped_refptr devd_buffer_; + std::map permissions_checks_attempts_; + -+ DISALLOW_COPY_AND_ASSIGN(BlockingTaskHelper); ++ DISALLOW_COPY_AND_ASSIGN(BlockingTaskRunnerHelper); +}; + +HidServiceFreeBSD::HidServiceFreeBSD() -+ : task_runner_(base::ThreadTaskRunnerHandle::Get()), -+ blocking_task_runner_( -+ base::CreateSequencedTaskRunner(kBlockingTaskTraits)), -+ weak_factory_(this) { -+ helper_ = std::make_unique(weak_factory_.GetWeakPtr()); ++ : blocking_task_runner_( ++ base::ThreadPool::CreateSequencedTaskRunner(kBlockingTaskTraits)), ++ helper_(nullptr, base::OnTaskRunnerDeleter(blocking_task_runner_)) { ++ helper_.reset(new BlockingTaskRunnerHelper(weak_factory_.GetWeakPtr())); + blocking_task_runner_->PostTask( + FROM_HERE, -+ base::Bind(&BlockingTaskHelper::Start, base::Unretained(helper_.get()))); ++ base::BindOnce(&BlockingTaskRunnerHelper::Start, base::Unretained(helper_.get()))); +} + +HidServiceFreeBSD::~HidServiceFreeBSD() { + blocking_task_runner_->DeleteSoon(FROM_HERE, helper_.release()); +} + +base::WeakPtr HidServiceFreeBSD::GetWeakPtr() { + return weak_factory_.GetWeakPtr(); +} + +// static +void HidServiceFreeBSD::OpenOnBlockingThread( + std::unique_ptr params) { + base::ScopedBlockingCall scoped_blocking_call( + FROM_HERE, base::BlockingType::MAY_BLOCK); + scoped_refptr task_runner = params->task_runner; + + base::FilePath device_path(params->device_info->device_node()); + base::File device_file; + int flags = + base::File::FLAG_OPEN | base::File::FLAG_READ | base::File::FLAG_WRITE; + device_file.Initialize(device_path, flags); + if (!device_file.IsValid()) { + HID_LOG(EVENT) << "Failed to open '" << params->device_info->device_node() + << "': " + << base::File::ErrorToString(device_file.error_details()); + task_runner->PostTask(FROM_HERE, + base::BindOnce(std::move(params->callback), nullptr)); + return; + } + params->fd.reset(device_file.TakePlatformFile()); + task_runner->PostTask(FROM_HERE, base::BindOnce(&HidServiceFreeBSD::FinishOpen, + std::move(params))); +} + +void HidServiceFreeBSD::Connect(const std::string& device_guid, + ConnectCallback callback) { + DCHECK_CALLED_ON_VALID_SEQUENCE(sequence_checker_); + + const auto& map_entry = devices().find(device_guid); + if (map_entry == devices().end()) { + base::ThreadTaskRunnerHandle::Get()->PostTask( + FROM_HERE, base::BindOnce(std::move(callback), nullptr)); + return; + } + + scoped_refptr device_info = map_entry->second; + + auto params = std::make_unique(device_info, std::move(callback)); + scoped_refptr blocking_task_runner = + params->blocking_task_runner; + + blocking_task_runner->PostTask( + FROM_HERE, base::BindOnce(&HidServiceFreeBSD::OpenOnBlockingThread, + std::move(params))); +} + +// static +void HidServiceFreeBSD::FinishOpen(std::unique_ptr params) { + DCHECK(params->fd.is_valid()); + + if (!base::SetNonBlocking(params->fd.get())) { + HID_PLOG(ERROR) << "Failed to set the non-blocking flag on the device fd"; + std::move(params->callback).Run(nullptr); + } + + std::move(params->callback).Run(base::MakeRefCounted( + std::move(params->device_info), + std::move(params->fd), + std::move(params->blocking_task_runner) + )); +} + +} // namespace device Index: branches/2020Q3/www/chromium/files/patch-services_device_hid_hid__service__freebsd.h =================================================================== --- branches/2020Q3/www/chromium/files/patch-services_device_hid_hid__service__freebsd.h (revision 545068) +++ branches/2020Q3/www/chromium/files/patch-services_device_hid_hid__service__freebsd.h (revision 545069) @@ -1,50 +1,49 @@ ---- services/device/hid/hid_service_freebsd.h.orig 2020-03-17 15:11:01 UTC -+++ services/device/hid/hid_service_freebsd.h -@@ -0,0 +1,47 @@ +--- services/device/hid/hid_service_freebsd.h.orig 2020-07-18 19:40:14.418200000 -0700 ++++ services/device/hid/hid_service_freebsd.h 2020-07-21 19:52:08.796704000 -0700 +@@ -0,0 +1,46 @@ +// Copyright 2014 The Chromium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +#ifndef DEVICE_HID_HID_SERVICE_FREEBSD_H_ +#define DEVICE_HID_HID_SERVICE_FREEBSD_H_ + +#include + +#include "base/macros.h" +#include "base/memory/ref_counted.h" +#include "base/memory/weak_ptr.h" +#include "base/timer/timer.h" +#include "services/device/hid/hid_service.h" +#include "net/base/io_buffer.h" + +namespace device { + +class HidServiceFreeBSD : public HidService { + public: + HidServiceFreeBSD(); + ~HidServiceFreeBSD() override; + + void Connect(const std::string& device_guid, + ConnectCallback connect) override; + base::WeakPtr GetWeakPtr() override; + + private: + struct ConnectParams; -+ class BlockingTaskHelper; ++ class BlockingTaskRunnerHelper; + + static void OpenOnBlockingThread(std::unique_ptr params); + static void FinishOpen(std::unique_ptr params); + -+ const scoped_refptr task_runner_; + const scoped_refptr blocking_task_runner_; + // |helper_| lives on the sequence |blocking_task_runner_| posts to and holds + // a weak reference back to the service that owns it. -+ std::unique_ptr helper_; -+ base::WeakPtrFactory weak_factory_; ++ std::unique_ptr helper_; ++ base::WeakPtrFactory weak_factory_{this}; + + DISALLOW_COPY_AND_ASSIGN(HidServiceFreeBSD); +}; + +} // namespace device + +#endif // DEVICE_HID_HID_SERVICE_FREEBSD_H_ Index: branches/2020Q3 =================================================================== --- branches/2020Q3 (revision 545068) +++ branches/2020Q3 (revision 545069) Property changes on: branches/2020Q3 ___________________________________________________________________ Modified: svn:mergeinfo ## -0,0 +0,1 ## Merged /head:r545067-545068