/// <summary> /// Create a new CfrStreamReader object from a custom handler. /// </summary> /// <remarks> /// See also the original CEF documentation in /// <see href="https://bitbucket.org/chromiumfx/chromiumfx/src/tip/cef/include/capi/cef_stream_capi.h">cef/include/capi/cef_stream_capi.h</see>. /// </remarks> public static CfrStreamReader CreateForHandler(CfrReadHandler handler) { var call = new CfxStreamReaderCreateForHandlerRemoteCall(); call.handler = CfrObject.Unwrap(handler).ptr; call.RequestExecution(); return(CfrStreamReader.Wrap(new RemotePtr(call.__retval))); }
/// <summary> /// Create a new CfrStreamReader object from a custom handler. /// </summary> /// <remarks> /// See also the original CEF documentation in /// <see href="https://bitbucket.org/chromiumfx/chromiumfx/src/tip/cef/include/capi/cef_stream_capi.h">cef/include/capi/cef_stream_capi.h</see>. /// </remarks> public static CfrStreamReader CreateForHandler(CfrReadHandler handler) { var connection = CfxRemoteCallContext.CurrentContext.connection; var call = new CfxStreamReaderCreateForHandlerRemoteCall(); if (!CfrObject.CheckConnection(handler, connection)) { throw new ArgumentException("Render process connection mismatch.", "handler"); } call.handler = CfrObject.Unwrap(handler).ptr; call.RequestExecution(connection); return(CfrStreamReader.Wrap(new RemotePtr(connection, call.__retval))); }
internal static CfrReadHandler Wrap(RemotePtr remotePtr) { if (remotePtr == RemotePtr.Zero) { return(null); } var weakCache = CfxRemoteCallContext.CurrentContext.connection.weakCache; lock (weakCache) { var cfrObj = (CfrReadHandler)weakCache.Get(remotePtr.ptr); if (cfrObj == null) { cfrObj = new CfrReadHandler(remotePtr); weakCache.Add(remotePtr.ptr, cfrObj); } return(cfrObj); } }