2015-06-25 16:56:38 -04:00
|
|
|
// Copyright 1998-2015 Epic Games, Inc. All Rights Reserved.
|
|
|
|
|
|
|
|
|
|
#include "UnrealCEFSubProcess.h"
|
|
|
|
|
#include "UnrealCEFSubProcessCallbackRegistry.h"
|
|
|
|
|
|
2015-07-08 18:54:20 -04:00
|
|
|
#if WITH_CEF3
|
|
|
|
|
|
2015-06-25 16:56:38 -04:00
|
|
|
FGuid FUnrealCEFSubProcessCallbackRegistry::FindOrAdd(CefRefPtr<CefV8Context> Context, CefRefPtr<CefV8Value> Object, CefRefPtr<CefV8Value> Function, CefRefPtr<CefV8Value> OnError, bool bOneShot)
|
|
|
|
|
{
|
|
|
|
|
if (! bOneShot)
|
|
|
|
|
{
|
|
|
|
|
for(auto Iter = CreateIterator(); Iter; ++Iter)
|
|
|
|
|
{
|
|
|
|
|
auto Value = Iter.Value();
|
|
|
|
|
if (! Value.bOneShot
|
|
|
|
|
&& Context->IsSame(Value.Context)
|
|
|
|
|
&& Function->IsSame(Value.Function)
|
2015-07-14 16:06:52 -04:00
|
|
|
&& (Object == nullptr && Value.Object == nullptr || Object->IsSame(Value.Object))
|
2015-06-25 16:56:38 -04:00
|
|
|
&& (OnError == nullptr && Value.OnError == nullptr || OnError->IsSame(Value.OnError)))
|
|
|
|
|
{
|
|
|
|
|
return Iter.Key();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// If not found or one-shot, add new entry to the map
|
|
|
|
|
FGuid Guid = FGuid::NewGuid();
|
|
|
|
|
Add(Guid, FUnrealCEFSubProcessCallbackRegistryEntry(Context, Object, Function, OnError, bOneShot));
|
|
|
|
|
return Guid;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void FUnrealCEFSubProcessCallbackRegistry::RemoveByContext(CefRefPtr<CefV8Context> Context)
|
|
|
|
|
{
|
|
|
|
|
for(auto Iter = CreateIterator(); Iter; ++Iter)
|
|
|
|
|
{
|
|
|
|
|
if (Context->IsSame(Iter.Value().Context))
|
|
|
|
|
{
|
|
|
|
|
Iter.RemoveCurrent();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
2015-07-08 18:54:20 -04:00
|
|
|
|
|
|
|
|
#endif // WITH_CEF3
|