Files
UnrealEngineUWP/Engine/Source/Programs/UnrealCEFSubProcess/Private/UnrealCEFSubProcessCallbackRegistry.cpp
Keli Hlodversson e2b03ba393 Merging CL#2601171 using UE4-To-UE4-LauncherDev:
Implement JS integration via a subset of UObject scripting functionality and custom CEF Messages
JIRA: OPP-3240
rb: Justin.Sargent

[CL 2601283 by Keli Hlodversson in Main branch]
2015-06-25 16:56:38 -04:00

40 lines
1.1 KiB
C++

// Copyright 1998-2015 Epic Games, Inc. All Rights Reserved.
#include "UnrealCEFSubProcess.h"
#include "UnrealCEFSubProcessCallbackRegistry.h"
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)
&& Object->IsSame(Value.Object)
&& (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();
}
}
}