Files
cefsharp/CefSharp.BrowserSubprocess.Core/JavascriptCallbackRegistry.h
Alex Maitland d78d01a2c4 Core - Rewrite RenderProcess to avoid using OnBrowserDestroyed for JS eval (#5197)
- JavascriptCallbackRegistry - Get BrowserId From V8Context
- Render Process - Rewrite to store root object wrapper by frame instead of per browser
-  Don't store JavascriptRootObjectWrapper in the browserWrapper as CEF is calling destroyed more than it should.
-  Revert "Tests - Simplify ShouldFailWhenIsObjectCachedCalledWithInvalidObjectName"

This reverts commit f8a81acf7a.

---------

Co-authored-by: amaitland <307872+amaitland@users.noreply.github.com>
2025-12-03 19:00:12 +10:00

54 lines
1.7 KiB
C++

// Copyright © 2015 The CefSharp Authors. All rights reserved.
//
// Use of this source code is governed by a BSD-style license that can be found in the LICENSE file.
#pragma once
#include "JavascriptCallbackWrapper.h"
using namespace System::Collections::Concurrent;
using namespace CefSharp::BrowserSubprocess;
namespace CefSharp
{
namespace BrowserSubprocess
{
private ref class JavascriptCallbackRegistry
{
private:
//Only access through Interlocked::Increment - used to generate unique callback Id's
//Is static so ids are unique to this process, which is required until #1984 is implemented
//and callbacks are disposed of properly between contexts
static Int64 _lastId;
ConcurrentDictionary<Int64, JavascriptCallbackWrapper^>^ _callbacks;
internal:
JavascriptCallbackWrapper^ FindWrapper(int64_t id);
public:
JavascriptCallbackRegistry()
{
_callbacks = gcnew ConcurrentDictionary<Int64, JavascriptCallbackWrapper^>();
}
~JavascriptCallbackRegistry()
{
if (_callbacks != nullptr)
{
for each (JavascriptCallbackWrapper^ callback in _callbacks->Values)
{
delete callback;
}
_callbacks->Clear();
_callbacks = nullptr;
}
}
JavascriptCallback^ Register(const CefRefPtr<CefV8Context>& context, const CefRefPtr<CefV8Value>& value);
void Deregister(Int64 id);
};
}
}