cef/patch/patches/resource_bundle_2512.patch

46 lines
1.9 KiB
Diff

diff --git ui/base/resource/resource_bundle.cc ui/base/resource/resource_bundle.cc
index 1b4d235071561..e5c795b4ab0b7 100644
--- ui/base/resource/resource_bundle.cc
+++ ui/base/resource/resource_bundle.cc
@@ -890,6 +890,12 @@ ResourceBundle::ResourceBundle(Delegate* delegate)
: delegate_(delegate),
locale_resources_data_lock_(new base::Lock),
max_scale_factor_(k100Percent) {
+ // With CEF's multi-threaded mode the ResourceBundle may be created on the
+ // main thread and then accessed on the UI thread. Allow the SequenceChecker
+ // to re-bind on the UI thread when CalledOnValidSequence() is called for the
+ // first time.
+ DETACH_FROM_SEQUENCE(sequence_checker_);
+
mangle_localized_strings_ = base::CommandLine::ForCurrentProcess()->HasSwitch(
switches::kMangleLocalizedStrings);
}
@@ -899,6 +905,11 @@ ResourceBundle::~ResourceBundle() {
UnloadLocaleResources();
}
+void ResourceBundle::CleanupOnUIThread() {
+ FreeImages();
+ font_cache_.clear();
+}
+
// static
void ResourceBundle::InitSharedInstance(Delegate* delegate) {
DCHECK(g_shared_instance_ == nullptr) << "ResourceBundle initialized twice";
diff --git ui/base/resource/resource_bundle.h ui/base/resource/resource_bundle.h
index f192e3e05f993..bb7cb1e0fa323 100644
--- ui/base/resource/resource_bundle.h
+++ ui/base/resource/resource_bundle.h
@@ -209,6 +209,11 @@ class COMPONENT_EXPORT(UI_BASE) ResourceBundle {
ResourceBundle(const ResourceBundle&) = delete;
ResourceBundle& operator=(const ResourceBundle&) = delete;
+ // With CEF's multi-threaded mode the ResourceBundle may be created/destroyed
+ // on the main thread but accessed on the UI thread. Call this method on the
+ // UI thread to clean up resources before destruction.
+ void CleanupOnUIThread();
+
// Loads a secondary locale data pack using the given file region.
void LoadSecondaryLocaleDataWithPakFileRegion(
base::File pak_file,