Esempio n. 1
0
        internal static cef_resource_handler_t *Alloc()
        {
            var ptr = (cef_resource_handler_t *)Marshal.AllocHGlobal(_sizeof);

            *ptr = new cef_resource_handler_t();
            ptr->_base._size = (UIntPtr)_sizeof;
            return(ptr);
        }
        private int process_request(cef_resource_handler_t* self, cef_request_t* request, cef_callback_t* callback)
        {
            CheckSelf(self);

            var m_request = CefRequest.FromNative(request);
            var m_callback = CefCallback.FromNative(callback);

            var result = ProcessRequest(m_request, m_callback);
            return result ? 1 : 0;
        }
 private int release(cef_resource_handler_t* self)
 {
     lock (SyncRoot)
     {
         var result = --_refct;
         if (result == 0)
         {
             lock (_roots) { _roots.Remove((IntPtr)_self); }
         }
         return result;
     }
 }
 private int add_ref(cef_resource_handler_t* self)
 {
     lock (SyncRoot)
     {
         var result = ++_refct;
         if (result == 1)
         {
             lock (_roots) { _roots.Add((IntPtr)_self, this); }
         }
         return result;
     }
 }
        private int read_response(cef_resource_handler_t* self, void* data_out, int bytes_to_read, int* bytes_read, cef_callback_t* callback)
        {
            CheckSelf(self);

            var m_callback = CefCallback.FromNative(callback);

            using (var m_stream = new UnmanagedMemoryStream((byte*)data_out, bytes_to_read, bytes_to_read, FileAccess.Write))
            {
                int m_bytesRead;
                var result = ReadResponse(m_stream, bytes_to_read, out m_bytesRead, m_callback);
                *bytes_read = m_bytesRead;
                return result ? 1 : 0;
            }
        }
        private void get_response_headers(cef_resource_handler_t* self, cef_response_t* response, long* response_length, cef_string_t* redirectUrl)
        {
            CheckSelf(self);

            var m_response = CefResponse.FromNative(response);
            long m_responseLength;
            string m_redirectUrl;

            GetResponseHeaders(m_response, out m_responseLength, out m_redirectUrl);

            *response_length = m_responseLength;

            if (!string.IsNullOrEmpty(m_redirectUrl))
            {
                cef_string_t.Copy(m_redirectUrl, redirectUrl);
            }
        }
        private int can_get_cookie(cef_resource_handler_t* self, cef_cookie_t* cookie)
        {
            CheckSelf(self);

            var m_cookie = CefCookie.FromNative(cookie);

            return CanGetCookie(m_cookie) ? 1 : 0;
        }
        private void cancel(cef_resource_handler_t* self)
        {
            CheckSelf(self);

            Cancel();
        }
 private int get_refct(cef_resource_handler_t* self)
 {
     return _refct;
 }
 private void CheckSelf(cef_resource_handler_t* self)
 {
     if (_self != self) throw ExceptionBuilder.InvalidSelfReference();
 }
 internal static void Free(cef_resource_handler_t* ptr)
 {
     Marshal.FreeHGlobal((IntPtr)ptr);
 }
 internal static cef_resource_handler_t* Alloc()
 {
     var ptr = (cef_resource_handler_t*)Marshal.AllocHGlobal(_sizeof);
     *ptr = new cef_resource_handler_t();
     ptr->_base._size = (UIntPtr)_sizeof;
     return ptr;
 }