unbreak sync to google and add some missing OS_BSD ifdefs to the viz and

autofill code

sync was broken because we had the a function neutered that pulled hardware
information (manufacturer and model) which was required for sync to work.

this commit implements this function but sends dummy information about the
hardware: manufacturer is OpenBSD and the model is an empty string
This commit is contained in:
robert 2020-06-23 06:32:53 +00:00
parent d9349d37b6
commit 321627dadc
8 changed files with 126 additions and 65 deletions

View File

@ -1,4 +1,4 @@
# $OpenBSD: Makefile,v 1.518 2020/06/21 15:49:36 gnezdo Exp $
# $OpenBSD: Makefile,v 1.519 2020/06/23 06:32:53 robert Exp $
.include <bsd.port.arch.mk>
@ -13,7 +13,7 @@ DPB_PROPERTIES= lonesome
COMMENT= Chromium browser
V= 83.0.4103.106
REVISION= 0
REVISION= 1
DISTNAME= chromium-${V}

View File

@ -0,0 +1,14 @@
$OpenBSD: patch-base_system_sys_info_cc,v 1.1 2020/06/23 06:32:53 robert Exp $
Index: base/system/sys_info.cc
--- base/system/sys_info.cc.orig
+++ base/system/sys_info.cc
@@ -102,7 +102,7 @@ void SysInfo::GetHardwareInfo(base::OnceCallback<void(
#elif defined(OS_ANDROID) || defined(OS_MACOSX)
base::ThreadPool::PostTaskAndReplyWithResult(
FROM_HERE, {}, base::BindOnce(&GetHardwareInfoSync), std::move(callback));
-#elif defined(OS_LINUX)
+#elif defined(OS_LINUX) || defined(OS_BSD)
base::ThreadPool::PostTaskAndReplyWithResult(
FROM_HERE, {base::MayBlock()}, base::BindOnce(&GetHardwareInfoSync),
std::move(callback));

View File

@ -1,9 +1,17 @@
$OpenBSD: patch-base_system_sys_info_openbsd_cc,v 1.4 2019/12/15 13:36:30 robert Exp $
$OpenBSD: patch-base_system_sys_info_openbsd_cc,v 1.5 2020/06/23 06:32:53 robert Exp $
Index: base/system/sys_info_openbsd.cc
--- base/system/sys_info_openbsd.cc.orig
+++ base/system/sys_info_openbsd.cc
@@ -29,9 +29,14 @@ int64_t AmountOfMemory(int pages_name) {
@@ -12,6 +12,7 @@
#include "base/logging.h"
#include "base/stl_util.h"
+#include "base/strings/string_util.h"
namespace {
@@ -29,9 +30,14 @@ int64_t AmountOfMemory(int pages_name) {
namespace base {
@ -19,7 +27,7 @@ Index: base/system/sys_info_openbsd.cc
int ncpu;
size_t size = sizeof(ncpu);
if (sysctl(mib, base::size(mib), &ncpu, &size, NULL, 0) < 0) {
@@ -43,29 +48,23 @@ int SysInfo::NumberOfProcessors() {
@@ -43,38 +49,61 @@ int SysInfo::NumberOfProcessors() {
// static
int64_t SysInfo::AmountOfPhysicalMemoryImpl() {
@ -42,42 +50,54 @@ Index: base/system/sys_info_openbsd.cc
}
// static
-uint64_t SysInfo::MaxSharedMemorySize() {
- int mib[] = {CTL_KERN, KERN_SHMINFO, KERN_SHMINFO_SHMMAX};
- size_t limit;
- size_t size = sizeof(limit);
- if (sysctl(mib, base::size(mib), &limit, &size, NULL, 0) < 0) {
- NOTREACHED();
- return 0;
- }
- return static_cast<uint64_t>(limit);
-}
-
-// static
std::string SysInfo::CPUModelName() {
int mib[] = {CTL_HW, HW_MODEL};
char name[256];
@@ -75,6 +74,23 @@ std::string SysInfo::CPUModelName() {
return std::string();
}
return name;
+std::string SysInfo::CPUModelName() {
+ int mib[] = {CTL_HW, HW_MODEL};
+ char name[256];
+ size_t len = base::size(name);
+ if (sysctl(mib, base::size(mib), name, &len, NULL, 0) < 0) {
+ NOTREACHED();
+ return std::string();
+ }
+ return name;
+}
+
+// static
+uint64_t SysInfo::MaxSharedMemorySize() {
+ int mib[] = {CTL_KERN, KERN_SHMINFO, KERN_SHMINFO_SHMMAX};
+ size_t limit;
+ size_t size = sizeof(limit);
uint64_t SysInfo::MaxSharedMemorySize() {
int mib[] = {CTL_KERN, KERN_SHMINFO, KERN_SHMINFO_SHMMAX};
size_t limit;
size_t size = sizeof(limit);
+ // pledge(2)
+ if (shmmax)
+ goto out;
+ if (sysctl(mib, base::size(mib), &limit, &size, NULL, 0) < 0) {
+ NOTREACHED();
+ return 0;
+ }
if (sysctl(mib, base::size(mib), &limit, &size, NULL, 0) < 0) {
NOTREACHED();
return 0;
}
- return static_cast<uint64_t>(limit);
+ shmmax = static_cast<uint64_t>(limit);
+out:
+ return shmmax;
}
// static
-std::string SysInfo::CPUModelName() {
- int mib[] = {CTL_HW, HW_MODEL};
- char name[256];
- size_t len = base::size(name);
- if (sysctl(mib, base::size(mib), name, &len, NULL, 0) < 0) {
- NOTREACHED();
- return std::string();
- }
- return name;
+SysInfo::HardwareInfo SysInfo::GetHardwareInfoSync() {
+ HardwareInfo info;
+ // Set the manufacturer to "OpenBSD" and the model to
+ // an empty string.
+ info.manufacturer = "OpenBSD";
+ info.model = HardwareModelName();
+ DCHECK(IsStringUTF8(info.manufacturer));
+ DCHECK(IsStringUTF8(info.model));
+ return info;
}
} // namespace base

View File

@ -0,0 +1,14 @@
$OpenBSD: patch-components_autofill_core_browser_autofill_external_delegate_cc,v 1.1 2020/06/23 06:32:53 robert Exp $
Index: components/autofill/core/browser/autofill_external_delegate.cc
--- components/autofill/core/browser/autofill_external_delegate.cc.orig
+++ components/autofill/core/browser/autofill_external_delegate.cc
@@ -118,7 +118,7 @@ void AutofillExternalDelegate::OnSuggestionsReturned(
// Append the "Hide Suggestions" menu item for only Autofill Address and
// Autocomplete popups.
#if defined(OS_WIN) || defined(OS_LINUX) || defined(OS_MACOSX) || \
- defined(OS_CHROMEOS)
+ defined(OS_CHROMEOS) || defined(OS_BSD)
if (base::FeatureList::IsEnabled(
features::kAutofillEnableHideSuggestionsUI)) {
// If the user has selected a suggestion, it indicates the suggestions are

View File

@ -1,16 +0,0 @@
$OpenBSD: patch-components_sync_device_info_device_info_sync_bridge_cc,v 1.3 2020/04/10 18:51:31 robert Exp $
Index: components/sync_device_info/device_info_sync_bridge.cc
--- components/sync_device_info/device_info_sync_bridge.cc.orig
+++ components/sync_device_info/device_info_sync_bridge.cc
@@ -456,6 +456,10 @@ void DeviceInfoSyncBridge::OnStoreCreated(
return;
}
+#if defined(OS_BSD)
+ return;
+#endif
+
store_ = std::move(store);
base::SysInfo::GetHardwareInfo(

View File

@ -1,17 +0,0 @@
$OpenBSD: patch-components_sync_device_info_local_device_info_util_linux_cc,v 1.2 2019/12/15 12:03:46 robert Exp $
Index: components/sync_device_info/local_device_info_util_linux.cc
--- components/sync_device_info/local_device_info_util_linux.cc.orig
+++ components/sync_device_info/local_device_info_util_linux.cc
@@ -37,8 +37,9 @@ std::string GetPersonalizableDeviceNameInternal() {
#if defined(OS_CHROMEOS)
return GetChromeOSDeviceNameFromType();
#else
- char hostname[HOST_NAME_MAX];
- if (gethostname(hostname, HOST_NAME_MAX) == 0) // Success.
+ int len = sysconf(_SC_HOST_NAME_MAX);
+ char hostname[len];
+ if (gethostname(hostname, len) == 0) // Success.
return hostname;
return base::GetLinuxDistro();
#endif

View File

@ -0,0 +1,23 @@
$OpenBSD: patch-components_viz_service_display_embedder_software_output_surface_cc,v 1.1 2020/06/23 06:32:53 robert Exp $
Index: components/viz/service/display_embedder/software_output_surface.cc
--- components/viz/service/display_embedder/software_output_surface.cc.orig
+++ components/viz/service/display_embedder/software_output_surface.cc
@@ -114,7 +114,7 @@ void SoftwareOutputSurface::SwapBuffersCallback(base::
base::TimeTicks now = base::TimeTicks::Now();
base::TimeDelta interval_to_next_refresh =
now.SnappedToNextTick(refresh_timebase_, refresh_interval_) - now;
-#if defined(OS_LINUX) && !defined(OS_CHROMEOS)
+#if (defined(OS_LINUX) && !defined(OS_CHROMEOS)) || defined(OS_BSD)
if (needs_swap_size_notifications_)
client_->DidSwapWithSize(pixel_size);
#endif
@@ -143,7 +143,7 @@ gfx::OverlayTransform SoftwareOutputSurface::GetDispla
return gfx::OVERLAY_TRANSFORM_NONE;
}
-#if defined(OS_LINUX) && !defined(OS_CHROMEOS)
+#if (defined(OS_LINUX) && !defined(OS_CHROMEOS)) || defined(OS_BSD)
void SoftwareOutputSurface::SetNeedsSwapSizeNotifications(
bool needs_swap_size_notifications) {
needs_swap_size_notifications_ = needs_swap_size_notifications;

View File

@ -0,0 +1,23 @@
$OpenBSD: patch-components_viz_service_display_embedder_software_output_surface_h,v 1.1 2020/06/23 06:32:53 robert Exp $
Index: components/viz/service/display_embedder/software_output_surface.h
--- components/viz/service/display_embedder/software_output_surface.h.orig
+++ components/viz/service/display_embedder/software_output_surface.h
@@ -49,7 +49,7 @@ class VIZ_SERVICE_EXPORT SoftwareOutputSurface : publi
UpdateVSyncParametersCallback callback) override;
void SetDisplayTransformHint(gfx::OverlayTransform transform) override {}
gfx::OverlayTransform GetDisplayTransform() override;
-#if defined(OS_LINUX) && !defined(OS_CHROMEOS)
+#if (defined(OS_LINUX) && !defined(OS_CHROMEOS)) || defined(OS_BSD)
void SetNeedsSwapSizeNotifications(
bool needs_swap_size_notifications) override;
#endif
@@ -72,7 +72,7 @@ class VIZ_SERVICE_EXPORT SoftwareOutputSurface : publi
std::queue<std::vector<ui::LatencyInfo>> stored_latency_info_;
ui::LatencyTracker latency_tracker_;
-#if defined(OS_LINUX) && !defined(OS_CHROMEOS)
+#if (defined(OS_LINUX) && !defined(OS_CHROMEOS)) || defined(OS_BSD)
bool needs_swap_size_notifications_ = false;
#endif