aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--chromium/chromium/chromium-gcc10-chrome.patch12
-rw-r--r--chromium/chromium/chromium-gcc10-content.patch50
-rw-r--r--chromium/chromium/chromium-gcc10-r769713.patch41
-rw-r--r--chromium/chromium/chromium-gcc10-r771840.patch43
-rw-r--r--chromium/chromium/chromium-gcc10-r772215.patch119
-rw-r--r--chromium/chromium/chromium-gcc10-r772267.patch35
-rw-r--r--chromium/chromium/chromium-gcc10-r772283.patch70
-rw-r--r--chromium/chromium/chromium-gcc10-r772542.patch44
-rw-r--r--chromium/chromium/chromium-gcc10-r773698.patch39
-rw-r--r--chromium/chromium/chromium-gcc10-r773855.patch73
-rw-r--r--chromium/chromium/chromium-gcc10-r774141.patch43
-rw-r--r--chromium/chromium/chromium-gcc10-r775439.patch125
-rw-r--r--chromium/chromium/chromium-gcc10-r778406.patch33
-rw-r--r--chromium/chromium/chromium-gcc10-r783489.patch706
-rw-r--r--chromium/chromium/chromium-gcc10-r783782.patch42
-rw-r--r--chromium/chromium/chromium-gcc10-r783978.patch32
-rw-r--r--chromium/chromium/chromium-gcc10-r784897.patch59
-rw-r--r--chromium/chromium/chromium-gcc10-r785035.patch1538
-rw-r--r--chromium/chromium/chromium-gcc10-r785727.patch34
-rw-r--r--chromium/chromium/chromium-gcc10-r785770.patch39
-rw-r--r--chromium/chromium/chromium-gcc10-r785771.patch45
-rw-r--r--chromium/chromium/chromium-gcc10-ui.patch13
-rw-r--r--chromium/chromium/chromium-gcc9-r772175.patch76
-rw-r--r--chromium/chromium/chromium-gcc9-r772348.patch61
-rw-r--r--chromium/chromium/chromium-gcc9-ui.patch35
-rw-r--r--chromium/chromium/chromium-gen-xproto-python3.patch28
-rw-r--r--chromium/chromium/chromium-revert-manage-ManifestManagerHost-per-document.patch396
-rw-r--r--chromium/chromium/chromium-webrtc-gcc10.patch12
-rw-r--r--chromium/chromium/chromium.spec69
29 files changed, 2518 insertions, 1394 deletions
diff --git a/chromium/chromium/chromium-gcc10-chrome.patch b/chromium/chromium/chromium-gcc10-chrome.patch
deleted file mode 100644
index 282d7c6..0000000
--- a/chromium/chromium/chromium-gcc10-chrome.patch
+++ /dev/null
@@ -1,12 +0,0 @@
-diff --git a/chrome/browser/search/background/ntp_backgrounds.h b/chrome/browser/search/background/ntp_backgrounds.h
-index 7afc0a2..6d0957e 100644
---- a/chrome/browser/search/background/ntp_backgrounds.h
-+++ b/chrome/browser/search/background/ntp_backgrounds.h
-@@ -6,6 +6,7 @@
- #define CHROME_BROWSER_SEARCH_BACKGROUND_NTP_BACKGROUNDS_H_
-
- #include <array>
-+#include <cstddef>
-
- class GURL;
-
diff --git a/chromium/chromium/chromium-gcc10-content.patch b/chromium/chromium/chromium-gcc10-content.patch
deleted file mode 100644
index 90909c5..0000000
--- a/chromium/chromium/chromium-gcc10-content.patch
+++ /dev/null
@@ -1,50 +0,0 @@
-diff --git a/content/public/browser/web_ui.h b/content/public/browser/web_ui.h
-index 4e6aa0e..fa6f10c 100644
---- a/content/public/browser/web_ui.h
-+++ b/content/public/browser/web_ui.h
-@@ -138,22 +138,6 @@ class CONTENT_EXPORT WebUI {
- template <typename T>
- static T GetValue(const base::Value& value);
-
-- template <>
-- inline bool GetValue<bool>(const base::Value& value) {
-- return value.GetBool();
-- }
--
-- template <>
-- inline int GetValue<int>(const base::Value& value) {
-- return value.GetInt();
-- }
--
-- template <>
-- inline const std::string& GetValue<const std::string&>(
-- const base::Value& value) {
-- return value.GetString();
-- }
--
- template <typename Is, typename... Args>
- struct Call;
-
-@@ -169,6 +153,22 @@ class CONTENT_EXPORT WebUI {
- };
- };
-
-+template <>
-+inline bool WebUI::GetValue<bool>(const base::Value& value) {
-+ return value.GetBool();
-+}
-+
-+template <>
-+inline int WebUI::GetValue<int>(const base::Value& value) {
-+ return value.GetInt();
-+}
-+
-+template <>
-+inline const std::string& WebUI::GetValue<const std::string&>(
-+ const base::Value& value) {
-+ return value.GetString();
-+}
-+
- } // namespace content
-
- #endif // CONTENT_PUBLIC_BROWSER_WEB_UI_H_
diff --git a/chromium/chromium/chromium-gcc10-r769713.patch b/chromium/chromium/chromium-gcc10-r769713.patch
deleted file mode 100644
index c2feb72..0000000
--- a/chromium/chromium/chromium-gcc10-r769713.patch
+++ /dev/null
@@ -1,41 +0,0 @@
-From f3dfe39f9fd3091cf1a7146b936d9de77a459435 Mon Sep 17 00:00:00 2001
-From: Piotr Tworek <ptworek@vewd.com>
-Date: Mon, 18 May 2020 15:24:35 +0000
-Subject: [PATCH] Make blink::AXObject::AncestorsIterator STL compatible.
-
-Commit 31e5188ffc9a04295997d22bfdb68fc367bef047, "Used some methods from
-AXRoleProperties in AXObject" started using std::any_of with this custom
-iterator type. Unfortunately this iterator does not provide traits
-mandated by the standard. This works fine for libcxx, but fails when
-compiling the code against libstdc++.
-
-Bug: 819294
-Change-Id: I78fe25475593d73ce255f1de955aa41e936dff86
-Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2207112
-Reviewed-by: Kentaro Hara <haraken@chromium.org>
-Commit-Queue: Piotr Tworek <ptworek@vewd.com>
-Cr-Commit-Position: refs/heads/master@{#769713}
----
- .../blink/renderer/modules/accessibility/ax_object.h | 6 ++++++
- 1 file changed, 6 insertions(+)
-
-diff --git a/third_party/blink/renderer/modules/accessibility/ax_object.h b/third_party/blink/renderer/modules/accessibility/ax_object.h
-index 841715b3cecf..fbb87bfb8e1e 100644
---- a/third_party/blink/renderer/modules/accessibility/ax_object.h
-+++ b/third_party/blink/renderer/modules/accessibility/ax_object.h
-@@ -274,6 +274,12 @@ class MODULES_EXPORT AXObject : public GarbageCollected<AXObject> {
- class MODULES_EXPORT AncestorsIterator final
- : public GarbageCollected<AncestorsIterator> {
- public:
-+ using iterator_category = std::forward_iterator_tag;
-+ using value_type = AXObject;
-+ using difference_type = ptrdiff_t;
-+ using pointer = value_type*;
-+ using reference = value_type&;
-+
- ~AncestorsIterator() = default;
-
- AncestorsIterator(const AncestorsIterator& other)
---
-2.26.2
-
diff --git a/chromium/chromium/chromium-gcc10-r771840.patch b/chromium/chromium/chromium-gcc10-r771840.patch
deleted file mode 100644
index f8be1ef..0000000
--- a/chromium/chromium/chromium-gcc10-r771840.patch
+++ /dev/null
@@ -1,43 +0,0 @@
-From 3a3effdd81e97bfc4f2698cd1f41b008355b0469 Mon Sep 17 00:00:00 2001
-From: Raphael Kubo da Costa <raphael.kubo.da.costa@intel.com>
-Date: Tue, 26 May 2020 16:34:45 +0000
-Subject: [PATCH] scoped_nss_types.h: Include <certt.h> instead of
- <nss/certt.h>
-
-Follow-up to commit 701cae5de ("Introduce a function to format a DER-encoded
-SPKI for UI").
-
-That is the format used by other files that include <certt.h>, and the
-pkg-config configuration already passes -I/path/to/nss to the compiler.
-
-This can potentially fix the non-sysroot build, as the NSS headers might be
-installed in e.g. /usr/include/nss3 rather than /usr/include/nss.
-
-Change-Id: I0461a7a7f8c93459f2281ea71c96434a74687ee8
-Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2214390
-Auto-Submit: Raphael Kubo da Costa <raphael.kubo.da.costa@intel.com>
-Commit-Queue: David Benjamin <davidben@chromium.org>
-Reviewed-by: David Benjamin <davidben@chromium.org>
-Cr-Commit-Position: refs/heads/master@{#771840}
----
- crypto/scoped_nss_types.h | 2 +-
- 1 file changed, 1 insertion(+), 1 deletion(-)
-
-diff --git a/crypto/scoped_nss_types.h b/crypto/scoped_nss_types.h
-index 2a3a6e1b2517..0a663ea7c3b3 100644
---- a/crypto/scoped_nss_types.h
-+++ b/crypto/scoped_nss_types.h
-@@ -5,9 +5,9 @@
- #ifndef CRYPTO_SCOPED_NSS_TYPES_H_
- #define CRYPTO_SCOPED_NSS_TYPES_H_
-
-+#include <certt.h>
- #include <keyhi.h>
- #include <nss.h>
--#include <nss/certt.h>
- #include <pk11pub.h>
- #include <plarena.h>
-
---
-2.26.2
-
diff --git a/chromium/chromium/chromium-gcc10-r772215.patch b/chromium/chromium/chromium-gcc10-r772215.patch
deleted file mode 100644
index b1aad03..0000000
--- a/chromium/chromium/chromium-gcc10-r772215.patch
+++ /dev/null
@@ -1,119 +0,0 @@
-From bc9a96ef9eeab89276d67929f4a8a7d88f5dbc02 Mon Sep 17 00:00:00 2001
-From: Stephan Hartmann <stha09@googlemail.com>
-Date: Wed, 27 May 2020 13:37:25 +0000
-Subject: [PATCH] GCC: fix template specialization in TraceInCollectionTrait
-
-GCC complains that explicit specialization in non-namespace scope
-is happening for TraceImpl. Move TraceImpl implementations into
-different nested classes and select implementation using
-std::conditional.
-
-Bug: 819294
-Change-Id: I8feea5f2aa6e1f87daad61f496d6b53b1bbc49ac
-Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2217887
-Reviewed-by: Michael Lippautz <mlippautz@chromium.org>
-Commit-Queue: Michael Lippautz <mlippautz@chromium.org>
-Cr-Commit-Position: refs/heads/master@{#772215}
----
- .../heap_hash_table_backing.h | 80 ++++++++++---------
- 1 file changed, 41 insertions(+), 39 deletions(-)
-
-diff --git a/third_party/blink/renderer/platform/heap/collection_support/heap_hash_table_backing.h b/third_party/blink/renderer/platform/heap/collection_support/heap_hash_table_backing.h
-index 31e7888b07f6..2c0583f660cc 100644
---- a/third_party/blink/renderer/platform/heap/collection_support/heap_hash_table_backing.h
-+++ b/third_party/blink/renderer/platform/heap/collection_support/heap_hash_table_backing.h
-@@ -241,50 +241,52 @@ struct TraceInCollectionTrait<kNoWeakHandling,
-
- static void Trace(blink::Visitor* visitor,
- const KeyValuePair<Key, Value>& self) {
-- TraceImpl(visitor, self);
-+ TraceImpl::Trace(visitor, self);
- }
-
- private:
-- template <bool = EphemeronHelper::is_ephemeron>
-- static void TraceImpl(blink::Visitor* visitor,
-- const KeyValuePair<Key, Value>& self);
--
-- // Strongification of ephemerons, i.e., Weak/Strong and Strong/Weak.
-- template <>
-- static void TraceImpl<true>(blink::Visitor* visitor,
-- const KeyValuePair<Key, Value>& self) {
-+ struct TraceImplEphemerons {
- // Strongification of ephemerons, i.e., Weak/Strong and Strong/Weak.
-- // The helper ensures that helper.key always refers to the weak part and
-- // helper.value always refers to the dependent part.
-- // We distinguish ephemeron from Weak/Weak and Strong/Strong to allow users
-- // to override visitation behavior. An example is creating a heap snapshot,
-- // where it is useful to annotate values as being kept alive from keys
-- // rather than the table.
-- EphemeronHelper helper(&self.key, &self.value);
-- // Strongify the weak part.
-- blink::TraceCollectionIfEnabled<
-- kNoWeakHandling, typename EphemeronHelper::KeyType,
-- typename EphemeronHelper::KeyTraits>::Trace(visitor, helper.key);
-- // Strongify the dependent part.
-- visitor->TraceEphemeron(
-- *helper.key, helper.value,
-- blink::TraceCollectionIfEnabled<
-- kNoWeakHandling, typename EphemeronHelper::ValueType,
-- typename EphemeronHelper::ValueTraits>::Trace);
-- }
-+ static void Trace(blink::Visitor* visitor,
-+ const KeyValuePair<Key, Value>& self) {
-+ // Strongification of ephemerons, i.e., Weak/Strong and Strong/Weak.
-+ // The helper ensures that helper.key always refers to the weak part and
-+ // helper.value always refers to the dependent part.
-+ // We distinguish ephemeron from Weak/Weak and Strong/Strong to allow
-+ // users to override visitation behavior. An example is creating a heap
-+ // snapshot, where it is useful to annotate values as being kept alive
-+ // from keys rather than the table.
-+ EphemeronHelper helper(&self.key, &self.value);
-+ // Strongify the weak part.
-+ blink::TraceCollectionIfEnabled<
-+ kNoWeakHandling, typename EphemeronHelper::KeyType,
-+ typename EphemeronHelper::KeyTraits>::Trace(visitor, helper.key);
-+ // Strongify the dependent part.
-+ visitor->TraceEphemeron(
-+ *helper.key, helper.value,
-+ blink::TraceCollectionIfEnabled<
-+ kNoWeakHandling, typename EphemeronHelper::ValueType,
-+ typename EphemeronHelper::ValueTraits>::Trace);
-+ }
-+ };
-
-- template <>
-- static void TraceImpl<false>(blink::Visitor* visitor,
-- const KeyValuePair<Key, Value>& self) {
-- // Strongification of non-ephemeron KVP, i.e., Strong/Strong or Weak/Weak.
-- // Order does not matter here.
-- blink::TraceCollectionIfEnabled<
-- kNoWeakHandling, Key, typename Traits::KeyTraits>::Trace(visitor,
-- &self.key);
-- blink::TraceCollectionIfEnabled<
-- kNoWeakHandling, Value,
-- typename Traits::ValueTraits>::Trace(visitor, &self.value);
-- }
-+ struct TraceImplDefault {
-+ static void Trace(blink::Visitor* visitor,
-+ const KeyValuePair<Key, Value>& self) {
-+ // Strongification of non-ephemeron KVP, i.e., Strong/Strong or Weak/Weak.
-+ // Order does not matter here.
-+ blink::TraceCollectionIfEnabled<
-+ kNoWeakHandling, Key, typename Traits::KeyTraits>::Trace(visitor,
-+ &self.key);
-+ blink::TraceCollectionIfEnabled<
-+ kNoWeakHandling, Value,
-+ typename Traits::ValueTraits>::Trace(visitor, &self.value);
-+ }
-+ };
-+
-+ using TraceImpl = typename std::conditional<EphemeronHelper::is_ephemeron,
-+ TraceImplEphemerons,
-+ TraceImplDefault>::type;
- };
-
- template <typename Key, typename Value, typename Traits>
---
-2.26.2
-
diff --git a/chromium/chromium/chromium-gcc10-r772267.patch b/chromium/chromium/chromium-gcc10-r772267.patch
deleted file mode 100644
index 0e55d31..0000000
--- a/chromium/chromium/chromium-gcc10-r772267.patch
+++ /dev/null
@@ -1,35 +0,0 @@
-From 408bded3befc625e16ef18f2ff5467e040b203e7 Mon Sep 17 00:00:00 2001
-From: Raphael Kubo da Costa <raphael.kubo.da.costa@intel.com>
-Date: Wed, 27 May 2020 16:34:56 +0000
-Subject: [PATCH] ListContainerHelper: Include <cstring> for memcpy()
-
-IWYU. This fixes the libstdc++ build after commit 41989bd89 ("Remove/replace
-unnecessary logging.h includes in .cc files (cc)").
-
-Bug: 957519
-Change-Id: I1e782e8310ca548947b2d541af6a2159d928d1f3
-Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2218090
-Reviewed-by: vmpstr <vmpstr@chromium.org>
-Commit-Queue: vmpstr <vmpstr@chromium.org>
-Commit-Queue: Raphael Kubo da Costa <raphael.kubo.da.costa@intel.com>
-Auto-Submit: Raphael Kubo da Costa <raphael.kubo.da.costa@intel.com>
-Cr-Commit-Position: refs/heads/master@{#772267}
----
- cc/base/list_container_helper.cc | 1 +
- 1 file changed, 1 insertion(+)
-
-diff --git a/cc/base/list_container_helper.cc b/cc/base/list_container_helper.cc
-index afd386e3a883..7b594b4a4580 100644
---- a/cc/base/list_container_helper.cc
-+++ b/cc/base/list_container_helper.cc
-@@ -7,6 +7,7 @@
- #include <stddef.h>
-
- #include <algorithm>
-+#include <cstring>
- #include <vector>
-
- #include "base/check_op.h"
---
-2.26.2
-
diff --git a/chromium/chromium/chromium-gcc10-r772283.patch b/chromium/chromium/chromium-gcc10-r772283.patch
deleted file mode 100644
index abfbc1b..0000000
--- a/chromium/chromium/chromium-gcc10-r772283.patch
+++ /dev/null
@@ -1,70 +0,0 @@
-From df413313083a9dabdc573545aaf70343aa0830ca Mon Sep 17 00:00:00 2001
-From: Stephan Hartmann <stha09@googlemail.com>
-Date: Wed, 27 May 2020 17:03:03 +0000
-Subject: [PATCH] GCC: fix decltype to get a valid function pointer
-
-The decltype(<func>) passed as template parameter to
-CBBFunctionToVector does not return a function pointer
-and GCC complains like this:
-
-../../device/fido/virtual_fido_device.cc:104:68: error:
- 'int(struct cbb_st*, const struct evp_pkey_st*)' is not a valid type
- for a template non-type parameter
- 104 | EVP_marshal_private_key>(pkey_.get());
- | ^
-
-Fix this by passing decltype(&<func>).
-
-Bug: 819294
-Change-Id: I8114c3d75c9865779d58c0b6a6c48e6affd3175b
-Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2217414
-Reviewed-by: Adam Langley <agl@chromium.org>
-Commit-Queue: Adam Langley <agl@chromium.org>
-Cr-Commit-Position: refs/heads/master@{#772283}
----
- device/fido/virtual_fido_device.cc | 8 ++++----
- 1 file changed, 4 insertions(+), 4 deletions(-)
-
-diff --git a/device/fido/virtual_fido_device.cc b/device/fido/virtual_fido_device.cc
-index 0256c6ad4698..72423d322ad1 100644
---- a/device/fido/virtual_fido_device.cc
-+++ b/device/fido/virtual_fido_device.cc
-@@ -51,7 +51,7 @@ constexpr uint8_t kAttestationKey[]{
-
- // CBBFunctionToVector converts a BoringSSL function that writes to a CBB to one
- // that returns a std::vector. Invoke for a function, f, with:
--// CBBFunctionToVector<decltype(f), f>(args, to, f);
-+// CBBFunctionToVector<decltype(&f), f>(args, to, f);
- template <typename F, F function, typename... Args>
- std::vector<uint8_t> CBBFunctionToVector(Args&&... args) {
- uint8_t* der = nullptr;
-@@ -102,7 +102,7 @@ class EVPBackedPrivateKey : public VirtualFidoDevice::PrivateKey {
- }
-
- std::vector<uint8_t> GetPKCS8PrivateKey() const override {
-- return CBBFunctionToVector<decltype(EVP_marshal_private_key),
-+ return CBBFunctionToVector<decltype(&EVP_marshal_private_key),
- EVP_marshal_private_key>(pkey_.get());
- }
-
-@@ -122,7 +122,7 @@ class P256PrivateKey : public EVPBackedPrivateKey {
-
- std::vector<uint8_t> GetX962PublicKey() const override {
- const EC_KEY* ec_key = EVP_PKEY_get0_EC_KEY(pkey_.get());
-- return CBBFunctionToVector<decltype(EC_POINT_point2cbb),
-+ return CBBFunctionToVector<decltype(&EC_POINT_point2cbb),
- EC_POINT_point2cbb>(
- EC_KEY_get0_group(ec_key), EC_KEY_get0_public_key(ec_key),
- POINT_CONVERSION_UNCOMPRESSED, /*ctx=*/nullptr);
-@@ -172,7 +172,7 @@ class RSAPrivateKey : public EVPBackedPrivateKey {
- cbor::Writer::Write(cbor::Value(std::move(map))));
-
- std::vector<uint8_t> der_bytes(
-- CBBFunctionToVector<decltype(EVP_marshal_public_key),
-+ CBBFunctionToVector<decltype(&EVP_marshal_public_key),
- EVP_marshal_public_key>(pkey_.get()));
-
- return std::make_unique<PublicKey>(
---
-2.26.2
-
diff --git a/chromium/chromium/chromium-gcc10-r772542.patch b/chromium/chromium/chromium-gcc10-r772542.patch
deleted file mode 100644
index 1362c62..0000000
--- a/chromium/chromium/chromium-gcc10-r772542.patch
+++ /dev/null
@@ -1,44 +0,0 @@
-From fff3279bcf904673d312893b09bfc53811028490 Mon Sep 17 00:00:00 2001
-From: Stephan Hartmann <stha09@googlemail.com>
-Date: Thu, 28 May 2020 03:17:09 +0000
-Subject: [PATCH] GCC: use brace-initializer for QuotaClientType base::flat_set
-
-Constructing base::flat_set of QuotaClientType with parenthesis
-constructor is ambiguous in GCC. Use brace-initializer to avoid
-that problem.
-
-Bug: 819294
-Change-Id: Id33256a25d2af98d7be6ee570e2535a8b7bdf031
-Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2217554
-Reviewed-by: Kinuko Yasuda <kinuko@chromium.org>
-Commit-Queue: Kinuko Yasuda <kinuko@chromium.org>
-Cr-Commit-Position: refs/heads/master@{#772542}
----
- storage/browser/quota/quota_client_type.cc | 4 ++--
- 1 file changed, 2 insertions(+), 2 deletions(-)
-
-diff --git a/storage/browser/quota/quota_client_type.cc b/storage/browser/quota/quota_client_type.cc
-index b9e9f62a6afd..a2daaa23b5eb 100644
---- a/storage/browser/quota/quota_client_type.cc
-+++ b/storage/browser/quota/quota_client_type.cc
-@@ -9,7 +9,7 @@
- namespace storage {
-
- const QuotaClientTypes& AllQuotaClientTypes() {
-- static base::NoDestructor<QuotaClientTypes> all({
-+ static base::NoDestructor<QuotaClientTypes> all{{
- QuotaClientType::kFileSystem,
- QuotaClientType::kDatabase,
- QuotaClientType::kAppcache,
-@@ -17,7 +17,7 @@ const QuotaClientTypes& AllQuotaClientTypes() {
- QuotaClientType::kServiceWorkerCache,
- QuotaClientType::kServiceWorker,
- QuotaClientType::kBackgroundFetch,
-- });
-+ }};
- return *all;
- }
-
---
-2.26.2
-
diff --git a/chromium/chromium/chromium-gcc10-r773698.patch b/chromium/chromium/chromium-gcc10-r773698.patch
deleted file mode 100644
index 3087820..0000000
--- a/chromium/chromium/chromium-gcc10-r773698.patch
+++ /dev/null
@@ -1,39 +0,0 @@
-From f23cbade5ecc451b9a01bd11dd9de7456424722c Mon Sep 17 00:00:00 2001
-From: Stephan Hartmann <stha09@googlemail.com>
-Date: Mon, 1 Jun 2020 17:02:08 +0000
-Subject: [PATCH] GCC: DOMRect constexpr equal operator depends on non
- constexpr operators
-
-Make operators 'inline' only.
-
-Bug: 819294
-Change-Id: If07442258b4ebce26c013c4dff830c1d61dff9e3
-Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2217415
-Commit-Queue: Fernando Serboncini <fserb@chromium.org>
-Reviewed-by: Fernando Serboncini <fserb@chromium.org>
-Cr-Commit-Position: refs/heads/master@{#773698}
----
- third_party/blink/renderer/core/geometry/dom_rect.h | 4 ++--
- 1 file changed, 2 insertions(+), 2 deletions(-)
-
-diff --git a/third_party/blink/renderer/core/geometry/dom_rect.h b/third_party/blink/renderer/core/geometry/dom_rect.h
-index fede00578e6b..058c60a904ef 100644
---- a/third_party/blink/renderer/core/geometry/dom_rect.h
-+++ b/third_party/blink/renderer/core/geometry/dom_rect.h
-@@ -34,11 +34,11 @@ class CORE_EXPORT DOMRect final : public DOMRectReadOnly {
- void setHeight(double height) { height_ = height; }
- };
-
--constexpr bool operator==(const DOMRect& lhs, const DOMRect& rhs) {
-+inline bool operator==(const DOMRect& lhs, const DOMRect& rhs) {
- return lhs.x() == rhs.x() && lhs.y() == rhs.y() &&
- lhs.width() == rhs.width() && lhs.height() == rhs.height();
- }
--constexpr bool operator!=(const DOMRect& lhs, const DOMRect& rhs) {
-+inline bool operator!=(const DOMRect& lhs, const DOMRect& rhs) {
- return !(lhs == rhs);
- }
- } // namespace blink
---
-2.26.2
-
diff --git a/chromium/chromium/chromium-gcc10-r773855.patch b/chromium/chromium/chromium-gcc10-r773855.patch
deleted file mode 100644
index bab426a..0000000
--- a/chromium/chromium/chromium-gcc10-r773855.patch
+++ /dev/null
@@ -1,73 +0,0 @@
-From 2ec52ff90ae0345a1ba50665e8c98bf99c9cfd45 Mon Sep 17 00:00:00 2001
-From: Stephan Hartmann <stha09@googlemail.com>
-Date: Mon, 1 Jun 2020 21:56:38 +0000
-Subject: [PATCH] libstdc++: std::vector must have non-const value_type
-
-Bug: 957519
-Change-Id: I535b3bcf318f98cecbf4be1520ffe4126abcacd8
-Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2214556
-Commit-Queue: Karan Bhatia <karandeepb@chromium.org>
-Reviewed-by: Karan Bhatia <karandeepb@chromium.org>
-Cr-Commit-Position: refs/heads/master@{#773855}
----
- extensions/common/features/feature_flags.cc | 6 +++---
- extensions/common/features/feature_flags.h | 4 ++--
- extensions/common/features/simple_feature_unittest.cc | 2 +-
- 3 files changed, 6 insertions(+), 6 deletions(-)
-
-diff --git a/extensions/common/features/feature_flags.cc b/extensions/common/features/feature_flags.cc
-index 5b63764e4c19..7efa308dbecd 100644
---- a/extensions/common/features/feature_flags.cc
-+++ b/extensions/common/features/feature_flags.cc
-@@ -19,7 +19,7 @@ namespace {
- constexpr base::Feature kFeatureFlags[] = {
- {"DeclarativeNetRequest", base::FEATURE_ENABLED_BY_DEFAULT}};
-
--const std::vector<const base::Feature>* g_feature_flags_test_override = nullptr;
-+const std::vector<base::Feature>* g_feature_flags_test_override = nullptr;
-
- template <typename T>
- const base::Feature* GetFeature(T begin,
-@@ -52,8 +52,8 @@ bool IsFeatureFlagEnabled(const std::string& feature_flag) {
- }
-
- ScopedFeatureFlagsOverride CreateScopedFeatureFlagsOverrideForTesting(
-- const std::vector<const base::Feature>* features) {
-- return base::AutoReset<const std::vector<const base::Feature>*>(
-+ const std::vector<base::Feature>* features) {
-+ return base::AutoReset<const std::vector<base::Feature>*>(
- &g_feature_flags_test_override, features);
- }
-
-diff --git a/extensions/common/features/feature_flags.h b/extensions/common/features/feature_flags.h
-index d1a5dd3720b3..b57740b25cf6 100644
---- a/extensions/common/features/feature_flags.h
-+++ b/extensions/common/features/feature_flags.h
-@@ -25,9 +25,9 @@ bool IsFeatureFlagEnabled(const std::string& feature_flag);
- // in scope. Clients must ensure that |features| remains alive (non-dangling)
- // while the returned value is in scope.
- using ScopedFeatureFlagsOverride =
-- base::AutoReset<const std::vector<const base::Feature>*>;
-+ base::AutoReset<const std::vector<base::Feature>*>;
- ScopedFeatureFlagsOverride CreateScopedFeatureFlagsOverrideForTesting(
-- const std::vector<const base::Feature>* features);
-+ const std::vector<base::Feature>* features);
-
- } // namespace extensions
-
-diff --git a/extensions/common/features/simple_feature_unittest.cc b/extensions/common/features/simple_feature_unittest.cc
-index 8d9e0ad31534..659d4ef7c90a 100644
---- a/extensions/common/features/simple_feature_unittest.cc
-+++ b/extensions/common/features/simple_feature_unittest.cc
-@@ -718,7 +718,7 @@ TEST_F(SimpleFeatureTest, CommandLineSwitch) {
- }
-
- TEST_F(SimpleFeatureTest, FeatureFlags) {
-- const std::vector<const base::Feature> features(
-+ const std::vector<base::Feature> features(
- {{"stub_feature_1", base::FEATURE_ENABLED_BY_DEFAULT},
- {"stub_feature_2", base::FEATURE_DISABLED_BY_DEFAULT}});
- auto scoped_feature_override =
---
-2.26.2
-
diff --git a/chromium/chromium/chromium-gcc10-r774141.patch b/chromium/chromium/chromium-gcc10-r774141.patch
deleted file mode 100644
index 81c86c1..0000000
--- a/chromium/chromium/chromium-gcc10-r774141.patch
+++ /dev/null
@@ -1,43 +0,0 @@
-From 3b7fd76b6bc43b4a462e296168dc59541a713c11 Mon Sep 17 00:00:00 2001
-From: Stephan Hartmann <stha09@googlemail.com>
-Date: Tue, 2 Jun 2020 15:12:11 +0000
-Subject: [PATCH] GCC: fix template specialization in WTF::VectorBuffer
-
-GCC complains that explicit specialization in non-namespace scope
-is happening for InitInlinedBuffer. However, specialization is
-not really necessary here with templates and can be moved
-into InitInlinedBuffer method without changing generated code.
-
-Bug: 819294
-Change-Id: Ia8060152bf4ba21c85dfc4d99cd7cc64983de077
-Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2179122
-Reviewed-by: Nico Weber <thakis@chromium.org>
-Commit-Queue: Nico Weber <thakis@chromium.org>
-Cr-Commit-Position: refs/heads/master@{#774141}
----
- third_party/blink/renderer/platform/wtf/vector.h | 9 ++++-----
- 1 file changed, 4 insertions(+), 5 deletions(-)
-
-diff --git a/third_party/blink/renderer/platform/wtf/vector.h b/third_party/blink/renderer/platform/wtf/vector.h
-index 267eb905013b..d75f348550db 100644
---- a/third_party/blink/renderer/platform/wtf/vector.h
-+++ b/third_party/blink/renderer/platform/wtf/vector.h
-@@ -950,11 +950,10 @@ class VectorBuffer : protected VectorBufferBase<T, Allocator> {
- return unsafe_reinterpret_cast_ptr<const T*>(inline_buffer_);
- }
-
-- template <bool = Allocator::kIsGarbageCollected>
-- void InitInlinedBuffer() {}
-- template <>
-- void InitInlinedBuffer<true>() {
-- memset(&inline_buffer_, 0, kInlineBufferSize);
-+ void InitInlinedBuffer() {
-+ if (Allocator::kIsGarbageCollected) {
-+ memset(&inline_buffer_, 0, kInlineBufferSize);
-+ }
- }
-
- alignas(T) char inline_buffer_[kInlineBufferSize];
---
-2.26.2
-
diff --git a/chromium/chromium/chromium-gcc10-r775439.patch b/chromium/chromium/chromium-gcc10-r775439.patch
deleted file mode 100644
index d27d546..0000000
--- a/chromium/chromium/chromium-gcc10-r775439.patch
+++ /dev/null
@@ -1,125 +0,0 @@
-From cd5da994cb70eb13320183e767cae459900d7a31 Mon Sep 17 00:00:00 2001
-From: Joshua Peraza <jperaza@chromium.org>
-Date: Fri, 5 Jun 2020 05:14:24 +0000
-Subject: [PATCH] Update Crashpad to 7a70b0f1513d2787437aafc6593c97cbd0f2d94e
-
-a8ff62676466 Add a bunch of missing string.h includes
-4b5a5bac26be win: Make CreatePipe compatible with UWP apps
-686852d9d87d linux: update test expectations
-86c28287d23a linux: add section header string table to test module
-294d233ca09e elf: adjust small DT_STRTAB addresses by load bias
-7a70b0f1513d android: correct executable placement in debug rendezvous
-
-Change-Id: Ie34272e560e92779661d804c8664f52e72a86349
-Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2231880
-Commit-Queue: Mark Mentovai <mark@chromium.org>
-Auto-Submit: Joshua Peraza <jperaza@chromium.org>
-Reviewed-by: Mark Mentovai <mark@chromium.org>
-Cr-Commit-Position: refs/heads/master@{#775439}
----
- third_party/crashpad/README.chromium | 2 +-
- .../crashpad/client/crashpad_client_win.cc | 9 ++-
- .../client/simple_address_range_bag.h | 1 +
- .../crashpad/snapshot/elf/elf_image_reader.cc | 8 +++
- .../snapshot/linux/debug_rendezvous.cc | 16 +++++
- .../snapshot/linux/debug_rendezvous_test.cc | 23 +++++--
- .../snapshot/linux/process_reader_linux.cc | 4 +-
- .../linux/process_reader_linux_test.cc | 65 ++++++++++++++-----
- .../minidump/minidump_context_converter.cc | 2 +
- .../crashpad/util/linux/ptrace_client.cc | 1 +
- .../util/net/http_multipart_builder.cc | 1 +
- .../util/net/http_transport_socket.cc | 1 +
- .../crashpad/util/process/process_memory.cc | 2 +
- .../crashpad/util/stream/log_output_stream.cc | 2 +
- 14 files changed, 109 insertions(+), 28 deletions(-)
-
-diff --git a/third_party/crashpad/crashpad/client/simple_address_range_bag.h b/third_party/crashpad/crashpad/client/simple_address_range_bag.h
-index c69fa5afd8b2..d288303c4d5b 100644
---- a/third_party/crashpad/crashpad/client/simple_address_range_bag.h
-+++ b/third_party/crashpad/crashpad/client/simple_address_range_bag.h
-@@ -16,6 +16,7 @@
- #define CRASHPAD_CLIENT_SIMPLE_ADDRESS_RANGE_BAG_H_
-
- #include <stdint.h>
-+#include <string.h>
-
- #include <type_traits>
-
-diff --git a/third_party/crashpad/crashpad/snapshot/minidump/minidump_context_converter.cc b/third_party/crashpad/crashpad/snapshot/minidump/minidump_context_converter.cc
-index 0c840deac227..24d2585b376e 100644
---- a/third_party/crashpad/crashpad/snapshot/minidump/minidump_context_converter.cc
-+++ b/third_party/crashpad/crashpad/snapshot/minidump/minidump_context_converter.cc
-@@ -14,6 +14,8 @@
-
- #include "snapshot/minidump/minidump_context_converter.h"
-
-+#include <string.h>
-+
- #include "base/stl_util.h"
- #include "minidump/minidump_context.h"
-
-diff --git a/third_party/crashpad/crashpad/util/linux/ptrace_client.cc b/third_party/crashpad/crashpad/util/linux/ptrace_client.cc
-index f097ad98593d..43214a18af20 100644
---- a/third_party/crashpad/crashpad/util/linux/ptrace_client.cc
-+++ b/third_party/crashpad/crashpad/util/linux/ptrace_client.cc
-@@ -16,6 +16,7 @@
-
- #include <errno.h>
- #include <stdio.h>
-+#include <string.h>
-
- #include <string>
-
-diff --git a/third_party/crashpad/crashpad/util/net/http_multipart_builder.cc b/third_party/crashpad/crashpad/util/net/http_multipart_builder.cc
-index 267960b274f9..dda46aa3ce9b 100644
---- a/third_party/crashpad/crashpad/util/net/http_multipart_builder.cc
-+++ b/third_party/crashpad/crashpad/util/net/http_multipart_builder.cc
-@@ -14,6 +14,7 @@
-
- #include "util/net/http_multipart_builder.h"
-
-+#include <string.h>
- #include <sys/types.h>
-
- #include <utility>
-diff --git a/third_party/crashpad/crashpad/util/net/http_transport_socket.cc b/third_party/crashpad/crashpad/util/net/http_transport_socket.cc
-index 4dd01b6e7a69..b9c6c9c5e064 100644
---- a/third_party/crashpad/crashpad/util/net/http_transport_socket.cc
-+++ b/third_party/crashpad/crashpad/util/net/http_transport_socket.cc
-@@ -17,6 +17,7 @@
- #include <fcntl.h>
- #include <netdb.h>
- #include <poll.h>
-+#include <string.h>
- #include <sys/socket.h>
-
- #include "base/logging.h"
-diff --git a/third_party/crashpad/crashpad/util/process/process_memory.cc b/third_party/crashpad/crashpad/util/process/process_memory.cc
-index ab87b940fa14..3125e6f3852c 100644
---- a/third_party/crashpad/crashpad/util/process/process_memory.cc
-+++ b/third_party/crashpad/crashpad/util/process/process_memory.cc
-@@ -14,6 +14,8 @@
-
- #include "util/process/process_memory.h"
-
-+#include <string.h>
-+
- #include <algorithm>
-
- #include "base/logging.h"
-diff --git a/third_party/crashpad/crashpad/util/stream/log_output_stream.cc b/third_party/crashpad/crashpad/util/stream/log_output_stream.cc
-index 03c0a5a02dbe..e35bb3b32fc1 100644
---- a/third_party/crashpad/crashpad/util/stream/log_output_stream.cc
-+++ b/third_party/crashpad/crashpad/util/stream/log_output_stream.cc
-@@ -14,6 +14,8 @@
-
- #include "util/stream/log_output_stream.h"
-
-+#include <string.h>
-+
- #include <algorithm>
-
- #include "base/logging.h"
---
-2.26.2
-
diff --git a/chromium/chromium/chromium-gcc10-r778406.patch b/chromium/chromium/chromium-gcc10-r778406.patch
deleted file mode 100644
index 7451871..0000000
--- a/chromium/chromium/chromium-gcc10-r778406.patch
+++ /dev/null
@@ -1,33 +0,0 @@
-From eddad6d81cf621c88fd5c395826241236f56e8ac Mon Sep 17 00:00:00 2001
-From: Kristian Kirs <kristian.kirs@lge.com>
-Date: Mon, 15 Jun 2020 19:08:54 +0000
-Subject: [PATCH] GCC: Fix DHECK_EQ
-
-GCC complains about it
-
-Change-Id: I4c5ffcc66225c895efde77a77c83342d6794b5e1
-Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2246170
-Reviewed-by: Christian Biesinger <cbiesinger@chromium.org>
-Reviewed-by: Koji Ishii <kojii@chromium.org>
-Commit-Queue: Koji Ishii <kojii@chromium.org>
-Cr-Commit-Position: refs/heads/master@{#778406}
----
- .../blink/renderer/core/layout/ng/inline/ng_inline_node.cc | 2 +-
- 1 file changed, 1 insertion(+), 1 deletion(-)
-
-diff --git a/third_party/blink/renderer/core/layout/ng/inline/ng_inline_node.cc b/third_party/blink/renderer/core/layout/ng/inline/ng_inline_node.cc
-index 9baf436feb9c..e9cbb609513c 100644
---- a/third_party/blink/renderer/core/layout/ng/inline/ng_inline_node.cc
-+++ b/third_party/blink/renderer/core/layout/ng/inline/ng_inline_node.cc
-@@ -818,7 +818,7 @@ void NGInlineNode::SegmentText(NGInlineNodeData* data) const {
-
- // Segment NGInlineItem by script, Emoji, and orientation using RunSegmenter.
- void NGInlineNode::SegmentScriptRuns(NGInlineNodeData* data) {
-- DCHECK_EQ(data->segments, nullptr);
-+ DCHECK_EQ(data->segments.get(), nullptr);
-
- String& text_content = data->text_content;
- if (text_content.IsEmpty()) {
---
-2.26.2
-
diff --git a/chromium/chromium/chromium-gcc10-r783489.patch b/chromium/chromium/chromium-gcc10-r783489.patch
new file mode 100644
index 0000000..1f3547e
--- /dev/null
+++ b/chromium/chromium/chromium-gcc10-r783489.patch
@@ -0,0 +1,706 @@
+From e8ec5cc524f989d9f4cb2e19f401fa7b958a1751 Mon Sep 17 00:00:00 2001
+From: Naomi Musgrave <nmusgrave@chromium.org>
+Date: Mon, 29 Jun 2020 12:30:00 +0000
+Subject: [PATCH] Split decoder so that necessary methods are in public
+
+Bug: 1084582
+Change-Id: Iff455ac6887661f39d60c7bcd7e5ef999179ac91
+Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2270226
+Commit-Queue: Naomi Musgrave <nmusgrave@chromium.org>
+Reviewed-by: Alex Chau <alexchau@chromium.org>
+Cr-Commit-Position: refs/heads/master@{#783489}
+---
+ .../services/sharing/nearby_decoder/BUILD.gn | 10 +-
+ .../nearby_decoder/advertisement_decoder.cc | 94 +++++++++++++++++++
+ .../nearby_decoder/advertisement_decoder.h | 35 +++++++
+ ...t.cc => advertisement_decoder_unittest.cc} | 75 +++++----------
+ .../sharing/nearby_decoder/nearby_decoder.cc | 7 +-
+ .../nearby_decoder/nearby_decoder_unittest.cc | 4 +-
+ chrome/services/sharing/public/cpp/BUILD.gn | 19 +++-
+ .../cpp}/advertisement.cc | 74 +--------------
+ .../cpp}/advertisement.h | 13 +--
+ .../public/cpp/advertisement_unittest.cc | 63 +++++++++++++
+ .../{nearby_decoder => public}/proto/BUILD.gn | 0
+ .../proto/wire_format.proto | 0
+ chrome/test/BUILD.gn | 1 +
+ 13 files changed, 251 insertions(+), 144 deletions(-)
+ create mode 100644 chrome/services/sharing/nearby_decoder/advertisement_decoder.cc
+ create mode 100644 chrome/services/sharing/nearby_decoder/advertisement_decoder.h
+ rename chrome/services/sharing/nearby_decoder/{advertisement_unittest.cc => advertisement_decoder_unittest.cc} (60%)
+ rename chrome/services/sharing/{nearby_decoder => public/cpp}/advertisement.cc (59%)
+ rename chrome/services/sharing/{nearby_decoder => public/cpp}/advertisement.h (83%)
+ create mode 100644 chrome/services/sharing/public/cpp/advertisement_unittest.cc
+ rename chrome/services/sharing/{nearby_decoder => public}/proto/BUILD.gn (100%)
+ rename chrome/services/sharing/{nearby_decoder => public}/proto/wire_format.proto (100%)
+
+diff --git a/chrome/services/sharing/nearby_decoder/BUILD.gn b/chrome/services/sharing/nearby_decoder/BUILD.gn
+index 6b7666f303d0..0dfe998736e9 100644
+--- a/chrome/services/sharing/nearby_decoder/BUILD.gn
++++ b/chrome/services/sharing/nearby_decoder/BUILD.gn
+@@ -6,17 +6,17 @@ import("//testing/libfuzzer/fuzzer_test.gni")
+
+ source_set("nearby_decoder") {
+ sources = [
+- "advertisement.cc",
+- "advertisement.h",
++ "advertisement_decoder.cc",
++ "advertisement_decoder.h",
+ "nearby_decoder.cc",
+ "nearby_decoder.h",
+ ]
+
+- deps = [ "//chrome/services/sharing/nearby_decoder/proto" ]
+-
+ public_deps = [
+ "//base",
++ "//chrome/services/sharing/public/cpp",
+ "//chrome/services/sharing/public/mojom",
++ "//chrome/services/sharing/public/proto",
+ "//mojo/public/cpp/bindings",
+ ]
+ }
+@@ -25,7 +25,7 @@ source_set("unit_tests") {
+ testonly = true
+
+ sources = [
+- "advertisement_unittest.cc",
++ "advertisement_decoder_unittest.cc",
+ "nearby_decoder_unittest.cc",
+ ]
+
+diff --git a/chrome/services/sharing/nearby_decoder/advertisement_decoder.cc b/chrome/services/sharing/nearby_decoder/advertisement_decoder.cc
+new file mode 100644
+index 000000000000..68173b240964
+--- /dev/null
++++ b/chrome/services/sharing/nearby_decoder/advertisement_decoder.cc
+@@ -0,0 +1,94 @@
++// Copyright 2020 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 <utility>
++
++#include "chrome/services/sharing/nearby_decoder/advertisement_decoder.h"
++
++#include "base/logging.h"
++#include "base/memory/ptr_util.h"
++#include "base/strings/string_util.h"
++
++namespace {
++
++// The bit mask for parsing and writing Version.
++constexpr uint8_t kVersionBitmask = 0b111;
++
++// The bit mask for parsing and writing Visibility.
++constexpr uint8_t kVisibilityBitmask = 0b1;
++
++constexpr uint8_t kMinimumSize =
++ /* Version(3 bits)|Visibility(1 bit)|Reserved(4 bits)= */ 1 +
++ sharing::Advertisement::kSaltSize +
++ sharing::Advertisement::kMetadataEncryptionKeyHashByteSize;
++
++int ParseVersion(uint8_t b) {
++ return (b >> 5) & kVersionBitmask;
++}
++
++bool ParseHasDeviceName(uint8_t b) {
++ return ((b >> 4) & kVisibilityBitmask) == 0;
++}
++
++} // namespace
++
++namespace sharing {
++
++// static
++std::unique_ptr<sharing::Advertisement> AdvertisementDecoder::FromEndpointInfo(
++ base::span<const uint8_t> endpoint_info) {
++ if (endpoint_info.size() < kMinimumSize) {
++ LOG(ERROR) << "Failed to parse advertisement because it was too short.";
++ return nullptr;
++ }
++
++ auto iter = endpoint_info.begin();
++ uint8_t first_byte = *iter++;
++
++ int version = ParseVersion(first_byte);
++ if (version != 0) {
++ LOG(ERROR) << "Failed to parse advertisement because we failed to parse "
++ "the version number";
++ return nullptr;
++ }
++
++ bool has_device_name = ParseHasDeviceName(first_byte);
++
++ std::vector<uint8_t> salt(iter, iter + sharing::Advertisement::kSaltSize);
++ iter += sharing::Advertisement::kSaltSize;
++
++ std::vector<uint8_t> encrypted_metadata_key(
++ iter, iter + sharing::Advertisement::kMetadataEncryptionKeyHashByteSize);
++ iter += sharing::Advertisement::kMetadataEncryptionKeyHashByteSize;
++
++ int device_name_length = 0;
++ if (iter != endpoint_info.end())
++ device_name_length = *iter++ & 0xff;
++
++ if (endpoint_info.end() - iter < device_name_length ||
++ (device_name_length == 0 && has_device_name)) {
++ LOG(ERROR) << "Failed to parse advertisement because the device name did "
++ "not match the expected length "
++ << device_name_length;
++ return nullptr;
++ }
++
++ base::Optional<std::string> optional_device_name;
++ if (device_name_length > 0) {
++ optional_device_name = std::string(iter, iter + device_name_length);
++ iter += device_name_length;
++
++ if (!base::IsStringUTF8(*optional_device_name)) {
++ LOG(ERROR) << "Failed to parse advertisement because the device name was "
++ "corrupted";
++ return nullptr;
++ }
++ }
++
++ return sharing::Advertisement::NewInstance(std::move(salt),
++ std::move(encrypted_metadata_key),
++ std::move(optional_device_name));
++}
++
++} // namespace sharing
+diff --git a/chrome/services/sharing/nearby_decoder/advertisement_decoder.h b/chrome/services/sharing/nearby_decoder/advertisement_decoder.h
+new file mode 100644
+index 000000000000..3a916ab7de5f
+--- /dev/null
++++ b/chrome/services/sharing/nearby_decoder/advertisement_decoder.h
+@@ -0,0 +1,35 @@
++// Copyright 2020 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 CHROME_SERVICES_SHARING_NEARBY_DECODER_ADVERTISEMENT_DECODER_H_
++#define CHROME_SERVICES_SHARING_NEARBY_DECODER_ADVERTISEMENT_DECODER_H_
++
++#include <stdint.h>
++#include <memory>
++#include <string>
++#include <vector>
++
++#include "base/containers/span.h"
++#include "base/optional.h"
++#include "chrome/services/sharing/public/cpp/advertisement.h"
++
++namespace sharing {
++
++// A utility class to convert from a byte span in the form of
++// [VERSION|VISIBILITY][SALT][ACCOUNT_IDENTIFIER][LEN][DEVICE_NAME],
++// to an Advertisement.
++// A device name indicates the advertisement is visible to everyone;
++// a missing device name indicates the advertisement is contacts-only.
++class AdvertisementDecoder {
++ public:
++ AdvertisementDecoder() = delete;
++ ~AdvertisementDecoder() = delete;
++
++ static std::unique_ptr<sharing::Advertisement> FromEndpointInfo(
++ base::span<const uint8_t> endpoint_info);
++};
++
++} // namespace sharing
++
++#endif // CHROME_SERVICES_SHARING_NEARBY_DECODER_ADVERTISEMENT_DECODER_H_
+diff --git a/chrome/services/sharing/nearby_decoder/advertisement_unittest.cc b/chrome/services/sharing/nearby_decoder/advertisement_decoder_unittest.cc
+similarity index 60%
+rename from chrome/services/sharing/nearby_decoder/advertisement_unittest.cc
+rename to chrome/services/sharing/nearby_decoder/advertisement_decoder_unittest.cc
+index e618b66d0fa6..bfc1dd33e4cf 100644
+--- a/chrome/services/sharing/nearby_decoder/advertisement_unittest.cc
++++ b/chrome/services/sharing/nearby_decoder/advertisement_decoder_unittest.cc
+@@ -7,11 +7,11 @@
+ #include <string>
+ #include <vector>
+
+-#include "chrome/services/sharing/nearby_decoder/advertisement.h"
+-#include "chrome/services/sharing/nearby_decoder/nearby_decoder.h"
++#include "chrome/services/sharing/nearby_decoder/advertisement_decoder.h"
+
+ #include "base/strings/strcat.h"
+ #include "base/test/task_environment.h"
++#include "chrome/services/sharing/public/cpp/advertisement.h"
+ #include "mojo/public/cpp/bindings/remote.h"
+ #include "testing/gtest/include/gtest/gtest.h"
+
+@@ -37,123 +37,94 @@ void ExpectEquals(const Advertisement& self, const Advertisement& other) {
+
+ } // namespace
+
+-TEST(AdvertisementTest, CreateNewInstanceWithNullName) {
+- std::unique_ptr<sharing::Advertisement> advertisement =
+- sharing::Advertisement::NewInstance(kSalt, kEncryptedMetadataKey,
+- /* device_name=*/base::nullopt);
+- EXPECT_FALSE(advertisement->device_name());
+- EXPECT_EQ(advertisement->encrypted_metadata_key(), kEncryptedMetadataKey);
+- EXPECT_FALSE(advertisement->HasDeviceName());
+- EXPECT_EQ(advertisement->salt(), kSalt);
+-}
+-
+-TEST(AdvertisementTest, CreateNewInstance) {
+- std::unique_ptr<sharing::Advertisement> advertisement =
+- sharing::Advertisement::NewInstance(kSalt, kEncryptedMetadataKey,
+- kDeviceName);
+- EXPECT_EQ(advertisement->device_name(), kDeviceName);
+- EXPECT_EQ(advertisement->encrypted_metadata_key(), kEncryptedMetadataKey);
+- EXPECT_TRUE(advertisement->HasDeviceName());
+- EXPECT_EQ(advertisement->salt(), kSalt);
+-}
+-
+-TEST(AdvertisementTest, CreateNewInstanceFromEndpointInfo) {
++TEST(AdvertisementDecoderTest, CreateNewInstanceFromEndpointInfo) {
+ std::unique_ptr<sharing::Advertisement> original =
+ sharing::Advertisement::NewInstance(kSalt, kEncryptedMetadataKey,
+ kDeviceName);
+ std::unique_ptr<sharing::Advertisement> advertisement =
+- sharing::Advertisement::FromEndpointInfo(original->ToEndpointInfo());
++ sharing::AdvertisementDecoder::FromEndpointInfo(
++ original->ToEndpointInfo());
+ ExpectEquals(*advertisement, *original);
+ }
+
+-TEST(AdvertisementTest, CreateNewInstanceFromStringWithExtraLength) {
++TEST(AdvertisementDecoderTest, CreateNewInstanceFromStringWithExtraLength) {
+ std::unique_ptr<sharing::Advertisement> original =
+ sharing::Advertisement::NewInstance(
+ kSalt, kEncryptedMetadataKey, base::StrCat({kDeviceName, "123456"}));
+ std::unique_ptr<sharing::Advertisement> advertisement =
+- sharing::Advertisement::FromEndpointInfo(original->ToEndpointInfo());
++ sharing::AdvertisementDecoder::FromEndpointInfo(
++ original->ToEndpointInfo());
+ ExpectEquals(*advertisement, *original);
+ }
+
+-TEST(AdvertisementTest, CreateNewInstanceWithWrongSaltSize) {
+- EXPECT_FALSE(sharing::Advertisement::NewInstance(
+- /* salt= */ std::vector<uint8_t>(5, 5), kEncryptedMetadataKey,
+- kDeviceName));
+-}
+-
+-TEST(AdvertisementTest, CreateNewInstanceWithWrongAccountIdentifierSize) {
+- EXPECT_FALSE(sharing::Advertisement::NewInstance(
+- kSalt, /* encrypted_metadata_key= */ std::vector<uint8_t>(2, 1),
+- kDeviceName));
+-}
+-
+-TEST(AdvertisementTest, SerializeContactsOnlyAdvertisementWithoutDeviceName) {
++TEST(AdvertisementDecoderTest,
++ SerializeContactsOnlyAdvertisementWithoutDeviceName) {
+ std::unique_ptr<sharing::Advertisement> advertisement =
+ sharing::Advertisement::NewInstance(kSalt, kEncryptedMetadataKey,
+ /* device_name= */ base::nullopt);
+- ExpectEquals(*sharing::Advertisement::FromEndpointInfo(
++ ExpectEquals(*sharing::AdvertisementDecoder::FromEndpointInfo(
+ advertisement->ToEndpointInfo()),
+ *advertisement);
+ }
+
+-TEST(AdvertisementTest,
++TEST(AdvertisementDecoderTest,
+ SerializeVisibleToEveryoneAdvertisementWithoutDeviceName) {
+ std::unique_ptr<sharing::Advertisement> advertisement =
+ sharing::Advertisement::NewInstance(kSalt, kEncryptedMetadataKey,
+ /* device_name= */ std::string());
+- EXPECT_FALSE(sharing::Advertisement::FromEndpointInfo(
++ EXPECT_FALSE(sharing::AdvertisementDecoder::FromEndpointInfo(
+ advertisement->ToEndpointInfo()));
+ }
+
+-TEST(AdvertisementTest, V1ContactsOnlyAdvertisementDecoding) {
++TEST(AdvertisementDecoderTest, V1ContactsOnlyAdvertisementDecoding) {
+ std::unique_ptr<sharing::Advertisement> advertisement =
+ sharing::Advertisement::NewInstance(kSalt, kEncryptedMetadataKey,
+ kDeviceName);
+ std::vector<uint8_t> v1EndpointInfo = {
+ 16, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 10, 100, 101, 118, 105, 99, 101, 78, 97, 109, 101};
+- ExpectEquals(*sharing::Advertisement::FromEndpointInfo(v1EndpointInfo),
++ ExpectEquals(*sharing::AdvertisementDecoder::FromEndpointInfo(v1EndpointInfo),
+ *advertisement);
+ }
+
+-TEST(AdvertisementTest, V1VisibleToEveryoneAdvertisementDecoding) {
++TEST(AdvertisementDecoderTest, V1VisibleToEveryoneAdvertisementDecoding) {
+ std::unique_ptr<sharing::Advertisement> advertisement =
+ sharing::Advertisement::NewInstance(kSalt, kEncryptedMetadataKey,
+ kDeviceName);
+ std::vector<uint8_t> v1EndpointInfo = {
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 10, 100, 101, 118, 105, 99, 101, 78, 97, 109, 101};
+- ExpectEquals(*sharing::Advertisement::FromEndpointInfo(v1EndpointInfo),
++ ExpectEquals(*sharing::AdvertisementDecoder::FromEndpointInfo(v1EndpointInfo),
+ *advertisement);
+ }
+
+-TEST(AdvertisementTest, V1ContactsOnlyAdvertisementEncoding) {
++TEST(AdvertisementDecoderTest, V1ContactsOnlyAdvertisementEncoding) {
+ std::unique_ptr<sharing::Advertisement> advertisement =
+ sharing::Advertisement::NewInstance(kSalt, kEncryptedMetadataKey,
+ /* device_name= */ base::nullopt);
+ std::vector<uint8_t> v1EndpointInfo = {16, 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0};
+- ExpectEquals(*sharing::Advertisement::FromEndpointInfo(v1EndpointInfo),
++ ExpectEquals(*sharing::AdvertisementDecoder::FromEndpointInfo(v1EndpointInfo),
+ *advertisement);
+ }
+
+-TEST(AdvertisementTest, V1VisibleToEveryoneAdvertisementEncoding) {
++TEST(AdvertisementDecoderTest, V1VisibleToEveryoneAdvertisementEncoding) {
+ std::unique_ptr<sharing::Advertisement> advertisement =
+ sharing::Advertisement::NewInstance(kSalt, kEncryptedMetadataKey,
+ kDeviceName);
+ std::vector<uint8_t> v1EndpointInfo = {
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 10, 100, 101, 118, 105, 99, 101, 78, 97, 109, 101};
+- ExpectEquals(*sharing::Advertisement::FromEndpointInfo(v1EndpointInfo),
++ ExpectEquals(*sharing::AdvertisementDecoder::FromEndpointInfo(v1EndpointInfo),
+ *advertisement);
+ }
+
+-TEST(AdvertisementTest, InvalidDeviceNameEncoding) {
++TEST(AdvertisementDecoderTest, InvalidDeviceNameEncoding) {
+ std::vector<uint8_t> v1EndpointInfo = {
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 10, 226, 40, 161, 105, 99, 101, 78, 97, 109, 101,
+ };
+- EXPECT_FALSE(sharing::Advertisement::FromEndpointInfo(v1EndpointInfo));
++ EXPECT_FALSE(sharing::AdvertisementDecoder::FromEndpointInfo(v1EndpointInfo));
+ }
+
+ } // namespace sharing
+diff --git a/chrome/services/sharing/nearby_decoder/nearby_decoder.cc b/chrome/services/sharing/nearby_decoder/nearby_decoder.cc
+index 814f972c6262..907c0ee2cb90 100644
+--- a/chrome/services/sharing/nearby_decoder/nearby_decoder.cc
++++ b/chrome/services/sharing/nearby_decoder/nearby_decoder.cc
+@@ -10,9 +10,10 @@
+
+ #include "base/callback.h"
+ #include "base/optional.h"
+-#include "chrome/services/sharing/nearby_decoder/advertisement.h"
+-#include "chrome/services/sharing/nearby_decoder/proto/wire_format.pb.h"
++#include "chrome/services/sharing/nearby_decoder/advertisement_decoder.h"
++#include "chrome/services/sharing/public/cpp/advertisement.h"
+ #include "chrome/services/sharing/public/mojom/nearby_decoder_types.mojom.h"
++#include "chrome/services/sharing/public/proto/wire_format.pb.h"
+
+ namespace sharing {
+
+@@ -217,7 +218,7 @@ void NearbySharingDecoder::DecodeAdvertisement(
+ const std::vector<uint8_t>& data,
+ DecodeAdvertisementCallback callback) {
+ std::unique_ptr<sharing::Advertisement> advertisement =
+- sharing::Advertisement::FromEndpointInfo(data);
++ sharing::AdvertisementDecoder::FromEndpointInfo(data);
+
+ if (!advertisement) {
+ LOG(ERROR) << "Failed to decode advertisement";
+diff --git a/chrome/services/sharing/nearby_decoder/nearby_decoder_unittest.cc b/chrome/services/sharing/nearby_decoder/nearby_decoder_unittest.cc
+index fa9868b16055..bfdab13c9a83 100644
+--- a/chrome/services/sharing/nearby_decoder/nearby_decoder_unittest.cc
++++ b/chrome/services/sharing/nearby_decoder/nearby_decoder_unittest.cc
+@@ -13,9 +13,9 @@
+ #include "base/strings/string_number_conversions.h"
+ #include "base/test/bind_test_util.h"
+ #include "base/test/task_environment.h"
+-#include "chrome/services/sharing/nearby_decoder/advertisement.h"
+-#include "chrome/services/sharing/nearby_decoder/proto/wire_format.pb.h"
++#include "chrome/services/sharing/public/cpp/advertisement.h"
+ #include "chrome/services/sharing/public/mojom/nearby_decoder_types.mojom.h"
++#include "chrome/services/sharing/public/proto/wire_format.pb.h"
+ #include "mojo/public/cpp/bindings/remote.h"
+ #include "testing/gtest/include/gtest/gtest.h"
+
+diff --git a/chrome/services/sharing/public/cpp/BUILD.gn b/chrome/services/sharing/public/cpp/BUILD.gn
+index ee1f7813882c..85ad274ac4a6 100644
+--- a/chrome/services/sharing/public/cpp/BUILD.gn
++++ b/chrome/services/sharing/public/cpp/BUILD.gn
+@@ -4,9 +4,26 @@
+
+ source_set("cpp") {
+ sources = [
++ "advertisement.cc",
++ "advertisement.h",
+ "sharing_webrtc_metrics.cc",
+ "sharing_webrtc_metrics.h",
+ ]
+
+- public_deps = [ "//base" ]
++ public_deps = [
++ "//base",
++ "//mojo/public/cpp/bindings",
++ ]
++}
++
++source_set("unit_tests") {
++ testonly = true
++
++ sources = [ "advertisement_unittest.cc" ]
++
++ deps = [
++ "//base/test:test_support",
++ "//testing/gmock",
++ "//testing/gtest",
++ ]
+ }
+diff --git a/chrome/services/sharing/nearby_decoder/advertisement.cc b/chrome/services/sharing/public/cpp/advertisement.cc
+similarity index 59%
+rename from chrome/services/sharing/nearby_decoder/advertisement.cc
+rename to chrome/services/sharing/public/cpp/advertisement.cc
+index 319ff8533a6f..12f0b8ad5c71 100644
+--- a/chrome/services/sharing/nearby_decoder/advertisement.cc
++++ b/chrome/services/sharing/public/cpp/advertisement.cc
+@@ -4,7 +4,7 @@
+
+ #include <utility>
+
+-#include "chrome/services/sharing/nearby_decoder/advertisement.h"
++#include "chrome/services/sharing/public/cpp/advertisement.h"
+
+ #include "base/logging.h"
+ #include "base/memory/ptr_util.h"
+@@ -15,26 +15,15 @@ namespace {
+ // The bit mask for parsing and writing Version.
+ constexpr uint8_t kVersionBitmask = 0b111;
+
+-// The bit mask for parsing and writing Visibility.
+-constexpr uint8_t kVisibilityBitmask = 0b1;
+-
+ const uint8_t kMinimumSize =
+ /* Version(3 bits)|Visibility(1 bit)|Reserved(4 bits)= */ 1 +
+ sharing::Advertisement::kSaltSize +
+ sharing::Advertisement::kMetadataEncryptionKeyHashByteSize;
+
+-int ParseVersion(uint8_t b) {
+- return (b >> 5) & kVersionBitmask;
+-}
+-
+ uint8_t ConvertVersion(int version) {
+ return static_cast<uint8_t>((version & kVersionBitmask) << 5);
+ }
+
+-bool ParseHasDeviceName(uint8_t b) {
+- return ((b >> 4) & kVisibilityBitmask) == 0;
+-}
+-
+ uint8_t ConvertHasDeviceName(bool hasDeviceName) {
+ return static_cast<uint8_t>((hasDeviceName ? 0 : 1) << 4);
+ }
+@@ -43,10 +32,6 @@ uint8_t ConvertHasDeviceName(bool hasDeviceName) {
+
+ namespace sharing {
+
+-// static
+-constexpr uint8_t Advertisement::kSaltSize = 2;
+-constexpr uint8_t Advertisement::kMetadataEncryptionKeyHashByteSize = 14;
+-
+ // static
+ std::unique_ptr<Advertisement> Advertisement::NewInstance(
+ std::vector<uint8_t> salt,
+@@ -81,63 +66,6 @@ std::unique_ptr<Advertisement> Advertisement::NewInstance(
+ std::move(device_name)));
+ }
+
+-// static
+-std::unique_ptr<Advertisement> Advertisement::FromEndpointInfo(
+- base::span<const uint8_t> endpoint_info) {
+- if (endpoint_info.size() < kMinimumSize) {
+- LOG(ERROR) << "Failed to parse advertisement because it was too short.";
+- return nullptr;
+- }
+-
+- auto iter = endpoint_info.begin();
+- uint8_t first_byte = *iter++;
+-
+- int version = ParseVersion(first_byte);
+- if (version != 0) {
+- LOG(ERROR) << "Failed to parse advertisement because we failed to parse "
+- "the version number";
+- return nullptr;
+- }
+-
+- bool has_device_name = ParseHasDeviceName(first_byte);
+-
+- std::vector<uint8_t> salt(iter, iter + kSaltSize);
+- iter += kSaltSize;
+-
+- std::vector<uint8_t> encrypted_metadata_key(
+- iter, iter + kMetadataEncryptionKeyHashByteSize);
+- iter += kMetadataEncryptionKeyHashByteSize;
+-
+- int device_name_length = 0;
+- if (iter != endpoint_info.end())
+- device_name_length = *iter++ & 0xff;
+-
+- if (endpoint_info.end() - iter < device_name_length ||
+- (device_name_length == 0 && has_device_name)) {
+- LOG(ERROR) << "Failed to parse advertisement because the device name did "
+- "not match the expected length "
+- << device_name_length;
+- return nullptr;
+- }
+-
+- base::Optional<std::string> optional_device_name;
+- if (device_name_length > 0) {
+- optional_device_name = std::string(iter, iter + device_name_length);
+- iter += device_name_length;
+-
+- if (!base::IsStringUTF8(*optional_device_name)) {
+- LOG(ERROR) << "Failed to parse advertisement because the device name was "
+- "corrupted";
+- return nullptr;
+- }
+- }
+-
+- // Using `new` to access a non-public constructor.
+- return base::WrapUnique(new Advertisement(version, std::move(salt),
+- std::move(encrypted_metadata_key),
+- std::move(optional_device_name)));
+-}
+-
+ Advertisement::~Advertisement() = default;
+ Advertisement::Advertisement(Advertisement&& other) = default;
+
+diff --git a/chrome/services/sharing/nearby_decoder/advertisement.h b/chrome/services/sharing/public/cpp/advertisement.h
+similarity index 83%
+rename from chrome/services/sharing/nearby_decoder/advertisement.h
+rename to chrome/services/sharing/public/cpp/advertisement.h
+index a5b5742854e5..661d0a0fde66 100644
+--- a/chrome/services/sharing/nearby_decoder/advertisement.h
++++ b/chrome/services/sharing/public/cpp/advertisement.h
+@@ -2,8 +2,8 @@
+ // Use of this source code is governed by a BSD-style license that can be
+ // found in the LICENSE file.
+
+-#ifndef CHROME_SERVICES_SHARING_NEARBY_DECODER_ADVERTISEMENT_H_
+-#define CHROME_SERVICES_SHARING_NEARBY_DECODER_ADVERTISEMENT_H_
++#ifndef CHROME_SERVICES_SHARING_PUBLIC_CPP_ADVERTISEMENT_H_
++#define CHROME_SERVICES_SHARING_PUBLIC_CPP_ADVERTISEMENT_H_
+
+ #include <stdint.h>
+ #include <memory>
+@@ -26,9 +26,6 @@ class Advertisement {
+ std::vector<uint8_t> encrypted_metadata_key,
+ base::Optional<std::string> device_name);
+
+- static std::unique_ptr<Advertisement> FromEndpointInfo(
+- base::span<const uint8_t> endpoint_info);
+-
+ Advertisement(Advertisement&& other);
+ Advertisement(const Advertisement& other) = delete;
+ Advertisement& operator=(const Advertisement& rhs) = delete;
+@@ -46,8 +43,8 @@ class Advertisement {
+ }
+ bool HasDeviceName() const { return device_name_.has_value(); }
+
+- static const uint8_t kSaltSize;
+- static const uint8_t kMetadataEncryptionKeyHashByteSize;
++ static const uint8_t kSaltSize = 2;
++ static const uint8_t kMetadataEncryptionKeyHashByteSize = 14;
+
+ private:
+ Advertisement(int version,
+@@ -72,4 +69,4 @@ class Advertisement {
+
+ } // namespace sharing
+
+-#endif // CHROME_SERVICES_SHARING_NEARBY_DECODER_ADVERTISEMENT_H_
++#endif // CHROME_SERVICES_SHARING_PUBLIC_CPP_ADVERTISEMENT_H_
+diff --git a/chrome/services/sharing/public/cpp/advertisement_unittest.cc b/chrome/services/sharing/public/cpp/advertisement_unittest.cc
+new file mode 100644
+index 000000000000..92230b384fba
+--- /dev/null
++++ b/chrome/services/sharing/public/cpp/advertisement_unittest.cc
+@@ -0,0 +1,63 @@
++// Copyright 2020 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 <stdint.h>
++#include <memory>
++#include <string>
++#include <vector>
++
++#include "chrome/services/sharing/public/cpp/advertisement.h"
++
++#include "base/strings/strcat.h"
++#include "base/test/task_environment.h"
++#include "mojo/public/cpp/bindings/remote.h"
++#include "testing/gtest/include/gtest/gtest.h"
++
++namespace sharing {
++
++namespace {
++
++const char kDeviceName[] = "deviceName";
++// Salt for advertisement.
++const std::vector<uint8_t> kSalt(Advertisement::kSaltSize, 0);
++// Key for encrypting personal info metadata.
++static const std::vector<uint8_t> kEncryptedMetadataKey(
++ Advertisement::kMetadataEncryptionKeyHashByteSize,
++ 0);
++
++} // namespace
++
++TEST(AdvertisementTest, CreateNewInstanceWithNullName) {
++ std::unique_ptr<sharing::Advertisement> advertisement =
++ sharing::Advertisement::NewInstance(kSalt, kEncryptedMetadataKey,
++ /* device_name=*/base::nullopt);
++ EXPECT_FALSE(advertisement->device_name());
++ EXPECT_EQ(advertisement->encrypted_metadata_key(), kEncryptedMetadataKey);
++ EXPECT_FALSE(advertisement->HasDeviceName());
++ EXPECT_EQ(advertisement->salt(), kSalt);
++}
++
++TEST(AdvertisementTest, CreateNewInstance) {
++ std::unique_ptr<sharing::Advertisement> advertisement =
++ sharing::Advertisement::NewInstance(kSalt, kEncryptedMetadataKey,
++ kDeviceName);
++ EXPECT_EQ(advertisement->device_name(), kDeviceName);
++ EXPECT_EQ(advertisement->encrypted_metadata_key(), kEncryptedMetadataKey);
++ EXPECT_TRUE(advertisement->HasDeviceName());
++ EXPECT_EQ(advertisement->salt(), kSalt);
++}
++
++TEST(AdvertisementTest, CreateNewInstanceWithWrongSaltSize) {
++ EXPECT_FALSE(sharing::Advertisement::NewInstance(
++ /* salt= */ std::vector<uint8_t>(5, 5), kEncryptedMetadataKey,
++ kDeviceName));
++}
++
++TEST(AdvertisementTest, CreateNewInstanceWithWrongAccountIdentifierSize) {
++ EXPECT_FALSE(sharing::Advertisement::NewInstance(
++ kSalt, /* encrypted_metadata_key= */ std::vector<uint8_t>(2, 1),
++ kDeviceName));
++}
++
++} // namespace sharing
+diff --git a/chrome/services/sharing/nearby_decoder/proto/BUILD.gn b/chrome/services/sharing/public/proto/BUILD.gn
+similarity index 100%
+rename from chrome/services/sharing/nearby_decoder/proto/BUILD.gn
+rename to chrome/services/sharing/public/proto/BUILD.gn
+diff --git a/chrome/services/sharing/nearby_decoder/proto/wire_format.proto b/chrome/services/sharing/public/proto/wire_format.proto
+similarity index 100%
+rename from chrome/services/sharing/nearby_decoder/proto/wire_format.proto
+rename to chrome/services/sharing/public/proto/wire_format.proto
+diff --git a/chrome/test/BUILD.gn b/chrome/test/BUILD.gn
+index 6b357abea22a..e970d5d90f0a 100644
+--- a/chrome/test/BUILD.gn
++++ b/chrome/test/BUILD.gn
+@@ -4336,6 +4336,7 @@ test("unit_tests") {
+ "//chrome/browser/resource_coordinator/tab_ranker:tab_features_test_helper",
+ "//chrome/services/sharing:unit_tests",
+ "//chrome/services/sharing/nearby_decoder:unit_tests",
++ "//chrome/services/sharing/public/cpp:unit_tests",
+ "//chrome/services/speech:unit_tests",
+ "//components/chrome_cleaner/test:test_name_helper",
+ "//components/feature_engagement/test:test_support",
+--
+2.26.2
+
diff --git a/chromium/chromium/chromium-gcc10-r783782.patch b/chromium/chromium/chromium-gcc10-r783782.patch
new file mode 100644
index 0000000..0ea3740
--- /dev/null
+++ b/chromium/chromium/chromium-gcc10-r783782.patch
@@ -0,0 +1,42 @@
+From 2e8386a047240fc3ebb53d88dee9558193adbdd2 Mon Sep 17 00:00:00 2001
+From: Stephan Hartmann <stha09@googlemail.com>
+Date: Tue, 30 Jun 2020 01:48:49 +0000
+Subject: [PATCH] GCC: add explicit namespace for FrameWidget
+
+GCC is confused by multiple definitions in different namespaces
+and fails like this:
+
+../../third_party/blink/renderer/platform/widget/widget_base_client.h:153:24:
+
+error: declaration of 'virtual blink::FrameWidget*
+blink::WidgetBaseClient::FrameWidget()' changes meaning of 'FrameWidget'
+[-fpermissive]
+ 153 | virtual FrameWidget* FrameWidget() { return nullptr; }
+ | ^~~~~~~~~~~
+
+Bug: 819294
+Change-Id: If2f6ab4e75f5d4c87657620de84a50b85b2af960
+Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2273229
+Reviewed-by: Kentaro Hara <haraken@chromium.org>
+Commit-Queue: Kentaro Hara <haraken@chromium.org>
+Cr-Commit-Position: refs/heads/master@{#783782}
+---
+ third_party/blink/renderer/platform/widget/widget_base_client.h | 2 +-
+ 1 file changed, 1 insertion(+), 1 deletion(-)
+
+diff --git a/third_party/blink/renderer/platform/widget/widget_base_client.h b/third_party/blink/renderer/platform/widget/widget_base_client.h
+index 03d353c2b456..530360bcf8a1 100644
+--- a/third_party/blink/renderer/platform/widget/widget_base_client.h
++++ b/third_party/blink/renderer/platform/widget/widget_base_client.h
+@@ -150,7 +150,7 @@ class WidgetBaseClient {
+ mojo::PendingRemote<mojom::blink::WidgetInputHandlerHost> host) = 0;
+
+ // The FrameWidget interface if this is a FrameWidget.
+- virtual FrameWidget* FrameWidget() { return nullptr; }
++ virtual blink::FrameWidget* FrameWidget() { return nullptr; }
+
+ // Send the composition change to the browser.
+ virtual void SendCompositionRangeChanged(
+--
+2.26.2
+
diff --git a/chromium/chromium/chromium-gcc10-r783978.patch b/chromium/chromium/chromium-gcc10-r783978.patch
new file mode 100644
index 0000000..be78e01
--- /dev/null
+++ b/chromium/chromium/chromium-gcc10-r783978.patch
@@ -0,0 +1,32 @@
+From af06ca9d46d46302c100f07e499d8aaa9ab32364 Mon Sep 17 00:00:00 2001
+From: Stephan Hartmann <stha09@googlemail.com>
+Date: Tue, 30 Jun 2020 15:58:38 +0000
+Subject: [PATCH] IWYU: add includes for uint64_t and std::string
+
+Bug: 819294
+Change-Id: Iae844f8b6cf6bba879cb320c95ebf88f65e1385f
+Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2273161
+Reviewed-by: Yao Xiao <yaoxia@chromium.org>
+Commit-Queue: Yao Xiao <yaoxia@chromium.org>
+Cr-Commit-Position: refs/heads/master@{#783978}
+---
+ components/federated_learning/sim_hash.h | 2 ++
+ 1 file changed, 2 insertions(+)
+
+diff --git a/components/federated_learning/sim_hash.h b/components/federated_learning/sim_hash.h
+index 55030d9d2e3f..26087e74e9c7 100644
+--- a/components/federated_learning/sim_hash.h
++++ b/components/federated_learning/sim_hash.h
+@@ -5,7 +5,9 @@
+ #ifndef COMPONENTS_FEDERATED_LEARNING_SIM_HASH_H_
+ #define COMPONENTS_FEDERATED_LEARNING_SIM_HASH_H_
+
++#include <stdint.h>
+ #include <set>
++#include <string>
+ #include <unordered_set>
+
+ namespace federated_learning {
+--
+2.26.2
+
diff --git a/chromium/chromium/chromium-gcc10-r784897.patch b/chromium/chromium/chromium-gcc10-r784897.patch
new file mode 100644
index 0000000..2575825
--- /dev/null
+++ b/chromium/chromium/chromium-gcc10-r784897.patch
@@ -0,0 +1,59 @@
+From 63ca21fddaf4f3b12baf320857407b884db2b570 Mon Sep 17 00:00:00 2001
+From: Stephan Hartmann <stha09@googlemail.com>
+Date: Thu, 2 Jul 2020 19:20:33 +0000
+Subject: [PATCH] GCC: fix operator<< for
+ performance_manager::PageNode::OpenedType
+
+Move operator<< into namespace performance_manager.
+
+Bug: 819294
+Change-Id: I4e0e97f10dca0b2e56308e07a67cb00e2c2e8052
+Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2273191
+Reviewed-by: Chris Hamilton <chrisha@chromium.org>
+Commit-Queue: Chris Hamilton <chrisha@chromium.org>
+Cr-Commit-Position: refs/heads/master@{#784897}
+---
+ components/performance_manager/graph/page_node.cc | 6 +++---
+ components/performance_manager/public/graph/page_node.h | 4 ++--
+ 2 files changed, 5 insertions(+), 5 deletions(-)
+
+diff --git a/components/performance_manager/graph/page_node.cc b/components/performance_manager/graph/page_node.cc
+index 113fcf4c6847..b1a4007938e0 100644
+--- a/components/performance_manager/graph/page_node.cc
++++ b/components/performance_manager/graph/page_node.cc
+@@ -32,11 +32,11 @@ PageNodeObserver::~PageNodeObserver() = default;
+ PageNode::ObserverDefaultImpl::ObserverDefaultImpl() = default;
+ PageNode::ObserverDefaultImpl::~ObserverDefaultImpl() = default;
+
+-} // namespace performance_manager
+-
+ std::ostream& operator<<(
+ std::ostream& os,
+ performance_manager::PageNode::OpenedType opened_type) {
+ os << performance_manager::PageNode::ToString(opened_type);
+ return os;
+-}
+\ No newline at end of file
++}
++
++} // namespace performance_manager
+diff --git a/components/performance_manager/public/graph/page_node.h b/components/performance_manager/public/graph/page_node.h
+index 422c043ff722..79fec031397f 100644
+--- a/components/performance_manager/public/graph/page_node.h
++++ b/components/performance_manager/public/graph/page_node.h
+@@ -265,10 +265,10 @@ class PageNode::ObserverDefaultImpl : public PageNodeObserver {
+ DISALLOW_COPY_AND_ASSIGN(ObserverDefaultImpl);
+ };
+
+-} // namespace performance_manager
+-
+ // std::ostream support for PageNode::OpenedType.
+ std::ostream& operator<<(std::ostream& os,
+ performance_manager::PageNode::OpenedType opened_type);
+
++} // namespace performance_manager
++
+ #endif // COMPONENTS_PERFORMANCE_MANAGER_PUBLIC_GRAPH_PAGE_NODE_H_
+--
+2.26.2
+
diff --git a/chromium/chromium/chromium-gcc10-r785035.patch b/chromium/chromium/chromium-gcc10-r785035.patch
new file mode 100644
index 0000000..7e61b2e
--- /dev/null
+++ b/chromium/chromium/chromium-gcc10-r785035.patch
@@ -0,0 +1,1538 @@
+From 36f66526e925e81ba290c4625908bc2820bfcbeb Mon Sep 17 00:00:00 2001
+From: Naomi Musgrave <nmusgrave@chromium.org>
+Date: Fri, 3 Jul 2020 14:36:47 +0000
+Subject: [PATCH] Implements receiver registration in NearbySharingService.
+
+On registering a foreground or background receiver,
+NearbySharingService starts advertising if the
+appropriate conditions are met. On unregistering
+one of the receivers, NearbySharingService updates
+TransferUpdateCallback for background receivers and
+re-sets the advertising state.
+
+Bug: 1084647
+Change-Id: I62b15b76db9a1286a95119b22e45a02fdde82dd5
+Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2241547
+Commit-Queue: Naomi Musgrave <nmusgrave@chromium.org>
+Reviewed-by: Alex Chau <alexchau@chromium.org>
+Cr-Commit-Position: refs/heads/master@{#785035}
+---
+ chrome/browser/BUILD.gn | 1 +
+ .../fake_nearby_connections_manager.cc | 14 +-
+ .../fake_nearby_connections_manager.h | 15 +-
+ .../browser/nearby_sharing/file_attachment.cc | 4 +
+ .../browser/nearby_sharing/file_attachment.h | 2 +
+ .../nearby_connections_manager.h | 9 +-
+ .../browser/nearby_sharing/nearby_constants.h | 26 +-
+ .../nearby_sharing/nearby_sharing_prefs.cc | 11 +
+ .../nearby_sharing/nearby_sharing_prefs.h | 4 +
+ .../nearby_sharing/nearby_sharing_service.h | 28 +-
+ .../nearby_sharing_service_impl.cc | 409 +++++++++++++++++-
+ .../nearby_sharing_service_impl.h | 76 +++-
+ .../nearby_sharing_service_impl_unittest.cc | 399 ++++++++++++++++-
+ chrome/browser/nearby_sharing/share_target.cc | 4 +
+ chrome/browser/nearby_sharing/share_target.h | 2 +
+ .../browser/nearby_sharing/text_attachment.cc | 6 +
+ .../browser/nearby_sharing/text_attachment.h | 2 +
+ .../nearby_sharing/transfer_metadata.cc | 7 +
+ .../nearby_sharing/transfer_metadata.h | 2 +
+ .../nearby_sharing/transfer_update_callback.h | 4 +-
+ chrome/test/BUILD.gn | 1 +
+ 21 files changed, 970 insertions(+), 56 deletions(-)
+
+diff --git a/chrome/browser/BUILD.gn b/chrome/browser/BUILD.gn
+index fd71f270a6d7..497db2478e71 100644
+--- a/chrome/browser/BUILD.gn
++++ b/chrome/browser/BUILD.gn
+@@ -3740,6 +3740,7 @@ static_library("browser") {
+ "//chrome/common/themes:autogenerated_theme_util",
+ "//chrome/services/sharing/public/cpp",
+ "//chrome/services/sharing/public/mojom",
++ "//chrome/services/sharing/public/proto",
+ "//chrome/services/speech:buildflags",
+ "//components/feedback",
+ "//components/image_fetcher/core",
+diff --git a/chrome/browser/nearby_sharing/fake_nearby_connections_manager.cc b/chrome/browser/nearby_sharing/fake_nearby_connections_manager.cc
+index 48568fdff4a2..a6a9a834f9ba 100644
+--- a/chrome/browser/nearby_sharing/fake_nearby_connections_manager.cc
++++ b/chrome/browser/nearby_sharing/fake_nearby_connections_manager.cc
+@@ -54,14 +54,16 @@ void FakeNearbyConnectionsManager::StartAdvertising(
+ ConnectionsCallback callback) {
+ is_shutdown_ = false;
+ advertising_listener_ = listener;
+- // TODO(alexchau): Implement.
++ advertising_data_usage_ = data_usage;
++ advertising_power_level_ = power_level;
+ }
+
+ void FakeNearbyConnectionsManager::StopAdvertising() {
+ DCHECK(IsAdvertising());
+ DCHECK(!IsShutdown());
+ advertising_listener_ = nullptr;
+- // TODO(alexchau): Implement.
++ advertising_data_usage_ = DataUsage::kUnknown;
++ advertising_power_level_ = PowerLevel::kUnknown;
+ }
+
+ void FakeNearbyConnectionsManager::StartDiscovery(
+@@ -148,3 +150,11 @@ bool FakeNearbyConnectionsManager::IsDiscovering() {
+ bool FakeNearbyConnectionsManager::IsShutdown() {
+ return is_shutdown_;
+ }
++
++DataUsage FakeNearbyConnectionsManager::GetAdvertisingDataUsage() {
++ return advertising_data_usage_;
++}
++
++PowerLevel FakeNearbyConnectionsManager::GetAdvertisingPowerLevel() {
++ return advertising_power_level_;
++}
+diff --git a/chrome/browser/nearby_sharing/fake_nearby_connections_manager.h b/chrome/browser/nearby_sharing/fake_nearby_connections_manager.h
+index 7399605927b5..c7f08982edf9 100644
+--- a/chrome/browser/nearby_sharing/fake_nearby_connections_manager.h
++++ b/chrome/browser/nearby_sharing/fake_nearby_connections_manager.h
+@@ -5,6 +5,11 @@
+ #ifndef CHROME_BROWSER_NEARBY_SHARING_FAKE_NEARBY_CONNECTIONS_MANAGER_H_
+ #define CHROME_BROWSER_NEARBY_SHARING_FAKE_NEARBY_CONNECTIONS_MANAGER_H_
+
++#include <memory>
++#include <string>
++#include <utility>
++#include <vector>
++
+ #include "chrome/browser/nearby_sharing/nearby_connections_manager.h"
+
+ // Fake NearbyConnectionsManager for testing.
+@@ -65,11 +70,15 @@ class FakeNearbyConnectionsManager : public NearbyConnectionsManager {
+ bool IsAdvertising();
+ bool IsDiscovering();
+ bool IsShutdown();
++ DataUsage GetAdvertisingDataUsage();
++ PowerLevel GetAdvertisingPowerLevel();
+
+ private:
+- IncomingConnectionListener* advertising_listener_{nullptr};
+- DiscoveryListener* discovery_listener_{nullptr};
+- bool is_shutdown_{false};
++ IncomingConnectionListener* advertising_listener_ = nullptr;
++ DiscoveryListener* discovery_listener_ = nullptr;
++ bool is_shutdown_ = false;
++ DataUsage advertising_data_usage_ = DataUsage::kUnknown;
++ PowerLevel advertising_power_level_ = PowerLevel::kUnknown;
+ };
+
+ #endif // CHROME_BROWSER_NEARBY_SHARING_FAKE_NEARBY_CONNECTIONS_MANAGER_H_
+diff --git a/chrome/browser/nearby_sharing/file_attachment.cc b/chrome/browser/nearby_sharing/file_attachment.cc
+index 1c41f84fa905..11191458fa76 100644
+--- a/chrome/browser/nearby_sharing/file_attachment.cc
++++ b/chrome/browser/nearby_sharing/file_attachment.cc
+@@ -2,6 +2,8 @@
+ // Use of this source code is governed by a BSD-style license that can be
+ // found in the LICENSE file.
+
++#include <utility>
++
+ #include "chrome/browser/nearby_sharing/file_attachment.h"
+
+ FileAttachment::FileAttachment(std::string file_name,
+@@ -16,6 +18,8 @@ FileAttachment::FileAttachment(std::string file_name,
+ mime_type_(std::move(mime_type)) {}
+
+ FileAttachment::~FileAttachment() = default;
++FileAttachment::FileAttachment(const FileAttachment&) = default;
++FileAttachment& FileAttachment::operator=(const FileAttachment&) = default;
+
+ int64_t FileAttachment::size() const {
+ return size_;
+diff --git a/chrome/browser/nearby_sharing/file_attachment.h b/chrome/browser/nearby_sharing/file_attachment.h
+index 3d089771c048..65ed319ebd18 100644
+--- a/chrome/browser/nearby_sharing/file_attachment.h
++++ b/chrome/browser/nearby_sharing/file_attachment.h
+@@ -34,6 +34,8 @@ class FileAttachment : public Attachment {
+ base::Optional<base::FilePath> file_path,
+ std::string mime_type);
+ ~FileAttachment() override;
++ FileAttachment(const FileAttachment&);
++ FileAttachment& operator=(const FileAttachment&);
+
+ // Attachment:
+ int64_t size() const override;
+diff --git a/chrome/browser/nearby_sharing/nearby_connections_manager.h b/chrome/browser/nearby_sharing/nearby_connections_manager.h
+index d6ac91e86815..eb1fda7bf6d5 100644
+--- a/chrome/browser/nearby_sharing/nearby_connections_manager.h
++++ b/chrome/browser/nearby_sharing/nearby_connections_manager.h
+@@ -7,6 +7,7 @@
+
+ #include <stdint.h>
+ #include <memory>
++#include <string>
+ #include <vector>
+
+ #include "base/callback.h"
+@@ -25,11 +26,13 @@ class NearbyConnectionsManager {
+
+ // A callback for handling incoming connections while advertising.
+ class IncomingConnectionListener {
++ public:
+ virtual ~IncomingConnectionListener() = default;
+
+- virtual void OnIncomingConnection(const std::string& endpoint_id,
+- const std::vector<uint8_t>& endpoint_info,
+- NearbyConnection connection) = 0;
++ virtual void OnIncomingConnection(
++ const std::string& endpoint_id,
++ const std::vector<uint8_t>& endpoint_info,
++ std::unique_ptr<NearbyConnection> connection) = 0;
+ };
+
+ // A callback for handling discovered devices while discovering.
+diff --git a/chrome/browser/nearby_sharing/nearby_constants.h b/chrome/browser/nearby_sharing/nearby_constants.h
+index 225bbceee4f3..3bf9f1583a47 100644
+--- a/chrome/browser/nearby_sharing/nearby_constants.h
++++ b/chrome/browser/nearby_sharing/nearby_constants.h
+@@ -7,21 +7,35 @@
+
+ // Represents the advertising bluetooth power for Nearby Connections.
+ enum class PowerLevel {
+- kLowPower,
+- kMediumPower,
+- kHighPower,
++ kUnknown = 0,
++ kLowPower = 1,
++ kMediumPower = 2,
++ kHighPower = 3,
+ kMaxValue = kHighPower
+ };
+
+ // Represents the data usage preference.
+ enum class DataUsage {
++ kUnknown = 0,
+ // User is never willing to use the Internet
+- kOffline,
++ kOffline = 1,
+ // User is always willing to use the Internet
+- kOnline,
++ kOnline = 2,
+ // User is willing to use the Internet on an unmetered connection.
+- kWifiOnly,
++ kWifiOnly = 3,
+ kMaxValue = kWifiOnly
+ };
+
++// Represents the visibility of the advertisement.
++enum class Visibility {
++ kUnknown = 0,
++ // The user is not advertising to anyone.
++ kNoOne = 1,
++ // The user is visible to all contacts.
++ kAllContacts = 2,
++ // The user is only visible to selected contacts.
++ kSelectedContacts = 3,
++ kMaxValue = kSelectedContacts,
++};
++
+ #endif // CHROME_BROWSER_NEARBY_SHARING_NEARBY_CONSTANTS_H_
+diff --git a/chrome/browser/nearby_sharing/nearby_sharing_prefs.cc b/chrome/browser/nearby_sharing/nearby_sharing_prefs.cc
+index 43bc3c371fd3..8c9b3c5d51a8 100644
+--- a/chrome/browser/nearby_sharing/nearby_sharing_prefs.cc
++++ b/chrome/browser/nearby_sharing/nearby_sharing_prefs.cc
+@@ -14,6 +14,9 @@
+ const char prefs::kNearbySharingEnabledPrefName[] = "nearby_sharing.enabled";
+ const char prefs::kNearbySharingActiveProfilePrefName[] =
+ "nearby_sharing.active_profile";
++const char prefs::kNearbySharingBackgroundVisibilityName[] =
++ "nearby_sharing.background_visibility";
++const char prefs::kNearbySharingDataUsageName[] = "nearby_sharing.data_usage";
+
+ void RegisterNearbySharingPrefs(user_prefs::PrefRegistrySyncable* registry) {
+ // This pref is not synced.
+@@ -22,6 +25,14 @@ void RegisterNearbySharingPrefs(user_prefs::PrefRegistrySyncable* registry) {
+ registry->RegisterBooleanPref(
+ prefs::kNearbySharingEnabledPrefName, true /* default_value */,
+ PrefRegistry::PrefRegistrationFlags::NO_REGISTRATION_FLAGS /* flags */);
++ registry->RegisterIntegerPref(
++ prefs::kNearbySharingBackgroundVisibilityName,
++ static_cast<int>(Visibility::kNoOne) /* default_value */,
++ PrefRegistry::PrefRegistrationFlags::NO_REGISTRATION_FLAGS /* flags */);
++ registry->RegisterIntegerPref(
++ prefs::kNearbySharingDataUsageName,
++ static_cast<int>(DataUsage::kWifiOnly) /* default_value */,
++ PrefRegistry::PrefRegistrationFlags::NO_REGISTRATION_FLAGS /* flags */);
+ }
+
+ void RegisterNearbySharingLocalPrefs(PrefRegistrySimple* local_state) {
+diff --git a/chrome/browser/nearby_sharing/nearby_sharing_prefs.h b/chrome/browser/nearby_sharing/nearby_sharing_prefs.h
+index f61b86de7e41..700e2c3740ec 100644
+--- a/chrome/browser/nearby_sharing/nearby_sharing_prefs.h
++++ b/chrome/browser/nearby_sharing/nearby_sharing_prefs.h
+@@ -5,6 +5,8 @@
+ #ifndef CHROME_BROWSER_NEARBY_SHARING_NEARBY_SHARING_PREFS_H_
+ #define CHROME_BROWSER_NEARBY_SHARING_NEARBY_SHARING_PREFS_H_
+
++#include "chrome/browser/nearby_sharing/nearby_constants.h"
++
+ namespace user_prefs {
+ class PrefRegistrySyncable;
+ } // namespace user_prefs
+@@ -14,6 +16,8 @@ class PrefRegistrySimple;
+ namespace prefs {
+ extern const char kNearbySharingEnabledPrefName[];
+ extern const char kNearbySharingActiveProfilePrefName[];
++extern const char kNearbySharingBackgroundVisibilityName[];
++extern const char kNearbySharingDataUsageName[];
+ } // namespace prefs
+
+ void RegisterNearbySharingPrefs(user_prefs::PrefRegistrySyncable* registry);
+diff --git a/chrome/browser/nearby_sharing/nearby_sharing_service.h b/chrome/browser/nearby_sharing/nearby_sharing_service.h
+index d92e3a699ea3..894f925c1eaa 100644
+--- a/chrome/browser/nearby_sharing/nearby_sharing_service.h
++++ b/chrome/browser/nearby_sharing/nearby_sharing_service.h
+@@ -25,6 +25,15 @@ class NearbySharingService {
+ kError,
+ };
+
++ enum class ReceiveSurfaceState {
++ // Default, invalid state.
++ kUnknown,
++ // Background receive surface advertises only to contacts.
++ kBackground,
++ // Foreground receive surface advertises to everyone.
++ kForeground,
++ };
++
+ using StatusCodesCallback =
+ base::OnceCallback<void(StatusCodes status_codes)>;
+
+@@ -33,25 +42,24 @@ class NearbySharingService {
+ // Registers a send surface for handling payload transfer status and device
+ // discovery.
+ virtual void RegisterSendSurface(
+- TransferUpdateCallback* transferCallback,
+- ShareTargetDiscoveredCallback* discoveryCallback,
++ TransferUpdateCallback* transfer_callback,
++ ShareTargetDiscoveredCallback* discovery_callback,
+ StatusCodesCallback status_codes_callback) = 0;
+
+ // Unregisters the current send surface.
+ virtual void UnregisterSendSurface(
+- TransferUpdateCallback* transferCallback,
+- ShareTargetDiscoveredCallback* discoveryCallback,
++ TransferUpdateCallback* transfer_callback,
++ ShareTargetDiscoveredCallback* discovery_callback,
+ StatusCodesCallback status_codes_callback) = 0;
+
+ // Registers a receiver surface for handling payload transfer status.
+- virtual void RegisterReceiveSurface(
+- TransferUpdateCallback* transferCallback,
+- StatusCodesCallback status_codes_callback) = 0;
++ virtual StatusCodes RegisterReceiveSurface(
++ TransferUpdateCallback* transfer_callback,
++ ReceiveSurfaceState state) = 0;
+
+ // Unregistesrs the current receive surface.
+- virtual void UnregisterReceiveSurface(
+- TransferUpdateCallback* transferCallback,
+- StatusCodesCallback status_codes_callback) = 0;
++ virtual StatusCodes UnregisterReceiveSurface(
++ TransferUpdateCallback* transfer_callback) = 0;
+
+ // Sends text to the remote |share_target|.
+ virtual void SendText(const ShareTarget& share_target,
+diff --git a/chrome/browser/nearby_sharing/nearby_sharing_service_impl.cc b/chrome/browser/nearby_sharing/nearby_sharing_service_impl.cc
+index 2bb7dee36521..0cfc44765e2c 100644
+--- a/chrome/browser/nearby_sharing/nearby_sharing_service_impl.cc
++++ b/chrome/browser/nearby_sharing/nearby_sharing_service_impl.cc
+@@ -12,8 +12,100 @@
+ #include "chrome/browser/nearby_sharing/fast_initiation_manager.h"
+ #include "chrome/browser/nearby_sharing/nearby_connections_manager.h"
+ #include "chrome/browser/nearby_sharing/nearby_sharing_prefs.h"
++#include "chrome/services/sharing/public/cpp/advertisement.h"
++#include "chrome/services/sharing/public/mojom/nearby_connections_types.mojom.h"
+ #include "components/prefs/pref_service.h"
+ #include "device/bluetooth/bluetooth_adapter_factory.h"
++#include "ui/base/idle/idle.h"
++
++namespace {
++
++std::string ReceiveSurfaceStateToString(
++ NearbySharingService::ReceiveSurfaceState state) {
++ switch (state) {
++ case NearbySharingService::ReceiveSurfaceState::kForeground:
++ return "FOREGROUND";
++ case NearbySharingService::ReceiveSurfaceState::kBackground:
++ return "BACKGROUND";
++ case NearbySharingService::ReceiveSurfaceState::kUnknown:
++ return "UNKNOWN";
++ }
++}
++
++std::string DataUsageToString(DataUsage usage) {
++ switch (usage) {
++ case DataUsage::kOffline:
++ return "OFFLINE";
++ case DataUsage::kOnline:
++ return "ONLINE";
++ case DataUsage::kWifiOnly:
++ return "WIFI_ONLY";
++ case DataUsage::kUnknown:
++ return "UNKNOWN";
++ }
++}
++
++std::string PowerLevelToString(PowerLevel level) {
++ switch (level) {
++ case PowerLevel::kLowPower:
++ return "LOW_POWER";
++ case PowerLevel::kMediumPower:
++ return "MEDIUM_POWER";
++ case PowerLevel::kHighPower:
++ return "HIGH_POWER";
++ case PowerLevel::kUnknown:
++ return "UNKNOWN";
++ }
++}
++
++std::string VisibilityToString(Visibility visibility) {
++ switch (visibility) {
++ case Visibility::kNoOne:
++ return "NO_ONE";
++ case Visibility::kAllContacts:
++ return "ALL_CONTACTS";
++ case Visibility::kSelectedContacts:
++ return "SELECTED_CONTACTS";
++ case Visibility::kUnknown:
++ return "UNKNOWN";
++ }
++}
++
++std::string ConnectionsStatusToString(
++ NearbyConnectionsManager::ConnectionsStatus status) {
++ switch (status) {
++ case NearbyConnectionsManager::ConnectionsStatus::kSuccess:
++ return "SUCCESS";
++ case NearbyConnectionsManager::ConnectionsStatus::kError:
++ return "ERROR";
++ case NearbyConnectionsManager::ConnectionsStatus::kOutOfOrderApiCall:
++ return "OUT_OF_ORDER_API_CALL";
++ case NearbyConnectionsManager::ConnectionsStatus::
++ kAlreadyHaveActiveStrategy:
++ return "ALREADY_HAVE_ACTIVE_STRATEGY";
++ case NearbyConnectionsManager::ConnectionsStatus::kAlreadyAdvertising:
++ return "ALREADY_ADVERTISING";
++ case NearbyConnectionsManager::ConnectionsStatus::kAlreadyDiscovering:
++ return "ALREADY_DISCOVERING";
++ case NearbyConnectionsManager::ConnectionsStatus::kEndpointIOError:
++ return "ENDPOINT_IO_ERROR";
++ case NearbyConnectionsManager::ConnectionsStatus::kEndpointUnknown:
++ return "ENDPOINT_UNKNOWN";
++ case NearbyConnectionsManager::ConnectionsStatus::kConnectionRejected:
++ return "CONNECTION_REJECTED";
++ case NearbyConnectionsManager::ConnectionsStatus::
++ kAlreadyConnectedToEndpoint:
++ return "ALREADY_CONNECTED_TO_ENDPOINT";
++ case NearbyConnectionsManager::ConnectionsStatus::kNotConnectedToEndpoint:
++ return "NOT_CONNECTED_TO_ENDPOINT";
++ case NearbyConnectionsManager::ConnectionsStatus::kRadioError:
++ return "RADIO_ERROR";
++ case NearbyConnectionsManager::ConnectionsStatus::kPayloadUnknown:
++ return "PAYLOAD_UNKNOWN";
++ }
++}
++
++} // namespace
+
+ NearbySharingServiceImpl::NearbySharingServiceImpl(
+ PrefService* prefs,
+@@ -40,6 +132,14 @@ NearbySharingServiceImpl::NearbySharingServiceImpl(
+ prefs::kNearbySharingEnabledPrefName,
+ base::BindRepeating(&NearbySharingServiceImpl::OnEnabledPrefChanged,
+ base::Unretained(this)));
++ pref_change_registrar_.Add(
++ prefs::kNearbySharingBackgroundVisibilityName,
++ base::BindRepeating(&NearbySharingServiceImpl::OnVisibilityPrefChanged,
++ base::Unretained(this)));
++ pref_change_registrar_.Add(
++ prefs::kNearbySharingDataUsageName,
++ base::BindRepeating(&NearbySharingServiceImpl::OnDataUsagePrefChanged,
++ base::Unretained(this)));
+
+ GetBluetoothAdapter();
+ }
+@@ -50,31 +150,100 @@ NearbySharingServiceImpl::~NearbySharingServiceImpl() {
+ }
+
+ void NearbySharingServiceImpl::RegisterSendSurface(
+- TransferUpdateCallback* transferCallback,
+- ShareTargetDiscoveredCallback* discoveryCallback,
++ TransferUpdateCallback* transfer_callback,
++ ShareTargetDiscoveredCallback* discovery_callback,
+ StatusCodesCallback status_codes_callback) {
+ register_send_surface_callback_ = std::move(status_codes_callback);
+ StartFastInitiationAdvertising();
+ }
+
+ void NearbySharingServiceImpl::UnregisterSendSurface(
+- TransferUpdateCallback* transferCallback,
+- ShareTargetDiscoveredCallback* discoveryCallback,
++ TransferUpdateCallback* transfer_callback,
++ ShareTargetDiscoveredCallback* discovery_callback,
+ StatusCodesCallback status_codes_callback) {
+ unregister_send_surface_callback_ = std::move(status_codes_callback);
+ StopFastInitiationAdvertising();
+ }
+
+-void NearbySharingServiceImpl::RegisterReceiveSurface(
+- TransferUpdateCallback* transferCallback,
+- StatusCodesCallback status_codes_callback) {
+- std::move(status_codes_callback).Run(StatusCodes::kOk);
++NearbySharingService::StatusCodes
++NearbySharingServiceImpl::RegisterReceiveSurface(
++ TransferUpdateCallback* transfer_callback,
++ ReceiveSurfaceState state) {
++ DCHECK(transfer_callback);
++ DCHECK_NE(state, ReceiveSurfaceState::kUnknown);
++ if (foreground_receive_callbacks_.HasObserver(transfer_callback) ||
++ background_receive_callbacks_.HasObserver(transfer_callback)) {
++ VLOG(1) << __func__
++ << ": registerReceiveSurface failed. Already registered.";
++ return StatusCodes::kError;
++ }
++
++ // If the receive surface to be registered is a foreground surface, let it
++ // catch up with most recent transfer metadata immediately.
++ if (state == ReceiveSurfaceState::kForeground && last_incoming_metadata_) {
++ transfer_callback->OnTransferUpdate(last_incoming_metadata_->first,
++ last_incoming_metadata_->second);
++ }
++
++ if (state == ReceiveSurfaceState::kForeground) {
++ foreground_receive_callbacks_.AddObserver(transfer_callback);
++ } else {
++ background_receive_callbacks_.AddObserver(transfer_callback);
++ }
++
++ VLOG(1) << __func__ << ": A ReceiveSurface("
++ << ReceiveSurfaceStateToString(state) << ") has been registered";
++ InvalidateReceiveSurfaceState();
++ return StatusCodes::kOk;
+ }
+
+-void NearbySharingServiceImpl::UnregisterReceiveSurface(
+- TransferUpdateCallback* transferCallback,
+- StatusCodesCallback status_codes_callback) {
+- std::move(status_codes_callback).Run(StatusCodes::kOk);
++NearbySharingService::StatusCodes
++NearbySharingServiceImpl::UnregisterReceiveSurface(
++ TransferUpdateCallback* transfer_callback) {
++ DCHECK(transfer_callback);
++ bool is_foreground =
++ foreground_receive_callbacks_.HasObserver(transfer_callback);
++ bool is_background =
++ background_receive_callbacks_.HasObserver(transfer_callback);
++ if (!is_foreground && !is_background) {
++ VLOG(1)
++ << __func__
++ << ": unregisterReceiveSurface failed. Unknown TransferUpdateCallback.";
++ return StatusCodes::kError;
++ }
++
++ if (foreground_receive_callbacks_.might_have_observers() &&
++ last_incoming_metadata_ &&
++ last_incoming_metadata_->second.is_final_status()) {
++ // We already saw the final status in the foreground.
++ // Nullify it so the next time the user opens sharing, it starts the UI from
++ // the beginning
++ last_incoming_metadata_.reset();
++ }
++
++ if (is_foreground) {
++ foreground_receive_callbacks_.RemoveObserver(transfer_callback);
++ } else {
++ background_receive_callbacks_.RemoveObserver(transfer_callback);
++ }
++
++ // Displays the most recent payload status processed by foreground surfaces on
++ // background surface.
++ if (!foreground_receive_callbacks_.might_have_observers() &&
++ last_incoming_metadata_) {
++ for (TransferUpdateCallback& background_callback :
++ background_receive_callbacks_) {
++ background_callback.OnTransferUpdate(last_incoming_metadata_->first,
++ last_incoming_metadata_->second);
++ }
++ }
++
++ VLOG(1) << __func__ << ": A ReceiveSurface("
++ << (is_foreground ? "foreground" : "background")
++ << ") has been unregistered";
++
++ InvalidateReceiveSurfaceState();
++ return StatusCodes::kOk;
+ }
+
+ void NearbySharingServiceImpl::NearbySharingServiceImpl::SendText(
+@@ -132,6 +301,13 @@ void NearbySharingServiceImpl::OnNearbyProcessStopped() {
+ }
+ }
+
++void NearbySharingServiceImpl::OnIncomingConnection(
++ const std::string& endpoint_id,
++ const std::vector<uint8_t>& endpoint_info,
++ std::unique_ptr<NearbyConnection> connection) {
++ // TODO(crbug/1085068): Handle incoming connection; use CertificateManager
++}
++
+ bool NearbySharingServiceImpl::IsEnabled() {
+ return prefs_->GetBoolean(prefs::kNearbySharingEnabledPrefName);
+ }
+@@ -141,12 +317,67 @@ void NearbySharingServiceImpl::OnEnabledPrefChanged() {
+ VLOG(1) << __func__ << ": Nearby sharing enabled!";
+ } else {
+ VLOG(1) << __func__ << ": Nearby sharing disabled!";
+- // TODO(crbug/1084647): Stop advertising.
++ StopAdvertising();
+ // TODO(crbug/1085067): Stop discovery.
+ nearby_connections_manager_->Shutdown();
+ }
+ }
+
++bool NearbySharingServiceImpl::IsVisibleInBackground(Visibility visibility) {
++ return visibility == Visibility::kAllContacts ||
++ visibility == Visibility::kSelectedContacts;
++}
++
++Visibility NearbySharingServiceImpl::GetVisibilityPref() {
++ int visibility =
++ prefs_->GetInteger(prefs::kNearbySharingBackgroundVisibilityName);
++ if (visibility < 0 || visibility > static_cast<int>(Visibility::kMaxValue))
++ return Visibility::kUnknown;
++
++ return static_cast<Visibility>(visibility);
++}
++
++void NearbySharingServiceImpl::OnVisibilityPrefChanged() {
++ Visibility new_visibility = GetVisibilityPref();
++ if (advertising_visibilty_preference_ == new_visibility) {
++ VLOG(1) << __func__ << ": Nearby sharing visibility pref is unchanged";
++ return;
++ }
++
++ advertising_visibilty_preference_ = new_visibility;
++ VLOG(1) << __func__ << ": Nearby sharing visibility changed to "
++ << VisibilityToString(advertising_visibilty_preference_);
++
++ if (advertising_power_level_ != PowerLevel::kUnknown) {
++ StopAdvertising();
++ }
++
++ InvalidateReceiveSurfaceState();
++}
++
++DataUsage NearbySharingServiceImpl::GetDataUsagePref() {
++ int usage = prefs_->GetInteger(prefs::kNearbySharingDataUsageName);
++ if (usage < 0 || usage > static_cast<int>(DataUsage::kMaxValue))
++ return DataUsage::kUnknown;
++
++ return static_cast<DataUsage>(usage);
++}
++
++void NearbySharingServiceImpl::OnDataUsagePrefChanged() {
++ DataUsage new_data_usage = GetDataUsagePref();
++ if (advertising_data_usage_preference_ == new_data_usage) {
++ VLOG(1) << __func__ << ": Nearby sharing data usage pref is unchanged";
++ return;
++ }
++
++ VLOG(1) << __func__ << ": Nearby sharing data usage changed.";
++ if (advertising_power_level_ != PowerLevel::kUnknown) {
++ StopAdvertising();
++ }
++
++ InvalidateReceiveSurfaceState();
++}
++
+ void NearbySharingServiceImpl::StartFastInitiationAdvertising() {
+ if (!IsBluetoothPresent() || !IsBluetoothPowered()) {
+ std::move(register_send_surface_callback_).Run(StatusCodes::kError);
+@@ -250,3 +481,155 @@ void NearbySharingServiceImpl::AdapterPoweredChanged(
+ if (!powered)
+ StopFastInitiationAdvertising();
+ }
++
++void NearbySharingServiceImpl::InvalidateReceiveSurfaceState() {
++ InvalidateAdvertisingState();
++ // TODO(crbug/154846208) InvalidateFastInitScan();
++}
++
++void NearbySharingServiceImpl::InvalidateAdvertisingState() {
++ // Screen is off. Do no work.
++ if (ui::CheckIdleStateIsLocked()) {
++ StopAdvertising();
++ VLOG(1) << __func__
++ << ": Stopping advertising because the screen is locked.";
++ return;
++ }
++
++ // Check if Wifi or Ethernet LAN is off. Advertisements won't work, so
++ // disable them, unless bluetooth is known to be enabled. Not all platforms
++ // have bluetooth, so wifi LAN is a platform-agnostic check.
++ net::NetworkChangeNotifier::ConnectionType connection_type =
++ net::NetworkChangeNotifier::GetConnectionType();
++ if (!IsBluetoothPresent() &&
++ !(connection_type ==
++ net::NetworkChangeNotifier::ConnectionType::CONNECTION_WIFI ||
++ connection_type ==
++ net::NetworkChangeNotifier::ConnectionType::CONNECTION_ETHERNET)) {
++ StopAdvertising();
++ VLOG(1) << __func__
++ << ": Stopping advertising because both bluetooth and wifi LAN are "
++ "disabled.";
++ return;
++ }
++
++ // Nearby Sharing is disabled. Don't advertise.
++ if (!IsEnabled()) {
++ StopAdvertising();
++ VLOG(1) << __func__
++ << ": Stopping advertising because Nearby Sharing is disabled.";
++ return;
++ }
++
++ // We're scanning for other nearby devices. Don't advertise.
++ if (is_scanning_) {
++ StopAdvertising();
++ VLOG(1)
++ << __func__
++ << ": Stopping advertising because we're scanning for other devices.";
++ return;
++ }
++
++ if (is_transferring_files_) {
++ StopAdvertising();
++ VLOG(1) << __func__
++ << ": Stopping advertising because we're currently in the midst of "
++ "a transfer.";
++ return;
++ }
++
++ if (!foreground_receive_callbacks_.might_have_observers() &&
++ !background_receive_callbacks_.might_have_observers()) {
++ StopAdvertising();
++ VLOG(1)
++ << __func__
++ << ": Stopping advertising because no receive surface is registered.";
++ return;
++ }
++
++ if (!IsVisibleInBackground(advertising_visibilty_preference_) &&
++ !foreground_receive_callbacks_.might_have_observers()) {
++ StopAdvertising();
++ VLOG(1) << __func__
++ << ": Stopping advertising because no high power receive surface "
++ "is registered and device is visible to NO_ONE.";
++ return;
++ }
++
++ PowerLevel power_level;
++ if (foreground_receive_callbacks_.might_have_observers()) {
++ power_level = PowerLevel::kHighPower;
++ // TODO(crbug/1100367) handle fast init
++ // } else if (isFastInitDeviceNearby) {
++ // power_level = PowerLevel::kMediumPower;
++ } else {
++ power_level = PowerLevel::kLowPower;
++ }
++
++ DataUsage data_usage = GetDataUsagePref();
++ if (advertising_power_level_ != PowerLevel::kUnknown) {
++ if (power_level == advertising_power_level_ &&
++ data_usage == advertising_data_usage_preference_) {
++ VLOG(1) << __func__
++ << "Failed to advertise because we're already advertising with "
++ "power level "
++ << PowerLevelToString(advertising_power_level_)
++ << " and data usage preference "
++ << DataUsageToString(advertising_data_usage_preference_);
++ return;
++ }
++
++ StopAdvertising();
++ VLOG(1) << __func__ << ": Restart advertising with power level "
++ << PowerLevelToString(power_level) << " and data usage preference "
++ << DataUsageToString(data_usage);
++ }
++
++ // Starts advertising through Nearby Connections. Caller is expected to ensure
++ // |listener| remains valid until StopAdvertising is called.
++
++ // TODO(nmusgrave) fill values from CertificateManager
++ std::vector<uint8_t> salt(sharing::Advertisement::kSaltSize, 0);
++ std::vector<uint8_t> encrypted_metadata_key(
++ sharing::Advertisement::kMetadataEncryptionKeyHashByteSize, 0);
++
++ // TODO(nmusgrave) fill value from local device data manager
++ base::Optional<std::string> device_name = "todo_device_name";
++ std::vector<uint8_t> endpoint_info =
++ sharing::Advertisement::NewInstance(std::move(salt),
++ std::move(encrypted_metadata_key),
++ std::move(device_name))
++ ->ToEndpointInfo();
++ nearby_connections_manager_->StartAdvertising(
++ std::move(endpoint_info),
++ /* listener= */ this, power_level, data_usage,
++ base::BindOnce([](NearbyConnectionsManager::ConnectionsStatus status) {
++ VLOG(1)
++ << __func__
++ << ": Advertising attempted over Nearby Connections with result "
++ << ConnectionsStatusToString(status);
++ }));
++
++ advertising_power_level_ = power_level;
++ advertising_data_usage_preference_ = data_usage;
++ VLOG(1) << __func__ << ": Advertising has started over Nearby Connections: "
++ << " power level " << PowerLevelToString(power_level)
++ << " visibility "
++ << VisibilityToString(advertising_visibilty_preference_)
++ << " data usage " << DataUsageToString(data_usage);
++ return;
++}
++
++void NearbySharingServiceImpl::StopAdvertising() {
++ if (advertising_power_level_ == PowerLevel::kUnknown) {
++ VLOG(1) << __func__
++ << ": Failed to stop advertising because we weren't advertising";
++ return;
++ }
++
++ nearby_connections_manager_->StopAdvertising();
++
++ advertising_data_usage_preference_ = DataUsage::kUnknown;
++ advertising_power_level_ = PowerLevel::kUnknown;
++ VLOG(1) << __func__ << ": Advertising has stopped";
++}
+diff --git a/chrome/browser/nearby_sharing/nearby_sharing_service_impl.h b/chrome/browser/nearby_sharing/nearby_sharing_service_impl.h
+index 6e43e2ba6793..95c298443044 100644
+--- a/chrome/browser/nearby_sharing/nearby_sharing_service_impl.h
++++ b/chrome/browser/nearby_sharing/nearby_sharing_service_impl.h
+@@ -7,26 +7,30 @@
+
+ #include <memory>
+ #include <string>
++#include <utility>
+ #include <vector>
+
+ #include "base/memory/ptr_util.h"
+ #include "base/memory/weak_ptr.h"
+ #include "base/scoped_observer.h"
++#include "chrome/browser/nearby_sharing/nearby_connections_manager.h"
++#include "chrome/browser/nearby_sharing/nearby_constants.h"
+ #include "chrome/browser/nearby_sharing/nearby_process_manager.h"
+ #include "chrome/browser/nearby_sharing/nearby_sharing_service.h"
+ #include "components/keyed_service/core/keyed_service.h"
+ #include "components/prefs/pref_change_registrar.h"
+-#include "device/bluetooth/bluetooth_adapter.h"
+
+ class FastInitiationManager;
+ class NearbyConnectionsManager;
+ class PrefService;
+ class Profile;
+
+-class NearbySharingServiceImpl : public NearbySharingService,
+- public KeyedService,
+- public NearbyProcessManager::Observer,
+- public device::BluetoothAdapter::Observer {
++class NearbySharingServiceImpl
++ : public NearbySharingService,
++ public KeyedService,
++ public NearbyProcessManager::Observer,
++ public device::BluetoothAdapter::Observer,
++ public NearbyConnectionsManager::IncomingConnectionListener {
+ public:
+ explicit NearbySharingServiceImpl(
+ PrefService* prefs,
+@@ -35,19 +39,17 @@ class NearbySharingServiceImpl : public NearbySharingService,
+ ~NearbySharingServiceImpl() override;
+
+ // NearbySharingService:
+- void RegisterSendSurface(TransferUpdateCallback* transferCallback,
+- ShareTargetDiscoveredCallback* discoveryCallback,
++ void RegisterSendSurface(TransferUpdateCallback* transfer_callback,
++ ShareTargetDiscoveredCallback* discovery_callback,
+ StatusCodesCallback status_codes_callback) override;
+ void UnregisterSendSurface(
+- TransferUpdateCallback* transferCallback,
+- ShareTargetDiscoveredCallback* discoveryCallback,
+- StatusCodesCallback status_codes_callback) override;
+- void RegisterReceiveSurface(
+- TransferUpdateCallback* transferCallback,
+- StatusCodesCallback status_codes_callback) override;
+- void UnregisterReceiveSurface(
+- TransferUpdateCallback* transferCallback,
++ TransferUpdateCallback* transfer_callback,
++ ShareTargetDiscoveredCallback* discovery_callback,
+ StatusCodesCallback status_codes_callback) override;
++ StatusCodes RegisterReceiveSurface(TransferUpdateCallback* transfer_callback,
++ ReceiveSurfaceState state) override;
++ StatusCodes UnregisterReceiveSurface(
++ TransferUpdateCallback* transfer_callback) override;
+ void SendText(const ShareTarget& share_target,
+ std::string text,
+ StatusCodesCallback status_codes_callback) override;
+@@ -68,9 +70,20 @@ class NearbySharingServiceImpl : public NearbySharingService,
+ void OnNearbyProcessStarted() override;
+ void OnNearbyProcessStopped() override;
+
++ // NearbyConnectionsManager::IncomingConnectionListener:
++ void OnIncomingConnection(
++ const std::string& endpoint_id,
++ const std::vector<uint8_t>& endpoint_info,
++ std::unique_ptr<NearbyConnection> connection) override;
++
+ private:
+ bool IsEnabled();
+ void OnEnabledPrefChanged();
++ Visibility GetVisibilityPref();
++ bool IsVisibleInBackground(Visibility visibility);
++ void OnVisibilityPrefChanged();
++ DataUsage GetDataUsagePref();
++ void OnDataUsagePrefChanged();
+ void StartFastInitiationAdvertising();
+ void StopFastInitiationAdvertising();
+ void GetBluetoothAdapter();
+@@ -84,6 +97,9 @@ class NearbySharingServiceImpl : public NearbySharingService,
+ bool present) override;
+ void AdapterPoweredChanged(device::BluetoothAdapter* adapter,
+ bool powered) override;
++ void InvalidateReceiveSurfaceState();
++ void InvalidateAdvertisingState();
++ void StopAdvertising();
+
+ PrefService* prefs_;
+ Profile* profile_;
+@@ -95,6 +111,36 @@ class NearbySharingServiceImpl : public NearbySharingService,
+ std::unique_ptr<FastInitiationManager> fast_initiation_manager_;
+ StatusCodesCallback register_send_surface_callback_;
+ StatusCodesCallback unregister_send_surface_callback_;
++
++ // A list of foreground receivers.
++ base::ObserverList<TransferUpdateCallback> foreground_receive_callbacks_;
++ // A list of foreground receivers.
++ base::ObserverList<TransferUpdateCallback> background_receive_callbacks_;
++
++ // Registers the most recent TransferMetadata and ShareTarget used for
++ // transitioning notifications between foreground surfaces and background
++ // surfaces. Empty if no metadata is available.
++ base::Optional<std::pair<ShareTarget, TransferMetadata>>
++ last_incoming_metadata_;
++ // The most recent outgoing TransferMetadata and ShareTarget.
++ base::Optional<std::pair<ShareTarget, TransferMetadata>>
++ last_outgoing_metadata_;
++
++ // The current advertising power level. PowerLevel::kUnknown while not
++ // advertising.
++ PowerLevel advertising_power_level_ = PowerLevel::kUnknown;
++ // The current advertising data usage preference. We need to restart scan
++ // (Fast Init) or advertise (Nearby Connections or Fast Init) when online
++ // preference changes. DataUsage::kUnknown while not advertising.
++ DataUsage advertising_data_usage_preference_ = DataUsage::kUnknown;
++ // The current visibility preference. We need to restart advertising if
++ // the visibility changes.
++ Visibility advertising_visibilty_preference_ = Visibility::kUnknown;
++ // True if we are currently scanning for remote devices.
++ bool is_scanning_ = false;
++ // True if we're currently sending or receiving a file.
++ bool is_transferring_files_ = false;
++
+ base::WeakPtrFactory<NearbySharingServiceImpl> weak_ptr_factory_{this};
+ };
+
+diff --git a/chrome/browser/nearby_sharing/nearby_sharing_service_impl_unittest.cc b/chrome/browser/nearby_sharing/nearby_sharing_service_impl_unittest.cc
+index 5fa25789f5f7..d1debce4b75a 100644
+--- a/chrome/browser/nearby_sharing/nearby_sharing_service_impl_unittest.cc
++++ b/chrome/browser/nearby_sharing/nearby_sharing_service_impl_unittest.cc
+@@ -22,13 +22,17 @@
+ #include "device/bluetooth/bluetooth_adapter.h"
+ #include "device/bluetooth/bluetooth_adapter_factory.h"
+ #include "device/bluetooth/test/mock_bluetooth_adapter.h"
++#include "net/base/mock_network_change_notifier.h"
+ #include "testing/gmock/include/gmock/gmock.h"
+ #include "testing/gtest/include/gtest/gtest.h"
++#include "ui/base/idle/scoped_set_idle_state.h"
+
+ using ::testing::_;
+ using testing::NiceMock;
+ using testing::Return;
+
++using NetConnectionType = net::NetworkChangeNotifier::ConnectionType;
++
+ class FakeFastInitiationManager : public FastInitiationManager {
+ public:
+ explicit FakeFastInitiationManager(
+@@ -113,6 +117,15 @@ class FakeFastInitiationManagerFactory : public FastInitiationManager::Factory {
+ this};
+ };
+
++class FakeTransferUpdateCallback : public TransferUpdateCallback {
++ public:
++ void OnTransferUpdate(const ShareTarget& shareTarget,
++ const TransferMetadata& transferMetadata) override {
++ // TODO(crbug/1085068): Test transfer update callback when incoming
++ // connection is handled.
++ }
++};
++
+ namespace {
+
+ class NearbySharingServiceImplTest : public testing::Test {
+@@ -171,7 +184,7 @@ class NearbySharingServiceImplTest : public testing::Test {
+ base::RunLoop run_loop;
+ NearbySharingService::StatusCodes result;
+ service_->RegisterSendSurface(
+- /*transferCallback=*/nullptr, /*discoveryCallback=*/nullptr,
++ /*transfer_callback=*/nullptr, /*discovery_callback=*/nullptr,
+ base::BindOnce(
+ [](base::OnceClosure quit_closure,
+ NearbySharingService::StatusCodes* result,
+@@ -188,7 +201,7 @@ class NearbySharingServiceImplTest : public testing::Test {
+ base::RunLoop run_loop;
+ NearbySharingService::StatusCodes result;
+ service_->UnregisterSendSurface(
+- /*transferCallback=*/nullptr, /*discoveryCallback=*/nullptr,
++ /*transfer_callback=*/nullptr, /*discovery_callback=*/nullptr,
+ base::BindOnce(
+ [](base::OnceClosure quit_closure,
+ NearbySharingService::StatusCodes* result,
+@@ -209,6 +222,12 @@ class NearbySharingServiceImplTest : public testing::Test {
+ adapter_observer_ = observer;
+ }
+
++ void SetConnectionType(net::NetworkChangeNotifier::ConnectionType type) {
++ network_notifier_->SetConnectionType(type);
++ network_notifier_->NotifyObserversOfNetworkChangeForTests(
++ network_notifier_->GetConnectionType());
++ }
++
+ protected:
+ content::BrowserTaskEnvironment task_environment_;
+ TestingProfileManager profile_manager_{TestingBrowserProcess::GetGlobal()};
+@@ -221,6 +240,8 @@ class NearbySharingServiceImplTest : public testing::Test {
+ bool is_bluetooth_powered_ = true;
+ device::BluetoothAdapter::Observer* adapter_observer_ = nullptr;
+ scoped_refptr<NiceMock<device::MockBluetoothAdapter>> mock_bluetooth_adapter_;
++ std::unique_ptr<net::test::MockNetworkChangeNotifier> network_notifier_ =
++ net::test::MockNetworkChangeNotifier::Create();
+ };
+
+ } // namespace
+@@ -302,3 +323,377 @@ TEST_F(NearbySharingServiceImplTest,
+ EXPECT_TRUE(fast_initiation_manager_factory_
+ ->StopAdvertisingCalledAndManagerDestroyed());
+ }
++
++TEST_F(NearbySharingServiceImplTest,
++ ForegroundRegisterReceiveSurfaceIsAdvertising) {
++ ui::ScopedSetIdleState unlocked(ui::IDLE_STATE_IDLE);
++ SetConnectionType(net::NetworkChangeNotifier::CONNECTION_WIFI);
++ FakeTransferUpdateCallback callback;
++ NearbySharingService::StatusCodes result = service_->RegisterReceiveSurface(
++ &callback, NearbySharingService::ReceiveSurfaceState::kForeground);
++ EXPECT_EQ(result, NearbySharingService::StatusCodes::kOk);
++ EXPECT_TRUE(fake_nearby_connections_manager_->IsAdvertising());
++ EXPECT_EQ(PowerLevel::kHighPower,
++ fake_nearby_connections_manager_->GetAdvertisingPowerLevel());
++}
++
++TEST_F(NearbySharingServiceImplTest,
++ BackgroundRegisterReceiveSurfaceIsAdvertising) {
++ ui::ScopedSetIdleState unlocked(ui::IDLE_STATE_IDLE);
++ SetConnectionType(net::NetworkChangeNotifier::CONNECTION_WIFI);
++ prefs_.SetInteger(prefs::kNearbySharingBackgroundVisibilityName,
++ static_cast<int>(Visibility::kSelectedContacts));
++ FakeTransferUpdateCallback callback;
++ NearbySharingService::StatusCodes result = service_->RegisterReceiveSurface(
++ &callback, NearbySharingService::ReceiveSurfaceState::kBackground);
++ EXPECT_EQ(result, NearbySharingService::StatusCodes::kOk);
++ EXPECT_TRUE(fake_nearby_connections_manager_->IsAdvertising());
++ EXPECT_EQ(PowerLevel::kLowPower,
++ fake_nearby_connections_manager_->GetAdvertisingPowerLevel());
++}
++
++TEST_F(NearbySharingServiceImplTest,
++ RegisterReceiveSurfaceTwiceSameCallbackKeepAdvertising) {
++ ui::ScopedSetIdleState unlocked(ui::IDLE_STATE_IDLE);
++ SetConnectionType(net::NetworkChangeNotifier::CONNECTION_WIFI);
++ FakeTransferUpdateCallback callback;
++ NearbySharingService::StatusCodes result = service_->RegisterReceiveSurface(
++ &callback, NearbySharingService::ReceiveSurfaceState::kForeground);
++ EXPECT_EQ(result, NearbySharingService::StatusCodes::kOk);
++ EXPECT_TRUE(fake_nearby_connections_manager_->IsAdvertising());
++
++ NearbySharingService::StatusCodes result2 = service_->RegisterReceiveSurface(
++ &callback, NearbySharingService::ReceiveSurfaceState::kForeground);
++ EXPECT_EQ(result2, NearbySharingService::StatusCodes::kError);
++ EXPECT_TRUE(fake_nearby_connections_manager_->IsAdvertising());
++}
++
++TEST_F(NearbySharingServiceImplTest,
++ RegisterReceiveSurfaceTwiceKeepAdvertising) {
++ ui::ScopedSetIdleState unlocked(ui::IDLE_STATE_IDLE);
++ SetConnectionType(net::NetworkChangeNotifier::CONNECTION_WIFI);
++ FakeTransferUpdateCallback callback;
++ NearbySharingService::StatusCodes result = service_->RegisterReceiveSurface(
++ &callback, NearbySharingService::ReceiveSurfaceState::kForeground);
++ EXPECT_EQ(result, NearbySharingService::StatusCodes::kOk);
++ EXPECT_TRUE(fake_nearby_connections_manager_->IsAdvertising());
++
++ FakeTransferUpdateCallback callback2;
++ NearbySharingService::StatusCodes result2 = service_->RegisterReceiveSurface(
++ &callback2, NearbySharingService::ReceiveSurfaceState::kForeground);
++ EXPECT_EQ(result2, NearbySharingService::StatusCodes::kOk);
++ EXPECT_TRUE(fake_nearby_connections_manager_->IsAdvertising());
++}
++
++TEST_F(NearbySharingServiceImplTest,
++ ScreenLockedRegisterReceiveSurfaceNotAdvertising) {
++ ui::ScopedSetIdleState locked(ui::IDLE_STATE_LOCKED);
++ SetConnectionType(net::NetworkChangeNotifier::CONNECTION_WIFI);
++ FakeTransferUpdateCallback callback;
++ NearbySharingService::StatusCodes result = service_->RegisterReceiveSurface(
++ &callback, NearbySharingService::ReceiveSurfaceState::kForeground);
++ EXPECT_EQ(result, NearbySharingService::StatusCodes::kOk);
++ EXPECT_FALSE(fake_nearby_connections_manager_->IsAdvertising());
++ EXPECT_FALSE(fake_nearby_connections_manager_->IsShutdown());
++}
++
++TEST_F(NearbySharingServiceImplTest,
++ DataUsageChangedRegisterReceiveSurfaceRestartsAdvertising) {
++ ui::ScopedSetIdleState locked(ui::IDLE_STATE_IDLE);
++ SetConnectionType(net::NetworkChangeNotifier::CONNECTION_WIFI);
++
++ prefs_.SetInteger(prefs::kNearbySharingDataUsageName,
++ static_cast<int>(DataUsage::kOffline));
++ FakeTransferUpdateCallback callback;
++ NearbySharingService::StatusCodes result = service_->RegisterReceiveSurface(
++ &callback, NearbySharingService::ReceiveSurfaceState::kForeground);
++ EXPECT_EQ(result, NearbySharingService::StatusCodes::kOk);
++ EXPECT_TRUE(fake_nearby_connections_manager_->IsAdvertising());
++ EXPECT_EQ(DataUsage::kOffline,
++ fake_nearby_connections_manager_->GetAdvertisingDataUsage());
++
++ prefs_.SetInteger(prefs::kNearbySharingDataUsageName,
++ static_cast<int>(DataUsage::kOnline));
++ EXPECT_TRUE(fake_nearby_connections_manager_->IsAdvertising());
++ EXPECT_EQ(DataUsage::kOnline,
++ fake_nearby_connections_manager_->GetAdvertisingDataUsage());
++}
++
++TEST_F(NearbySharingServiceImplTest,
++ NoNetworkRegisterReceiveSurfaceIsAdvertising) {
++ ui::ScopedSetIdleState unlocked(ui::IDLE_STATE_IDLE);
++ FakeTransferUpdateCallback callback;
++ NearbySharingService::StatusCodes result = service_->RegisterReceiveSurface(
++ &callback, NearbySharingService::ReceiveSurfaceState::kForeground);
++ EXPECT_EQ(result, NearbySharingService::StatusCodes::kOk);
++ // Succeeds since bluetooth is present.
++ EXPECT_TRUE(fake_nearby_connections_manager_->IsAdvertising());
++}
++
++TEST_F(NearbySharingServiceImplTest,
++ NoBluetoothNoNetworkRegisterReceiveSurfaceNotAdvertising) {
++ ui::ScopedSetIdleState unlocked(ui::IDLE_STATE_IDLE);
++ is_bluetooth_present_ = false;
++ FakeTransferUpdateCallback callback;
++ NearbySharingService::StatusCodes result = service_->RegisterReceiveSurface(
++ &callback, NearbySharingService::ReceiveSurfaceState::kForeground);
++ EXPECT_EQ(result, NearbySharingService::StatusCodes::kOk);
++ EXPECT_FALSE(fake_nearby_connections_manager_->IsAdvertising());
++ EXPECT_FALSE(fake_nearby_connections_manager_->IsShutdown());
++}
++
++TEST_F(NearbySharingServiceImplTest, WifiRegisterReceiveSurfaceIsAdvertising) {
++ ui::ScopedSetIdleState unlocked(ui::IDLE_STATE_IDLE);
++ SetConnectionType(net::NetworkChangeNotifier::CONNECTION_WIFI);
++ FakeTransferUpdateCallback callback;
++ NearbySharingService::StatusCodes result = service_->RegisterReceiveSurface(
++ &callback, NearbySharingService::ReceiveSurfaceState::kForeground);
++ EXPECT_EQ(result, NearbySharingService::StatusCodes::kOk);
++ EXPECT_TRUE(fake_nearby_connections_manager_->IsAdvertising());
++}
++
++TEST_F(NearbySharingServiceImplTest,
++ EthernetRegisterReceiveSurfaceIsAdvertising) {
++ ui::ScopedSetIdleState unlocked(ui::IDLE_STATE_IDLE);
++ SetConnectionType(net::NetworkChangeNotifier::CONNECTION_ETHERNET);
++ FakeTransferUpdateCallback callback;
++ NearbySharingService::StatusCodes result = service_->RegisterReceiveSurface(
++ &callback, NearbySharingService::ReceiveSurfaceState::kForeground);
++ EXPECT_EQ(result, NearbySharingService::StatusCodes::kOk);
++ EXPECT_TRUE(fake_nearby_connections_manager_->IsAdvertising());
++}
++
++TEST_F(NearbySharingServiceImplTest,
++ ThreeGRegisterReceiveSurfaceIsAdvertising) {
++ ui::ScopedSetIdleState unlocked(ui::IDLE_STATE_IDLE);
++ SetConnectionType(net::NetworkChangeNotifier::CONNECTION_3G);
++ FakeTransferUpdateCallback callback;
++ NearbySharingService::StatusCodes result = service_->RegisterReceiveSurface(
++ &callback, NearbySharingService::ReceiveSurfaceState::kForeground);
++ EXPECT_EQ(result, NearbySharingService::StatusCodes::kOk);
++ // Since bluetooth is on, connection still succeeds.
++ EXPECT_TRUE(fake_nearby_connections_manager_->IsAdvertising());
++}
++
++TEST_F(NearbySharingServiceImplTest,
++ NoBluetoothWifiReceiveSurfaceIsAdvertising) {
++ ui::ScopedSetIdleState unlocked(ui::IDLE_STATE_IDLE);
++ is_bluetooth_present_ = false;
++ SetConnectionType(net::NetworkChangeNotifier::CONNECTION_WIFI);
++ FakeTransferUpdateCallback callback;
++ NearbySharingService::StatusCodes result = service_->RegisterReceiveSurface(
++ &callback, NearbySharingService::ReceiveSurfaceState::kForeground);
++ EXPECT_EQ(result, NearbySharingService::StatusCodes::kOk);
++ EXPECT_TRUE(fake_nearby_connections_manager_->IsAdvertising());
++}
++
++TEST_F(NearbySharingServiceImplTest,
++ NoBluetoothEthernetReceiveSurfaceIsAdvertising) {
++ ui::ScopedSetIdleState unlocked(ui::IDLE_STATE_IDLE);
++ is_bluetooth_present_ = false;
++ SetConnectionType(net::NetworkChangeNotifier::CONNECTION_ETHERNET);
++ FakeTransferUpdateCallback callback;
++ NearbySharingService::StatusCodes result = service_->RegisterReceiveSurface(
++ &callback, NearbySharingService::ReceiveSurfaceState::kForeground);
++ EXPECT_EQ(result, NearbySharingService::StatusCodes::kOk);
++ EXPECT_TRUE(fake_nearby_connections_manager_->IsAdvertising());
++}
++
++TEST_F(NearbySharingServiceImplTest,
++ NoBluetoothThreeGReceiveSurfaceNotAdvertising) {
++ ui::ScopedSetIdleState unlocked(ui::IDLE_STATE_IDLE);
++ is_bluetooth_present_ = false;
++ SetConnectionType(net::NetworkChangeNotifier::CONNECTION_3G);
++ FakeTransferUpdateCallback callback;
++ NearbySharingService::StatusCodes result = service_->RegisterReceiveSurface(
++ &callback, NearbySharingService::ReceiveSurfaceState::kForeground);
++ EXPECT_EQ(result, NearbySharingService::StatusCodes::kOk);
++ EXPECT_FALSE(fake_nearby_connections_manager_->IsAdvertising());
++ EXPECT_FALSE(fake_nearby_connections_manager_->IsShutdown());
++}
++
++TEST_F(NearbySharingServiceImplTest,
++ DisableFeatureReceiveSurfaceNotAdvertising) {
++ ui::ScopedSetIdleState unlocked(ui::IDLE_STATE_IDLE);
++ prefs_.SetBoolean(prefs::kNearbySharingEnabledPrefName, false);
++ SetConnectionType(net::NetworkChangeNotifier::CONNECTION_WIFI);
++ FakeTransferUpdateCallback callback;
++ NearbySharingService::StatusCodes result = service_->RegisterReceiveSurface(
++ &callback, NearbySharingService::ReceiveSurfaceState::kForeground);
++ EXPECT_EQ(result, NearbySharingService::StatusCodes::kOk);
++ EXPECT_FALSE(fake_nearby_connections_manager_->IsAdvertising());
++ EXPECT_TRUE(fake_nearby_connections_manager_->IsShutdown());
++}
++
++TEST_F(NearbySharingServiceImplTest,
++ DisableFeatureReceiveSurfaceStopsAdvertising) {
++ ui::ScopedSetIdleState unlocked(ui::IDLE_STATE_IDLE);
++ SetConnectionType(net::NetworkChangeNotifier::CONNECTION_WIFI);
++ FakeTransferUpdateCallback callback;
++ NearbySharingService::StatusCodes result = service_->RegisterReceiveSurface(
++ &callback, NearbySharingService::ReceiveSurfaceState::kForeground);
++ EXPECT_EQ(result, NearbySharingService::StatusCodes::kOk);
++ EXPECT_TRUE(fake_nearby_connections_manager_->IsAdvertising());
++
++ prefs_.SetBoolean(prefs::kNearbySharingEnabledPrefName, false);
++ EXPECT_FALSE(fake_nearby_connections_manager_->IsAdvertising());
++ EXPECT_TRUE(fake_nearby_connections_manager_->IsShutdown());
++}
++
++TEST_F(NearbySharingServiceImplTest,
++ ForegroundReceiveSurfaceNoOneVisibilityIsAdvertising) {
++ ui::ScopedSetIdleState unlocked(ui::IDLE_STATE_IDLE);
++ SetConnectionType(net::NetworkChangeNotifier::CONNECTION_WIFI);
++ prefs_.SetInteger(prefs::kNearbySharingBackgroundVisibilityName,
++ static_cast<int>(Visibility::kNoOne));
++ FakeTransferUpdateCallback callback;
++ NearbySharingService::StatusCodes result = service_->RegisterReceiveSurface(
++ &callback, NearbySharingService::ReceiveSurfaceState::kForeground);
++ EXPECT_EQ(result, NearbySharingService::StatusCodes::kOk);
++ EXPECT_TRUE(fake_nearby_connections_manager_->IsAdvertising());
++}
++
++TEST_F(NearbySharingServiceImplTest,
++ BackgroundReceiveSurfaceNoOneVisibilityNotAdvertising) {
++ ui::ScopedSetIdleState unlocked(ui::IDLE_STATE_IDLE);
++ SetConnectionType(net::NetworkChangeNotifier::CONNECTION_WIFI);
++ prefs_.SetInteger(prefs::kNearbySharingBackgroundVisibilityName,
++ static_cast<int>(Visibility::kNoOne));
++ FakeTransferUpdateCallback callback;
++ NearbySharingService::StatusCodes result = service_->RegisterReceiveSurface(
++ &callback, NearbySharingService::ReceiveSurfaceState::kBackground);
++ EXPECT_EQ(result, NearbySharingService::StatusCodes::kOk);
++ EXPECT_FALSE(fake_nearby_connections_manager_->IsAdvertising());
++ EXPECT_FALSE(fake_nearby_connections_manager_->IsShutdown());
++}
++
++TEST_F(NearbySharingServiceImplTest,
++ BackgroundReceiveSurfaceVisibilityToNoOneStopsAdvertising) {
++ ui::ScopedSetIdleState unlocked(ui::IDLE_STATE_IDLE);
++ SetConnectionType(net::NetworkChangeNotifier::CONNECTION_WIFI);
++ prefs_.SetInteger(prefs::kNearbySharingBackgroundVisibilityName,
++ static_cast<int>(Visibility::kSelectedContacts));
++ FakeTransferUpdateCallback callback;
++ NearbySharingService::StatusCodes result = service_->RegisterReceiveSurface(
++ &callback, NearbySharingService::ReceiveSurfaceState::kBackground);
++ EXPECT_EQ(result, NearbySharingService::StatusCodes::kOk);
++ EXPECT_TRUE(fake_nearby_connections_manager_->IsAdvertising());
++
++ prefs_.SetInteger(prefs::kNearbySharingBackgroundVisibilityName,
++ static_cast<int>(Visibility::kNoOne));
++ EXPECT_FALSE(fake_nearby_connections_manager_->IsAdvertising());
++ EXPECT_FALSE(fake_nearby_connections_manager_->IsShutdown());
++}
++
++TEST_F(NearbySharingServiceImplTest,
++ BackgroundReceiveSurfaceVisibilityToSelectedStartsAdvertising) {
++ ui::ScopedSetIdleState unlocked(ui::IDLE_STATE_IDLE);
++ SetConnectionType(net::NetworkChangeNotifier::CONNECTION_WIFI);
++ prefs_.SetInteger(prefs::kNearbySharingBackgroundVisibilityName,
++ static_cast<int>(Visibility::kNoOne));
++ FakeTransferUpdateCallback callback;
++ NearbySharingService::StatusCodes result = service_->RegisterReceiveSurface(
++ &callback, NearbySharingService::ReceiveSurfaceState::kBackground);
++ EXPECT_EQ(result, NearbySharingService::StatusCodes::kOk);
++ EXPECT_FALSE(fake_nearby_connections_manager_->IsAdvertising());
++ EXPECT_FALSE(fake_nearby_connections_manager_->IsShutdown());
++
++ prefs_.SetInteger(prefs::kNearbySharingBackgroundVisibilityName,
++ static_cast<int>(Visibility::kSelectedContacts));
++ EXPECT_TRUE(fake_nearby_connections_manager_->IsAdvertising());
++}
++
++TEST_F(NearbySharingServiceImplTest,
++ ForegroundReceiveSurfaceSelectedContactsVisibilityIsAdvertising) {
++ ui::ScopedSetIdleState unlocked(ui::IDLE_STATE_IDLE);
++ SetConnectionType(net::NetworkChangeNotifier::CONNECTION_WIFI);
++ prefs_.SetInteger(prefs::kNearbySharingBackgroundVisibilityName,
++ static_cast<int>(Visibility::kSelectedContacts));
++ FakeTransferUpdateCallback callback;
++ NearbySharingService::StatusCodes result = service_->RegisterReceiveSurface(
++ &callback, NearbySharingService::ReceiveSurfaceState::kForeground);
++ EXPECT_EQ(result, NearbySharingService::StatusCodes::kOk);
++ EXPECT_TRUE(fake_nearby_connections_manager_->IsAdvertising());
++}
++
++TEST_F(NearbySharingServiceImplTest,
++ BackgroundReceiveSurfaceSelectedContactsVisibilityIsAdvertising) {
++ ui::ScopedSetIdleState unlocked(ui::IDLE_STATE_IDLE);
++ SetConnectionType(net::NetworkChangeNotifier::CONNECTION_WIFI);
++ prefs_.SetInteger(prefs::kNearbySharingBackgroundVisibilityName,
++ static_cast<int>(Visibility::kSelectedContacts));
++ FakeTransferUpdateCallback callback;
++ NearbySharingService::StatusCodes result = service_->RegisterReceiveSurface(
++ &callback, NearbySharingService::ReceiveSurfaceState::kBackground);
++ EXPECT_EQ(result, NearbySharingService::StatusCodes::kOk);
++ EXPECT_TRUE(fake_nearby_connections_manager_->IsAdvertising());
++}
++
++TEST_F(NearbySharingServiceImplTest,
++ ForegroundReceiveSurfaceAllContactsVisibilityIsAdvertising) {
++ ui::ScopedSetIdleState unlocked(ui::IDLE_STATE_IDLE);
++ SetConnectionType(net::NetworkChangeNotifier::CONNECTION_WIFI);
++ prefs_.SetInteger(prefs::kNearbySharingBackgroundVisibilityName,
++ static_cast<int>(Visibility::kAllContacts));
++ FakeTransferUpdateCallback callback;
++ NearbySharingService::StatusCodes result = service_->RegisterReceiveSurface(
++ &callback, NearbySharingService::ReceiveSurfaceState::kForeground);
++ EXPECT_EQ(result, NearbySharingService::StatusCodes::kOk);
++ EXPECT_TRUE(fake_nearby_connections_manager_->IsAdvertising());
++}
++
++TEST_F(NearbySharingServiceImplTest,
++ BackgroundReceiveSurfaceAllContactsVisibilityNotAdvertising) {
++ ui::ScopedSetIdleState unlocked(ui::IDLE_STATE_IDLE);
++ SetConnectionType(net::NetworkChangeNotifier::CONNECTION_WIFI);
++ prefs_.SetInteger(prefs::kNearbySharingBackgroundVisibilityName,
++ static_cast<int>(Visibility::kAllContacts));
++ FakeTransferUpdateCallback callback;
++ NearbySharingService::StatusCodes result = service_->RegisterReceiveSurface(
++ &callback, NearbySharingService::ReceiveSurfaceState::kBackground);
++ EXPECT_EQ(result, NearbySharingService::StatusCodes::kOk);
++ EXPECT_TRUE(fake_nearby_connections_manager_->IsAdvertising());
++}
++
++TEST_F(NearbySharingServiceImplTest, UnregisterReceiveSurfaceStopsAdvertising) {
++ ui::ScopedSetIdleState unlocked(ui::IDLE_STATE_IDLE);
++ SetConnectionType(net::NetworkChangeNotifier::CONNECTION_WIFI);
++ FakeTransferUpdateCallback callback;
++ NearbySharingService::StatusCodes result = service_->RegisterReceiveSurface(
++ &callback, NearbySharingService::ReceiveSurfaceState::kForeground);
++ EXPECT_EQ(result, NearbySharingService::StatusCodes::kOk);
++ EXPECT_TRUE(fake_nearby_connections_manager_->IsAdvertising());
++
++ NearbySharingService::StatusCodes result2 =
++ service_->UnregisterReceiveSurface(&callback);
++ EXPECT_EQ(result2, NearbySharingService::StatusCodes::kOk);
++ EXPECT_FALSE(fake_nearby_connections_manager_->IsAdvertising());
++ EXPECT_FALSE(fake_nearby_connections_manager_->IsShutdown());
++}
++
++TEST_F(NearbySharingServiceImplTest,
++ UnregisterReceiveSurfaceDifferentCallbackKeepAdvertising) {
++ ui::ScopedSetIdleState unlocked(ui::IDLE_STATE_IDLE);
++ SetConnectionType(net::NetworkChangeNotifier::CONNECTION_WIFI);
++ FakeTransferUpdateCallback callback;
++ NearbySharingService::StatusCodes result = service_->RegisterReceiveSurface(
++ &callback, NearbySharingService::ReceiveSurfaceState::kForeground);
++ EXPECT_EQ(result, NearbySharingService::StatusCodes::kOk);
++ EXPECT_TRUE(fake_nearby_connections_manager_->IsAdvertising());
++
++ FakeTransferUpdateCallback callback2;
++ NearbySharingService::StatusCodes result2 =
++ service_->UnregisterReceiveSurface(&callback2);
++ EXPECT_EQ(result2, NearbySharingService::StatusCodes::kError);
++ EXPECT_TRUE(fake_nearby_connections_manager_->IsAdvertising());
++}
++
++TEST_F(NearbySharingServiceImplTest, UnregisterReceiveSurfaceNeverRegistered) {
++ ui::ScopedSetIdleState unlocked(ui::IDLE_STATE_IDLE);
++ SetConnectionType(net::NetworkChangeNotifier::CONNECTION_WIFI);
++ FakeTransferUpdateCallback callback;
++ NearbySharingService::StatusCodes result =
++ service_->UnregisterReceiveSurface(&callback);
++ EXPECT_EQ(result, NearbySharingService::StatusCodes::kError);
++ EXPECT_FALSE(fake_nearby_connections_manager_->IsAdvertising());
++}
+diff --git a/chrome/browser/nearby_sharing/share_target.cc b/chrome/browser/nearby_sharing/share_target.cc
+index 9c9da5047659..f8a870bccbac 100644
+--- a/chrome/browser/nearby_sharing/share_target.cc
++++ b/chrome/browser/nearby_sharing/share_target.cc
+@@ -4,6 +4,8 @@
+
+ #include "chrome/browser/nearby_sharing/share_target.h"
+
++#include <utility>
++
+ #include "base/atomic_sequence_num.h"
+
+ namespace {
+@@ -32,3 +34,5 @@ ShareTarget::ShareTarget(std::string device_name,
+ is_known_(is_known) {}
+
+ ShareTarget::~ShareTarget() = default;
++ShareTarget::ShareTarget(const ShareTarget&) = default;
++ShareTarget& ShareTarget::operator=(const ShareTarget&) = default;
+diff --git a/chrome/browser/nearby_sharing/share_target.h b/chrome/browser/nearby_sharing/share_target.h
+index 5f1b37309709..8df29a581ed1 100644
+--- a/chrome/browser/nearby_sharing/share_target.h
++++ b/chrome/browser/nearby_sharing/share_target.h
+@@ -27,6 +27,8 @@ class ShareTarget {
+ base::Optional<std::string> full_name,
+ bool is_known);
+ ~ShareTarget();
++ ShareTarget(const ShareTarget&);
++ ShareTarget& operator=(const ShareTarget&);
+
+ int id() { return id_; }
+ const std::string& device_name() { return device_name_; }
+diff --git a/chrome/browser/nearby_sharing/text_attachment.cc b/chrome/browser/nearby_sharing/text_attachment.cc
+index f7406bd6623b..ab210fab9747 100644
+--- a/chrome/browser/nearby_sharing/text_attachment.cc
++++ b/chrome/browser/nearby_sharing/text_attachment.cc
+@@ -2,6 +2,8 @@
+ // Use of this source code is governed by a BSD-style license that can be
+ // found in the LICENSE file.
+
++#include <utility>
++
+ #include "chrome/browser/nearby_sharing/text_attachment.h"
+
+ TextAttachment::TextAttachment(std::string text_body, Type type, int64_t size)
+@@ -9,6 +11,10 @@ TextAttachment::TextAttachment(std::string text_body, Type type, int64_t size)
+
+ TextAttachment::~TextAttachment() = default;
+
++TextAttachment::TextAttachment(const TextAttachment&) = default;
++
++TextAttachment& TextAttachment::operator=(const TextAttachment&) = default;
++
+ int64_t TextAttachment::size() const {
+ return size_;
+ }
+diff --git a/chrome/browser/nearby_sharing/text_attachment.h b/chrome/browser/nearby_sharing/text_attachment.h
+index e4fcce86400e..e9863ce69717 100644
+--- a/chrome/browser/nearby_sharing/text_attachment.h
++++ b/chrome/browser/nearby_sharing/text_attachment.h
+@@ -27,6 +27,8 @@ class TextAttachment : public Attachment {
+
+ TextAttachment(std::string text_body, Type type, int64_t size);
+ ~TextAttachment() override;
++ TextAttachment(const TextAttachment&);
++ TextAttachment& operator=(const TextAttachment&);
+
+ // Attachment:
+ int64_t size() const override;
+diff --git a/chrome/browser/nearby_sharing/transfer_metadata.cc b/chrome/browser/nearby_sharing/transfer_metadata.cc
+index 7e2f4028fd69..2eb708a93762 100644
+--- a/chrome/browser/nearby_sharing/transfer_metadata.cc
++++ b/chrome/browser/nearby_sharing/transfer_metadata.cc
+@@ -2,6 +2,8 @@
+ // Use of this source code is governed by a BSD-style license that can be
+ // found in the LICENSE file.
+
++#include <utility>
++
+ #include "chrome/browser/nearby_sharing/transfer_metadata.h"
+
+ TransferMetadata::TransferMetadata(Status status,
+@@ -16,3 +18,8 @@ TransferMetadata::TransferMetadata(Status status,
+ is_final_status_(is_final_status) {}
+
+ TransferMetadata::~TransferMetadata() = default;
++
++TransferMetadata::TransferMetadata(const TransferMetadata&) = default;
++
++TransferMetadata& TransferMetadata::operator=(const TransferMetadata&) =
++ default;
+diff --git a/chrome/browser/nearby_sharing/transfer_metadata.h b/chrome/browser/nearby_sharing/transfer_metadata.h
+index e13f3ae4c413..6b82fba803de 100644
+--- a/chrome/browser/nearby_sharing/transfer_metadata.h
++++ b/chrome/browser/nearby_sharing/transfer_metadata.h
+@@ -40,6 +40,8 @@ class TransferMetadata {
+ bool is_original,
+ bool is_final_status);
+ ~TransferMetadata();
++ TransferMetadata(const TransferMetadata&);
++ TransferMetadata& operator=(const TransferMetadata&);
+
+ Status status() { return status_; }
+ float progress() { return progress_; }
+diff --git a/chrome/browser/nearby_sharing/transfer_update_callback.h b/chrome/browser/nearby_sharing/transfer_update_callback.h
+index be8a64102c91..3d582bd50d62 100644
+--- a/chrome/browser/nearby_sharing/transfer_update_callback.h
++++ b/chrome/browser/nearby_sharing/transfer_update_callback.h
+@@ -12,8 +12,8 @@
+ // Reports the transfer status for an ongoing transfer with a |ShareTarget|.
+ class TransferUpdateCallback : public base::CheckedObserver {
+ public:
+- virtual void OnTransferUpdate(ShareTarget shareTarget,
+- TransferMetadata transferMetadata) = 0;
++ virtual void OnTransferUpdate(const ShareTarget& shareTarget,
++ const TransferMetadata& transferMetadata) = 0;
+ };
+
+ #endif // CHROME_BROWSER_NEARBY_SHARING_TRANSFER_UPDATE_CALLBACK_H_
+diff --git a/chrome/test/BUILD.gn b/chrome/test/BUILD.gn
+index 23dbec40c39e..b33a418e2ad6 100644
+--- a/chrome/test/BUILD.gn
++++ b/chrome/test/BUILD.gn
+@@ -4366,6 +4366,7 @@ test("unit_tests") {
+ "//components/sync:test_support",
+ "//services/metrics/public/cpp:ukm_builders",
+ "//third_party/libaddressinput",
++ "//ui/base/idle:test_support",
+ "//ui/native_theme:test_support",
+ ]
+ if (is_win) {
+--
+2.26.2
+
diff --git a/chromium/chromium/chromium-gcc10-r785727.patch b/chromium/chromium/chromium-gcc10-r785727.patch
new file mode 100644
index 0000000..61344f4
--- /dev/null
+++ b/chromium/chromium/chromium-gcc10-r785727.patch
@@ -0,0 +1,34 @@
+From ad1493ec8f5287c5cd10dcb50b741359f7858349 Mon Sep 17 00:00:00 2001
+From: Jose Dapena Paz <jdapena@igalia.com>
+Date: Tue, 7 Jul 2020 14:43:40 +0000
+Subject: [PATCH] IWYU: int8_t used in nearby share encrypted metadata key
+ requires cstdint
+MIME-Version: 1.0
+Content-Type: text/plain; charset=UTF-8
+Content-Transfer-Encoding: 8bit
+
+Bug: 819294
+Change-Id: I90f88cf35e85a8a0ab1811e5533347d329365b21
+Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2283508
+Reviewed-by: Alex Chau <alexchau@chromium.org>
+Commit-Queue: José Dapena Paz <jdapena@igalia.com>
+Cr-Commit-Position: refs/heads/master@{#785727}
+---
+ .../certificates/nearby_share_encrypted_metadata_key.h | 1 +
+ 1 file changed, 1 insertion(+)
+
+diff --git a/chrome/browser/nearby_sharing/certificates/nearby_share_encrypted_metadata_key.h b/chrome/browser/nearby_sharing/certificates/nearby_share_encrypted_metadata_key.h
+index 2893bdeef985..8e1758fb0e4e 100644
+--- a/chrome/browser/nearby_sharing/certificates/nearby_share_encrypted_metadata_key.h
++++ b/chrome/browser/nearby_sharing/certificates/nearby_share_encrypted_metadata_key.h
+@@ -5,6 +5,7 @@
+ #ifndef CHROME_BROWSER_NEARBY_SHARING_CERTIFICATES_NEARBY_SHARE_ENCRYPTED_METADATA_KEY_H_
+ #define CHROME_BROWSER_NEARBY_SHARING_CERTIFICATES_NEARBY_SHARE_ENCRYPTED_METADATA_KEY_H_
+
++#include <cstdint>
+ #include <vector>
+
+ // Holds the encrypted symmetric key--the key used to encrypt user/device
+--
+2.26.2
+
diff --git a/chromium/chromium/chromium-gcc10-r785770.patch b/chromium/chromium/chromium-gcc10-r785770.patch
new file mode 100644
index 0000000..49ea7ab
--- /dev/null
+++ b/chromium/chromium/chromium-gcc10-r785770.patch
@@ -0,0 +1,39 @@
+From 051a6f6f3fe71602d4c13aa8f3cda40cd3c7484d Mon Sep 17 00:00:00 2001
+From: Jose Dapena Paz <jdapena@igalia.com>
+Date: Tue, 7 Jul 2020 16:10:14 +0000
+Subject: [PATCH] fixup: SIMD for main loop of a-rate DelayNode
+MIME-Version: 1.0
+Content-Type: text/plain; charset=UTF-8
+Content-Transfer-Encoding: 8bit
+
+Similar to previous fix to oscillator node. In GCC, an implicit cast to
+m128i of the result of mm_cmplt_ps is not valid. In this case, as the
+next usage of the return value is already an m128, we just change the
+type of the return value to m128 too.
+
+Bug: 819294
+Change-Id: I9ae9103a837920a5bfe432d7c81930bb4a5fce78
+Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2283211
+Reviewed-by: Raymond Toy <rtoy@chromium.org>
+Commit-Queue: José Dapena Paz <jdapena@igalia.com>
+Cr-Commit-Position: refs/heads/master@{#785770}
+---
+ .../blink/renderer/platform/audio/audio_delay_dsp_kernel.cc | 2 +-
+ 1 file changed, 1 insertion(+), 1 deletion(-)
+
+diff --git a/third_party/blink/renderer/platform/audio/audio_delay_dsp_kernel.cc b/third_party/blink/renderer/platform/audio/audio_delay_dsp_kernel.cc
+index 6d26a4d9932a..7b244a65568d 100644
+--- a/third_party/blink/renderer/platform/audio/audio_delay_dsp_kernel.cc
++++ b/third_party/blink/renderer/platform/audio/audio_delay_dsp_kernel.cc
+@@ -142,7 +142,7 @@ static ALWAYS_INLINE __m128 WrapPositionVector(__m128 v_position,
+ // Wrap the read position if it exceed the buffer length.
+
+ // If buffer length < read_position, set cmp to 0xffffffff. Otherwise zero.
+- __m128i cmp = _mm_cmplt_ps(v_buffer_length, v_position);
++ __m128 cmp = _mm_cmplt_ps(v_buffer_length, v_position);
+
+ // Bitwise and buffer_length with cmp to get buffer_length or 0 depending on
+ // whether read_position >= buffer length or not. Then subtract from the
+--
+2.26.2
+
diff --git a/chromium/chromium/chromium-gcc10-r785771.patch b/chromium/chromium/chromium-gcc10-r785771.patch
new file mode 100644
index 0000000..477734c
--- /dev/null
+++ b/chromium/chromium/chromium-gcc10-r785771.patch
@@ -0,0 +1,45 @@
+From 3101c190bc55cb6ff7208652d0883566a3e00799 Mon Sep 17 00:00:00 2001
+From: Jose Dapena Paz <jdapena@igalia.com>
+Date: Tue, 7 Jul 2020 16:12:08 +0000
+Subject: [PATCH] fixup: do not return to 128 integer word from _mm_cmplt_ps in
+ v_wrap_virtual_index.
+MIME-Version: 1.0
+Content-Type: text/plain; charset=UTF-8
+Content-Transfer-Encoding: 8bit
+
+After the changes to convert to SIMD several operations in
+WebAudio oscillator node, GCC refuses to compile a call to _mm_cmplt_ps
+since we try to store it in m128i, but mm_cmplt_ps returns an m128.
+
+To fix that, we reinterpret_cast<__m128i>, as that's how we want to
+interpret the bits.
+
+Verified with webaudio/Oscillator/* web tests.
+
+Bug: 819294
+Change-Id: Ia00a7695476e84996548b6c679ffeedead49213b
+Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2247792
+Reviewed-by: Raymond Toy <rtoy@chromium.org>
+Commit-Queue: José Dapena Paz <jdapena@igalia.com>
+Cr-Commit-Position: refs/heads/master@{#785771}
+---
+ third_party/blink/renderer/modules/webaudio/oscillator_node.cc | 3 ++-
+ 1 file changed, 2 insertions(+), 1 deletion(-)
+
+diff --git a/third_party/blink/renderer/modules/webaudio/oscillator_node.cc b/third_party/blink/renderer/modules/webaudio/oscillator_node.cc
+index 08f20fc022a8..71671affd8dc 100644
+--- a/third_party/blink/renderer/modules/webaudio/oscillator_node.cc
++++ b/third_party/blink/renderer/modules/webaudio/oscillator_node.cc
+@@ -377,7 +377,8 @@ static __m128 v_wrap_virtual_index(__m128 x,
+
+ // cmplt(a,b) returns 0xffffffff (-1) if a < b and 0 if not. So cmp is -1 or
+ // 0 depending on whether r < f, which is what we need to compute floor(r).
+- const __m128i cmp = _mm_cmplt_ps(r, _mm_cvtepi32_ps(f));
++ const __m128i cmp =
++ reinterpret_cast<__m128i>(_mm_cmplt_ps(r, _mm_cvtepi32_ps(f)));
+
+ // This subtracts 1 if needed to get floor(r).
+ f = _mm_add_epi32(f, cmp);
+--
+2.26.2
+
diff --git a/chromium/chromium/chromium-gcc10-ui.patch b/chromium/chromium/chromium-gcc10-ui.patch
deleted file mode 100644
index d643663..0000000
--- a/chromium/chromium/chromium-gcc10-ui.patch
+++ /dev/null
@@ -1,13 +0,0 @@
-diff --git a/ui/gfx/linux/drm_util_linux.h b/ui/gfx/linux/drm_util_linux.h
-index 86ff2eb..990f12c 100644
---- a/ui/gfx/linux/drm_util_linux.h
-+++ b/ui/gfx/linux/drm_util_linux.h
-@@ -7,6 +7,8 @@
-
- #include "ui/gfx/buffer_types.h"
-
-+#include <cstdint>
-+
- namespace ui {
-
- int GetFourCCFormatFromBufferFormat(gfx::BufferFormat format);
diff --git a/chromium/chromium/chromium-gcc9-r772175.patch b/chromium/chromium/chromium-gcc9-r772175.patch
deleted file mode 100644
index 3ebbb98..0000000
--- a/chromium/chromium/chromium-gcc9-r772175.patch
+++ /dev/null
@@ -1,76 +0,0 @@
-From 911bdcd8cc5475be4ec4228cfbc85fc38f52857e Mon Sep 17 00:00:00 2001
-From: Stephan Hartmann <stha09@googlemail.com>
-Date: Wed, 27 May 2020 10:00:41 +0000
-Subject: [PATCH] GCC: make base::{flat_map,flat_tree} move assignement
- operators noexcept
-MIME-Version: 1.0
-Content-Type: text/plain; charset=UTF-8
-Content-Transfer-Encoding: 8bit
-
-Move assigment operator in ui::ColorSet is noexcept. Because this
-class has a member of type base::flat_map, move assignment operators
-of base::flat_map and base::flat_tree must be noexcept too.
-base::flat_tree noexcept is conditional to avoid build failure with
-NaCl.
-
-Otherwise GCC fails like this:
-
-../../ui/color/color_set.cc:14:11: error: function
-'ui::ColorSet& ui::ColorSet::operator=(ui::ColorSet&&)' defaulted on its
-redeclaration with an exception-specification that differs from the
-implicit exception-specification ''
- 14 | ColorSet& ColorSet::operator=(ColorSet&&) noexcept = default;
- | ^~~~~~~~
-
-Bug: 819294
-Change-Id: I10ce31851effc9ce78f2b5cbbb7148c339f065a7
-Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2179245
-Commit-Queue: Jan Wilken Dörrie <jdoerrie@chromium.org>
-Reviewed-by: Daniel Cheng <dcheng@chromium.org>
-Cr-Commit-Position: refs/heads/master@{#772175}
----
- base/containers/flat_map.h | 2 +-
- base/containers/flat_tree.h | 7 +++++--
- 2 files changed, 6 insertions(+), 3 deletions(-)
-
-diff --git a/base/containers/flat_map.h b/base/containers/flat_map.h
-index ed82c5d516c8..1af6b407a52d 100644
---- a/base/containers/flat_map.h
-+++ b/base/containers/flat_map.h
-@@ -202,7 +202,7 @@ class flat_map : public ::base::internal::flat_tree<
- ~flat_map() = default;
-
- flat_map& operator=(const flat_map&) = default;
-- flat_map& operator=(flat_map&&) = default;
-+ flat_map& operator=(flat_map&&) noexcept = default;
- // Takes the first if there are duplicates in the initializer list.
- flat_map& operator=(std::initializer_list<value_type> ilist);
-
-diff --git a/base/containers/flat_tree.h b/base/containers/flat_tree.h
-index 9412ff6af749..ce6e92b4d363 100644
---- a/base/containers/flat_tree.h
-+++ b/base/containers/flat_tree.h
-@@ -125,7 +125,8 @@ class flat_tree {
- // Assume that move assignment invalidates iterators and references.
-
- flat_tree& operator=(const flat_tree&);
-- flat_tree& operator=(flat_tree&&);
-+ flat_tree& operator=(flat_tree&&) noexcept(
-+ std::is_nothrow_move_assignable<underlying_type>::value);
- // Takes the first if there are duplicates in the initializer list.
- flat_tree& operator=(std::initializer_list<value_type> ilist);
-
-@@ -518,7 +519,9 @@ auto flat_tree<Key, Value, GetKeyFromValue, KeyCompare>::operator=(
- const flat_tree&) -> flat_tree& = default;
-
- template <class Key, class Value, class GetKeyFromValue, class KeyCompare>
--auto flat_tree<Key, Value, GetKeyFromValue, KeyCompare>::operator=(flat_tree &&)
-+auto flat_tree<Key, Value, GetKeyFromValue, KeyCompare>::
-+operator=(flat_tree&&) noexcept(
-+ std::is_nothrow_move_assignable<underlying_type>::value)
- -> flat_tree& = default;
-
- template <class Key, class Value, class GetKeyFromValue, class KeyCompare>
---
-2.26.2
-
diff --git a/chromium/chromium/chromium-gcc9-r772348.patch b/chromium/chromium/chromium-gcc9-r772348.patch
deleted file mode 100644
index 06f9b42..0000000
--- a/chromium/chromium/chromium-gcc9-r772348.patch
+++ /dev/null
@@ -1,61 +0,0 @@
-From c65b4d03c76da607b6b678c4a46baa75ca0cf7b3 Mon Sep 17 00:00:00 2001
-From: Stephan Hartmann <stha09@googlemail.com>
-Date: Wed, 27 May 2020 18:46:40 +0000
-Subject: [PATCH] GCC: make base::FilePath move assignment operator noexcept
-
-The move assignment operator in PaintPreviewClient::PaintPreviewData is
-noexcept. Because this class has a member of type base::FilePath, the
-move assignment operator of base::FilePath must be noexcept too.
-
-Otherwise GCC fails like this:
-
-../../components/paint_preview/browser/paint_preview_client.cc:107:1:
-
-error: function 'paint_preview::PaintPreviewClient::PaintPreviewData&
-paint_preview::PaintPreviewClient::PaintPreviewData::operator=
-(paint_preview::PaintPreviewClient::PaintPreviewData&&)' defaulted on
-its redeclaration with an exception-specification that differs from
-the implicit exception-specification ''
- 107 | PaintPreviewClient::PaintPreviewData::operator=(
- | ^~~~~~~~~~~~~~~~~~
-
-Bug: 819294
-Change-Id: I87b88a81e8af6b7e61f0d1a8c8444fd6707e50d2
-Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2218168
-Commit-Queue: Lei Zhang <thestig@chromium.org>
-Reviewed-by: Lei Zhang <thestig@chromium.org>
-Cr-Commit-Position: refs/heads/master@{#772348}
----
- base/files/file_path.cc | 2 +-
- base/files/file_path.h | 2 +-
- 2 files changed, 2 insertions(+), 2 deletions(-)
-
-diff --git a/base/files/file_path.cc b/base/files/file_path.cc
-index 6dc68540e9af..56c02d2bfc7c 100644
---- a/base/files/file_path.cc
-+++ b/base/files/file_path.cc
-@@ -186,7 +186,7 @@ FilePath::~FilePath() = default;
-
- FilePath& FilePath::operator=(const FilePath& that) = default;
-
--FilePath& FilePath::operator=(FilePath&& that) = default;
-+FilePath& FilePath::operator=(FilePath&& that) noexcept = default;
-
- bool FilePath::operator==(const FilePath& that) const {
- #if defined(FILE_PATH_USES_DRIVE_LETTERS)
-diff --git a/base/files/file_path.h b/base/files/file_path.h
-index 4e23f71a92aa..2160fdaca31d 100644
---- a/base/files/file_path.h
-+++ b/base/files/file_path.h
-@@ -193,7 +193,7 @@ class BASE_EXPORT FilePath {
- FilePath(FilePath&& that) noexcept;
- // Replaces the contents with those of |that|, which is left in valid but
- // unspecified state.
-- FilePath& operator=(FilePath&& that);
-+ FilePath& operator=(FilePath&& that) noexcept;
-
- bool operator==(const FilePath& that) const;
-
---
-2.26.2
-
diff --git a/chromium/chromium/chromium-gcc9-ui.patch b/chromium/chromium/chromium-gcc9-ui.patch
deleted file mode 100644
index 1c7de53..0000000
--- a/chromium/chromium/chromium-gcc9-ui.patch
+++ /dev/null
@@ -1,35 +0,0 @@
-diff --git a/ui/color/color_set.cc b/ui/color/color_set.cc
-index 56564d7..2798a3c 100644
---- a/ui/color/color_set.cc
-+++ b/ui/color/color_set.cc
-@@ -11,7 +11,7 @@ ColorSet::ColorSet(ColorSetId id, ColorMap&& colors)
-
- ColorSet::ColorSet(ColorSet&&) noexcept = default;
-
--ColorSet& ColorSet::operator=(ColorSet&&) noexcept = default;
-+ColorSet& ColorSet::operator=(ColorSet&&) = default;
-
- ColorSet::~ColorSet() = default;
-
-diff --git a/third_party/blink/public/platform/cross_variant_mojo_util.h b/third_party/blink/public/platform/cross_variant_mojo_util.h
-index dee0b95..0c83580 100644
---- a/third_party/blink/public/platform/cross_variant_mojo_util.h
-+++ b/third_party/blink/public/platform/cross_variant_mojo_util.h
-@@ -124,7 +124,7 @@ class CrossVariantMojoAssociatedReceiver {
- ~CrossVariantMojoAssociatedReceiver() = default;
-
- CrossVariantMojoAssociatedReceiver(
-- CrossVariantMojoAssociatedReceiver&&) noexcept = default;
-+ CrossVariantMojoAssociatedReceiver&&) = default;
- CrossVariantMojoAssociatedReceiver& operator=(
- CrossVariantMojoAssociatedReceiver&&) noexcept = default;
-
-@@ -155,7 +155,7 @@ class CrossVariantMojoAssociatedRemote {
- ~CrossVariantMojoAssociatedRemote() = default;
-
- CrossVariantMojoAssociatedRemote(
-- CrossVariantMojoAssociatedRemote&&) noexcept = default;
-+ CrossVariantMojoAssociatedRemote&&) = default;
- CrossVariantMojoAssociatedRemote& operator=(
- CrossVariantMojoAssociatedRemote&&) noexcept = default;
-
diff --git a/chromium/chromium/chromium-gen-xproto-python3.patch b/chromium/chromium/chromium-gen-xproto-python3.patch
deleted file mode 100644
index 8516d26..0000000
--- a/chromium/chromium/chromium-gen-xproto-python3.patch
+++ /dev/null
@@ -1,28 +0,0 @@
-diff --git a/ui/gfx/x/gen_xproto.py b/ui/gfx/x/gen_xproto.py
-index 4a34901012d9..509f22c1f4e2 100644
---- a/ui/gfx/x/gen_xproto.py
-+++ b/ui/gfx/x/gen_xproto.py
-@@ -168,6 +168,7 @@ from __future__ import print_function
-
- import argparse
- import collections
-+import functools
- import os
- import re
- import sys
-@@ -919,11 +920,13 @@ class GenXproto:
- return 3
- return 2
-
-- def cmp((_1, item1), (_2, item2)):
-+ def cmp(arg1, arg2):
-+ (_1, item1) = arg1
-+ (_2, item2) = arg2
- return type_order_priority(item1) - type_order_priority(item2)
-
- # sort() is guaranteed to be stable.
-- self.module.all.sort(cmp=cmp)
-+ self.module.all.sort(key=functools.cmp_to_key(cmp))
-
- def gen_header(self):
- self.file = self.args.headerfile
diff --git a/chromium/chromium/chromium-revert-manage-ManifestManagerHost-per-document.patch b/chromium/chromium/chromium-revert-manage-ManifestManagerHost-per-document.patch
deleted file mode 100644
index b65f30a..0000000
--- a/chromium/chromium/chromium-revert-manage-ManifestManagerHost-per-document.patch
+++ /dev/null
@@ -1,396 +0,0 @@
-From a7138cc22fab2a7be7271361ae2351ca7872f634 Mon Sep 17 00:00:00 2001
-From: Ting-Wei Lan <lantw44@gmail.com>
-Date: Sun, 26 Jul 2020 14:54:31 +0800
-Subject: [PATCH] Revert "[content] Manage ManifestManagerHost per-document"
-
-This reverts commit fce18322d66ea6e67275e13242dae2a8c06d3ae2.
-
-This changes was copied from https://github.com/stha09/chromium-patches
-in order to fix segfault caused by stack overflow.
-
-https://bugs.chromium.org/p/chromium/issues/detail?id=1085953
----
- .../browser/devtools/protocol/page_handler.cc | 10 ++--
- ...der_document_host_user_data_browsertest.cc | 12 ++---
- .../frame_host/render_frame_host_impl.cc | 10 ----
- .../frame_host/render_frame_host_impl.h | 4 --
- .../browser/manifest/manifest_manager_host.cc | 47 +++++++------------
- .../browser/manifest/manifest_manager_host.h | 31 +++++-------
- .../browser/web_contents/web_contents_impl.cc | 7 ++-
- .../browser/web_contents/web_contents_impl.h | 7 +++
- .../browser/render_document_host_user_data.cc | 4 --
- .../browser/render_document_host_user_data.h | 9 ----
- 10 files changed, 47 insertions(+), 94 deletions(-)
-
-diff --git a/content/browser/devtools/protocol/page_handler.cc b/content/browser/devtools/protocol/page_handler.cc
-index b1821434b975..929b63ab875e 100644
---- a/content/browser/devtools/protocol/page_handler.cc
-+++ b/content/browser/devtools/protocol/page_handler.cc
-@@ -961,14 +961,14 @@ Response PageHandler::SetDownloadBehavior(const std::string& behavior,
-
- void PageHandler::GetAppManifest(
- std::unique_ptr<GetAppManifestCallback> callback) {
-- if (!host_) {
-+ WebContentsImpl* web_contents = GetWebContents();
-+ if (!web_contents || !web_contents->GetManifestManagerHost()) {
- callback->sendFailure(Response::ServerError("Cannot retrieve manifest"));
- return;
- }
-- ManifestManagerHost::GetOrCreateForCurrentDocument(host_->GetMainFrame())
-- ->RequestManifestDebugInfo(base::BindOnce(&PageHandler::GotManifest,
-- weak_factory_.GetWeakPtr(),
-- std::move(callback)));
-+ web_contents->GetManifestManagerHost()->RequestManifestDebugInfo(
-+ base::BindOnce(&PageHandler::GotManifest, weak_factory_.GetWeakPtr(),
-+ std::move(callback)));
- }
-
- WebContentsImpl* PageHandler::GetWebContents() {
-diff --git a/content/browser/frame_host/render_document_host_user_data_browsertest.cc b/content/browser/frame_host/render_document_host_user_data_browsertest.cc
-index 09dff7842517..290e5509b448 100644
---- a/content/browser/frame_host/render_document_host_user_data_browsertest.cc
-+++ b/content/browser/frame_host/render_document_host_user_data_browsertest.cc
-@@ -88,7 +88,7 @@ class RenderDocumentHostUserDataTest : public ContentBrowserTest {
-
- // Test basic functionality of RenderDocumentHostUserData.
- IN_PROC_BROWSER_TEST_F(RenderDocumentHostUserDataTest,
-- GetCreateAndDeleteForCurrentDocument) {
-+ GetAndCreateForCurrentDocument) {
- ASSERT_TRUE(embedded_test_server()->Start());
- GURL url_a(embedded_test_server()->GetURL("a.com", "/title1.html"));
-
-@@ -104,14 +104,8 @@ IN_PROC_BROWSER_TEST_F(RenderDocumentHostUserDataTest,
- // 3) Create Data and check that GetForCurrentDocument shouldn't return null
- // now.
- Data::CreateForCurrentDocument(rfh_a);
-- base::WeakPtr<Data> created_data =
-- Data::GetForCurrentDocument(rfh_a)->GetWeakPtr();
-- EXPECT_TRUE(created_data);
--
-- // 4) Delete Data and check that GetForCurrentDocument should return null.
-- Data::DeleteForCurrentDocument(rfh_a);
-- EXPECT_FALSE(created_data);
-- EXPECT_FALSE(Data::GetForCurrentDocument(rfh_a));
-+ data = Data::GetForCurrentDocument(rfh_a);
-+ EXPECT_TRUE(data);
- }
-
- // Tests that RenderDocumentHostUserData objects are different for each
-diff --git a/content/browser/frame_host/render_frame_host_impl.cc b/content/browser/frame_host/render_frame_host_impl.cc
-index 115673d129dc..67735d7a859a 100644
---- a/content/browser/frame_host/render_frame_host_impl.cc
-+++ b/content/browser/frame_host/render_frame_host_impl.cc
-@@ -75,7 +75,6 @@
- #include "content/browser/loader/navigation_url_loader_impl.h"
- #include "content/browser/loader/prefetch_url_loader_service.h"
- #include "content/browser/log_console_message.h"
--#include "content/browser/manifest/manifest_manager_host.h"
- #include "content/browser/media/capture/audio_mirroring_manager.h"
- #include "content/browser/media/media_interface_proxy.h"
- #include "content/browser/media/webaudio/audio_context_manager_impl.h"
-@@ -6155,15 +6154,6 @@ void RenderFrameHostImpl::SetUpMojoIfNeeded() {
- std::make_unique<ActiveURLMessageFilter>(impl));
- },
- base::Unretained(this)));
--
-- associated_registry_->AddInterface(base::BindRepeating(
-- [](RenderFrameHostImpl* impl,
-- mojo::PendingAssociatedReceiver<
-- blink::mojom::ManifestUrlChangeObserver> receiver) {
-- ManifestManagerHost::GetOrCreateForCurrentDocument(impl)
-- ->BindObserver(std::move(receiver));
-- },
-- base::Unretained(this)));
- }
-
- associated_registry_->AddInterface(base::BindRepeating(
-diff --git a/content/browser/frame_host/render_frame_host_impl.h b/content/browser/frame_host/render_frame_host_impl.h
-index 513fca6f8619..98171ec5989a 100644
---- a/content/browser/frame_host/render_frame_host_impl.h
-+++ b/content/browser/frame_host/render_frame_host_impl.h
-@@ -1596,10 +1596,6 @@ class CONTENT_EXPORT RenderFrameHostImpl
- document_associated_data_.SetUserData(key, std::move(data));
- }
-
-- void RemoveRenderDocumentHostUserData(const void* key) {
-- document_associated_data_.RemoveUserData(key);
-- }
--
- // Returns the child RenderFrameHostImpl if |child_frame_routing_id| is an
- // immediate child of this FrameTreeNode. |child_frame_routing_id| is
- // considered untrusted, so the renderer process is killed if it refers to a
-diff --git a/content/browser/manifest/manifest_manager_host.cc b/content/browser/manifest/manifest_manager_host.cc
-index 68ea016c62eb..b063e0d1e98e 100644
---- a/content/browser/manifest/manifest_manager_host.cc
-+++ b/content/browser/manifest/manifest_manager_host.cc
-@@ -9,34 +9,25 @@
- #include "base/bind.h"
- #include "content/browser/web_contents/web_contents_impl.h"
- #include "content/public/browser/render_frame_host.h"
-+#include "content/public/browser/web_contents.h"
- #include "services/service_manager/public/cpp/interface_provider.h"
- #include "third_party/blink/public/common/associated_interfaces/associated_interface_provider.h"
- #include "third_party/blink/public/common/manifest/manifest.h"
-
- namespace content {
-
--ManifestManagerHost::ManifestManagerHost(RenderFrameHost* render_frame_host)
-- : manifest_manager_frame_(render_frame_host) {
-- // Check that |manifest_manager_frame_| is a main frame.
-- DCHECK(!manifest_manager_frame_->GetParent());
--}
-+ManifestManagerHost::ManifestManagerHost(WebContents* web_contents)
-+ : WebContentsObserver(web_contents),
-+ manifest_url_change_observer_receivers_(web_contents, this) {}
-
- ManifestManagerHost::~ManifestManagerHost() {
- OnConnectionError();
- }
-
--void ManifestManagerHost::BindObserver(
-- mojo::PendingAssociatedReceiver<blink::mojom::ManifestUrlChangeObserver>
-- receiver) {
-- manifest_url_change_observer_receiver_.Bind(std::move(receiver));
--}
--
--ManifestManagerHost* ManifestManagerHost::GetOrCreateForCurrentDocument(
-- RenderFrameHostImpl* rfh) {
-- DCHECK(rfh->is_main_frame());
-- if (!GetForCurrentDocument(rfh))
-- CreateForCurrentDocument(rfh);
-- return GetForCurrentDocument(rfh);
-+void ManifestManagerHost::RenderFrameDeleted(
-+ RenderFrameHost* render_frame_host) {
-+ if (render_frame_host == manifest_manager_frame_)
-+ OnConnectionError();
- }
-
- void ManifestManagerHost::GetManifest(GetManifestCallback callback) {
-@@ -54,7 +45,11 @@ void ManifestManagerHost::RequestManifestDebugInfo(
- }
-
- blink::mojom::ManifestManager& ManifestManagerHost::GetManifestManager() {
-+ if (manifest_manager_frame_ != web_contents()->GetMainFrame())
-+ OnConnectionError();
-+
- if (!manifest_manager_) {
-+ manifest_manager_frame_ = web_contents()->GetMainFrame();
- manifest_manager_frame_->GetRemoteInterfaces()->GetInterface(
- manifest_manager_.BindNewPipeAndPassReceiver());
- manifest_manager_.set_disconnect_handler(base::BindOnce(
-@@ -64,6 +59,8 @@ blink::mojom::ManifestManager& ManifestManagerHost::GetManifestManager() {
- }
-
- void ManifestManagerHost::OnConnectionError() {
-+ manifest_manager_frame_ = nullptr;
-+ manifest_manager_.reset();
- std::vector<GetManifestCallback> callbacks;
- for (CallbackMap::iterator it(&callbacks_); !it.IsAtEnd(); it.Advance()) {
- callbacks.push_back(std::move(*it.GetCurrentValue()));
-@@ -71,10 +68,6 @@ void ManifestManagerHost::OnConnectionError() {
- callbacks_.Clear();
- for (auto& callback : callbacks)
- std::move(callback).Run(GURL(), blink::Manifest());
--
-- if (GetForCurrentDocument(manifest_manager_frame_)) {
-- DeleteForCurrentDocument(manifest_manager_frame_);
-- }
- }
-
- void ManifestManagerHost::OnRequestManifestResponse(
-@@ -88,16 +81,12 @@ void ManifestManagerHost::OnRequestManifestResponse(
-
- void ManifestManagerHost::ManifestUrlChanged(
- const base::Optional<GURL>& manifest_url) {
-- if (!manifest_manager_frame_->IsCurrent())
-+ if (manifest_url_change_observer_receivers_.GetCurrentTargetFrame() !=
-+ web_contents()->GetMainFrame()) {
- return;
--
-- // TODO(yuzus): |NotifyManifestUrlChanged| should start taking a
-- // |RenderFrameHost| parameter.
-- WebContents* web_contents =
-- WebContents::FromRenderFrameHost(manifest_manager_frame_);
-- static_cast<WebContentsImpl*>(web_contents)
-+ }
-+ static_cast<WebContentsImpl*>(web_contents())
- ->NotifyManifestUrlChanged(manifest_url);
- }
-
--RENDER_DOCUMENT_HOST_USER_DATA_KEY_IMPL(ManifestManagerHost)
- } // namespace content
-diff --git a/content/browser/manifest/manifest_manager_host.h b/content/browser/manifest/manifest_manager_host.h
-index 57f51dc9fad7..3dc0bbf6e1ad 100644
---- a/content/browser/manifest/manifest_manager_host.h
-+++ b/content/browser/manifest/manifest_manager_host.h
-@@ -8,8 +8,8 @@
- #include "base/callback_forward.h"
- #include "base/containers/id_map.h"
- #include "base/macros.h"
--#include "content/public/browser/render_document_host_user_data.h"
--#include "mojo/public/cpp/bindings/associated_receiver.h"
-+#include "content/public/browser/web_contents_observer.h"
-+#include "content/public/browser/web_contents_receiver_set.h"
- #include "mojo/public/cpp/bindings/remote.h"
- #include "third_party/blink/public/mojom/manifest/manifest_manager.mojom.h"
- #include "third_party/blink/public/mojom/manifest/manifest_observer.mojom.h"
-@@ -21,16 +21,16 @@ struct Manifest;
- namespace content {
-
- class RenderFrameHost;
--class RenderFrameHostImpl;
-+class WebContents;
-
- // ManifestManagerHost is a helper class that allows callers to get the Manifest
- // associated with the main frame of the observed WebContents. It handles the
- // IPC messaging with the child process.
- // TODO(mlamouri): keep a cached version and a dirty bit here.
--class ManifestManagerHost
-- : public RenderDocumentHostUserData<ManifestManagerHost>,
-- public blink::mojom::ManifestUrlChangeObserver {
-+class ManifestManagerHost : public WebContentsObserver,
-+ public blink::mojom::ManifestUrlChangeObserver {
- public:
-+ explicit ManifestManagerHost(WebContents* web_contents);
- ~ManifestManagerHost() override;
-
- using GetManifestCallback =
-@@ -44,18 +44,10 @@ class ManifestManagerHost
- void RequestManifestDebugInfo(
- blink::mojom::ManifestManager::RequestManifestDebugInfoCallback callback);
-
-- void BindObserver(
-- mojo::PendingAssociatedReceiver<blink::mojom::ManifestUrlChangeObserver>
-- receiver);
--
-- static ManifestManagerHost* GetOrCreateForCurrentDocument(
-- RenderFrameHostImpl* rfh);
-+ // WebContentsObserver
-+ void RenderFrameDeleted(RenderFrameHost* render_frame_host) override;
-
- private:
-- explicit ManifestManagerHost(RenderFrameHost* render_frame_host);
--
-- friend class RenderDocumentHostUserData<ManifestManagerHost>;
--
- using CallbackMap = base::IDMap<std::unique_ptr<GetManifestCallback>>;
-
- blink::mojom::ManifestManager& GetManifestManager();
-@@ -68,14 +60,13 @@ class ManifestManagerHost
- // blink::mojom::ManifestUrlChangeObserver:
- void ManifestUrlChanged(const base::Optional<GURL>& manifest_url) override;
-
-- RenderFrameHost* manifest_manager_frame_;
-+ RenderFrameHost* manifest_manager_frame_ = nullptr;
- mojo::Remote<blink::mojom::ManifestManager> manifest_manager_;
- CallbackMap callbacks_;
-
-- mojo::AssociatedReceiver<blink::mojom::ManifestUrlChangeObserver>
-- manifest_url_change_observer_receiver_{this};
-+ WebContentsFrameReceiverSet<blink::mojom::ManifestUrlChangeObserver>
-+ manifest_url_change_observer_receivers_;
-
-- RENDER_DOCUMENT_HOST_USER_DATA_KEY_DECL();
- DISALLOW_COPY_AND_ASSIGN(ManifestManagerHost);
- };
-
-diff --git a/content/browser/web_contents/web_contents_impl.cc b/content/browser/web_contents/web_contents_impl.cc
-index 7908a60e1743..8615b19088df 100644
---- a/content/browser/web_contents/web_contents_impl.cc
-+++ b/content/browser/web_contents/web_contents_impl.cc
-@@ -2128,6 +2128,8 @@ void WebContentsImpl::Init(const WebContents::CreateParams& params) {
-
- screen_orientation_provider_.reset(new ScreenOrientationProvider(this));
-
-+ manifest_manager_host_.reset(new ManifestManagerHost(this));
-+
- #if defined(OS_ANDROID)
- DateTimeChooserAndroid::CreateForWebContents(this);
- #endif
-@@ -4208,10 +4210,7 @@ bool WebContentsImpl::WasEverAudible() {
- }
-
- void WebContentsImpl::GetManifest(GetManifestCallback callback) {
-- // TODO(yuzus, 1061899): Move this function to RenderFrameHostImpl.
-- ManifestManagerHost* manifest_manager_host =
-- ManifestManagerHost::GetOrCreateForCurrentDocument(GetMainFrame());
-- manifest_manager_host->GetManifest(std::move(callback));
-+ manifest_manager_host_->GetManifest(std::move(callback));
- }
-
- void WebContentsImpl::ExitFullscreen(bool will_cause_resize) {
-diff --git a/content/browser/web_contents/web_contents_impl.h b/content/browser/web_contents/web_contents_impl.h
-index 29125641f892..cf43c7b1ebb2 100644
---- a/content/browser/web_contents/web_contents_impl.h
-+++ b/content/browser/web_contents/web_contents_impl.h
-@@ -102,6 +102,7 @@ class DisplayCutoutHostImpl;
- class FindRequestManager;
- class JavaScriptDialogManager;
- class JavaScriptDialogNavigationDeferrer;
-+class ManifestManagerHost;
- class MediaWebContentsObserver;
- class NFCHost;
- class PluginContentOriginAllowlist;
-@@ -311,6 +312,10 @@ class CONTENT_EXPORT WebContentsImpl : public WebContents,
-
- void NotifyManifestUrlChanged(const base::Optional<GURL>& manifest_url);
-
-+ ManifestManagerHost* GetManifestManagerHost() const {
-+ return manifest_manager_host_.get();
-+ }
-+
- #if defined(OS_ANDROID)
- void SetMainFrameImportance(ChildProcessImportance importance);
- #endif
-@@ -1895,6 +1900,8 @@ class CONTENT_EXPORT WebContentsImpl : public WebContents,
-
- std::unique_ptr<ScreenOrientationProvider> screen_orientation_provider_;
-
-+ std::unique_ptr<ManifestManagerHost> manifest_manager_host_;
-+
- // The accessibility mode for all frames. This is queried when each frame
- // is created, and broadcast to all frames when it changes.
- ui::AXMode accessibility_mode_;
-diff --git a/content/public/browser/render_document_host_user_data.cc b/content/public/browser/render_document_host_user_data.cc
-index 3b58bf8a3c5e..b1b385455e61 100644
---- a/content/public/browser/render_document_host_user_data.cc
-+++ b/content/public/browser/render_document_host_user_data.cc
-@@ -23,8 +23,4 @@ void SetRenderDocumentHostUserData(
- key, std::move(data));
- }
-
--void RemoveRenderDocumentHostUserData(RenderFrameHost* rfh, const void* key) {
-- static_cast<RenderFrameHostImpl*>(rfh)->RemoveRenderDocumentHostUserData(key);
--}
--
- } // namespace content
-diff --git a/content/public/browser/render_document_host_user_data.h b/content/public/browser/render_document_host_user_data.h
-index a138fd60aa2a..f55f24f60992 100644
---- a/content/public/browser/render_document_host_user_data.h
-+++ b/content/public/browser/render_document_host_user_data.h
-@@ -22,9 +22,6 @@ CONTENT_EXPORT void SetRenderDocumentHostUserData(
- const void* key,
- std::unique_ptr<base::SupportsUserData::Data> data);
-
--CONTENT_EXPORT void RemoveRenderDocumentHostUserData(RenderFrameHost* rfh,
-- const void* key);
--
- // This class approximates the lifetime of a single blink::Document in the
- // browser process. At the moment RenderFrameHost can correspond to multiple
- // blink::Documents (when RenderFrameHost is reused for same-process
-@@ -85,12 +82,6 @@ class RenderDocumentHostUserData : public base::SupportsUserData::Data {
- return static_cast<T*>(GetRenderDocumentHostUserData(rfh, UserDataKey()));
- }
-
-- static void DeleteForCurrentDocument(RenderFrameHost* rfh) {
-- DCHECK(rfh);
-- DCHECK(GetForCurrentDocument(rfh));
-- RemoveRenderDocumentHostUserData(rfh, UserDataKey());
-- }
--
- static const void* UserDataKey() { return &T::kUserDataKey; }
- };
-
---
-2.26.2
-
diff --git a/chromium/chromium/chromium-webrtc-gcc10.patch b/chromium/chromium/chromium-webrtc-gcc10.patch
deleted file mode 100644
index 53383e9..0000000
--- a/chromium/chromium/chromium-webrtc-gcc10.patch
+++ /dev/null
@@ -1,12 +0,0 @@
-diff --git a/third_party/webrtc/modules/audio_processing/aec3/clockdrift_detector.h b/third_party/webrtc/modules/audio_processing/aec3/clockdrift_detector.h
-index 22528c9..69e624e 100644
---- a/third_party/webrtc/modules/audio_processing/aec3/clockdrift_detector.h
-+++ b/third_party/webrtc/modules/audio_processing/aec3/clockdrift_detector.h
-@@ -12,6 +12,7 @@
- #define MODULES_AUDIO_PROCESSING_AEC3_CLOCKDRIFT_DETECTOR_H_
-
- #include <array>
-+#include <cstddef>
-
- namespace webrtc {
-
diff --git a/chromium/chromium/chromium.spec b/chromium/chromium/chromium.spec
index 4b223dd..7c55a57 100644
--- a/chromium/chromium/chromium.spec
+++ b/chromium/chromium/chromium.spec
@@ -51,7 +51,7 @@
%bcond_with fedora_compilation_flags
Name: chromium
-Version: 84.0.4147.135
+Version: 85.0.4183.83
Release: 100%{?dist}
Summary: A WebKit (Blink) powered web browser
@@ -97,9 +97,6 @@ Patch1: chromium-certificate-transparency-google.patch
# Don't require static libstdc++
Patch2: chromium-gn-no-static-libstdc++.patch
-# Make ui/gfx/x/gen_xproto.py compatible with Python 3
-Patch3: chromium-gen-xproto-python3.patch
-
# Don't use unversioned python commands. This patch is based on
# https://src.fedoraproject.org/rpms/chromium/c/7048e95ab61cd143
# https://src.fedoraproject.org/rpms/chromium/c/cb0be2c990fc724e
@@ -111,32 +108,18 @@ Patch30: chromium-webrtc-cstring.patch
# Pull patches from Gentoo
# https://gitweb.gentoo.org/repo/gentoo.git/commit/?id=5b7b57438d399738
-# https://gitweb.gentoo.org/repo/gentoo.git/commit/?id=68ee7ce691b80d8a
-# https://gitweb.gentoo.org/repo/gentoo.git/commit/?id=adb8703f3e0af990
-# https://gitweb.gentoo.org/repo/gentoo.git/commit/?id=74bedae1b414b74f
-Patch41: chromium-base-location.patch
-Patch43: chromium-gcc10-chrome.patch
-Patch44: chromium-gcc10-ui.patch
-Patch45: chromium-webrtc-gcc10.patch
-Patch46: chromium-gcc10-content.patch
-Patch47: chromium-gcc9-ui.patch
-Patch48: chromium-revert-manage-ManifestManagerHost-per-document.patch
+Patch40: chromium-base-location.patch
# Pull upstream patches
Patch50: chromium-quiche-gcc9.patch
-Patch51: chromium-gcc10-r769713.patch
-Patch52: chromium-gcc10-r771840.patch
-Patch53: chromium-gcc10-r772215.patch
-Patch54: chromium-gcc10-r772267.patch
-Patch55: chromium-gcc10-r772283.patch
-Patch56: chromium-gcc10-r772542.patch
-Patch57: chromium-gcc10-r773698.patch
-Patch58: chromium-gcc10-r773855.patch
-Patch59: chromium-gcc10-r774141.patch
-Patch60: chromium-gcc10-r775439.patch
-Patch61: chromium-gcc10-r778406.patch
-Patch62: chromium-gcc9-r772175.patch
-Patch63: chromium-gcc9-r772348.patch
+Patch51: chromium-gcc10-r783489.patch
+Patch52: chromium-gcc10-r783782.patch
+Patch53: chromium-gcc10-r783978.patch
+Patch54: chromium-gcc10-r784897.patch
+Patch55: chromium-gcc10-r785035.patch
+Patch56: chromium-gcc10-r785727.patch
+Patch57: chromium-gcc10-r785770.patch
+Patch58: chromium-gcc10-r785771.patch
# I don't have time to test whether it work on other architectures
ExclusiveArch: x86_64
@@ -148,7 +131,6 @@ BuildRequires: clang
BuildRequires: gcc, gcc-c++
%endif
BuildRequires: ninja-build, nodejs, java-headless, bison, gperf, hwdata
-BuildRequires: xcb-proto
BuildRequires: libgcc(x86-32), glibc(x86-32), libatomic
BuildRequires: libcap-devel, cups-devel, alsa-lib-devel, expat-devel
%if 0%{?fedora} >= 30
@@ -393,6 +375,7 @@ find -type f -exec \
third_party/node/node_modules/polymer-bundler/lib/third_party/UglifyJS2 \
third_party/one_euro_filter \
third_party/openh264 \
+ third_party/opencv \
third_party/openscreen \
third_party/openscreen/src/third_party/mozilla \
third_party/openscreen/src/third_party/tinycbor/src/src \
@@ -460,6 +443,7 @@ find -type f -exec \
third_party/widevine \
third_party/woff2 \
third_party/wuffs \
+ third_party/xcbproto \
third_party/xdg-utils \
third_party/zlib/google \
tools/grit/third_party/six \
@@ -592,24 +576,6 @@ gn_args+=(
./out/Release/gn gen out/Release \
--script-executable=/usr/bin/python2 --args="${gn_args[*]}"
-# The Python script ui/gfx/x/gen_xproto.py uses xcbgen library, which can be
-# found in xcb-proto package on Fedora. Surprisingly, the Chromium developer
-# decides to write this new script in Python 2 even if Python 2 is EOL in 2020.
-# Fedora only provides xcb-proto package for Python 3, so we have to patch both
-# the script and the ninja file to switch it to Python 3.
-sed -i 's|python2 \(\.\./\.\./ui/gfx/x/gen_xproto\.py\)|python3 \1|' \
- out/Release/toolchain.ninja
-
-# It seems that Chromium cannot properly handle <list type="fd" name="buffers">
-# element of PixmapFromBuffers request in dri3.xml. It knows 'num_buffers' is
-# the size of 'buffers', but it doesn't declare the variable 'buffers' itself.
-# Therefore, the generated dri3.cc file doesn't compile because of undeclared
-# variable. Since currently there is no code using the function, assume that
-# callers never pass 'buffers' and patch 'num_buffers' to always be zero.
-%{ninja_build} -C out/Release gen/ui/gfx/x/dri3.cc
-sed -i 's|^\( num_buffers\) = buffers.size();|\1 = 0;|' \
- out/Release/gen/ui/gfx/x/dri3.cc
-
%if 0%{?ninja_build:1}
%{ninja_build} -C out/Release chrome chrome_sandbox chromedriver
%else
@@ -645,6 +611,8 @@ install -m 755 out/Release/chromedriver %{buildroot}%{chromiumdir}/
install -m 644 out/Release/icudtl.dat %{buildroot}%{chromiumdir}/
%endif
install -m 644 out/Release/v8_context_snapshot.bin %{buildroot}%{chromiumdir}/
+install -m 644 out/Release/vk_swiftshader_icd.json %{buildroot}%{chromiumdir}/
+install -m 755 out/Release/*.so %{buildroot}%{chromiumdir}/
install -m 644 out/Release/*.pak %{buildroot}%{chromiumdir}/
install -m 644 out/Release/locales/*.pak %{buildroot}%{chromiumdir}/locales/
install -m 644 out/Release/MEIPreload/* %{buildroot}%{chromiumdir}/MEIPreload/
@@ -701,7 +669,13 @@ gtk-update-icon-cache %{_datadir}/icons/hicolor &>/dev/null || :
%if !%{with system_libicu}
%{chromiumdir}/icudtl.dat
%endif
+%{chromiumdir}/libEGL.so
+%{chromiumdir}/libGLESv2.so
+%{chromiumdir}/libVkICD_mock_icd.so
+%{chromiumdir}/libvk_swiftshader.so
+%{chromiumdir}/libvulkan.so
%{chromiumdir}/v8_context_snapshot.bin
+%{chromiumdir}/vk_swiftshader_icd.json
%{chromiumdir}/*.pak
%dir %{chromiumdir}/locales
%{chromiumdir}/locales/*.pak
@@ -715,6 +689,9 @@ gtk-update-icon-cache %{_datadir}/icons/hicolor &>/dev/null || :
%changelog
+* Fri Aug 28 2020 - Ting-Wei Lan <lantw44@gmail.com> - 85.0.4183.83-100
+- Update to 85.0.4183.83
+
* Thu Aug 20 2020 - Ting-Wei Lan <lantw44@gmail.com> - 84.0.4147.135-100
- Update to 84.0.4147.135