mirror of
https://github.com/cefsharp/CefSharp.git
synced 2026-12-04 19:25:01 +00:00
78e32a3b9f
* Core - Add DevToolsClient Issue #3165 * DevTools Client - Add Network domain class - Add hand written class to get a better sense of how the code should be structured. - Improve exception handling * Devtools - First draft of devtools protocol methods (generated) Not complete yet * Devtools - Simple method execution working * DevTools - Add .Net Style cased property names to response objects - Use internal field and datacontract attributes * DevTools - Improve mapping * DevTools - Strongly typed enums * DevTools Client - Generated from active browser instance (M84) * Devtools Client - Extract IDevToolsClient interface for testability Improve xml doc comments * DevTools Client - Improve error handling * DevTools Client - Improve enum conversion * Revert to older c# syntax * DevTools Client - Fix failing tests * Devtools Client - Add SetCookie Tests * DevTools Client - Add Capture SyncContext by default - Add option to capture the SyncContext - Add option to provide custom SyncContext (can just pass in UI SyncContext and all continuations will happen there). - Fix bug in ExecuteDevToolsMethodAsync sending the command twice when exeucted on the CEF UI thread * Devtools Client - Add missing file reference The problem with developing with the .Net Core project where files are automatically included is you forget to include them in the regular csproj file. * Devtools Client - Add CanCanEmulate Test case * DevTools Client - Add AddScriptToEvaluateOnNewDocumentAsync test * DevTools Client - OnDevToolsEvent only parse data if event handler != null * DevTools Client - GetDevToolsClient remove ThrowExceptionIfDisposed/ThrowExceptionIfBrowserNotInitialized calls Those methods were removed as the GetBrowser call handles the checks for us. * DevTools Client - Improve error handling * DevTools Client - Update xml doc comments * DevTools Client - Add validation method (partial) Add ability to manually add validation logic * DevTools Client - Comment out failing test Was working when targeting M84, now with M85 it fails. The mapping appears to be correct, will need to investigate further * OffScreen Example - Remove test code
118 lines
5.9 KiB
C#
118 lines
5.9 KiB
C#
// Copyright © 2020 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.
|
|
namespace CefSharp.DevTools.CacheStorage
|
|
{
|
|
using System.Linq;
|
|
|
|
/// <summary>
|
|
/// CacheStorage
|
|
/// </summary>
|
|
public partial class CacheStorage : DevToolsDomainBase
|
|
{
|
|
private CefSharp.DevTools.IDevToolsClient _client;
|
|
public CacheStorage(CefSharp.DevTools.IDevToolsClient client)
|
|
{
|
|
_client = (client);
|
|
}
|
|
|
|
partial void ValidateDeleteCache(string cacheId);
|
|
/// <summary>
|
|
/// Deletes a cache.
|
|
/// </summary>
|
|
/// <param name = "cacheId">Id of cache for deletion.</param>
|
|
/// <returns>returns System.Threading.Tasks.Task<DevToolsMethodResponse></returns>
|
|
public async System.Threading.Tasks.Task<DevToolsMethodResponse> DeleteCacheAsync(string cacheId)
|
|
{
|
|
ValidateDeleteCache(cacheId);
|
|
var dict = new System.Collections.Generic.Dictionary<string, object>();
|
|
dict.Add("cacheId", cacheId);
|
|
var methodResult = await _client.ExecuteDevToolsMethodAsync("CacheStorage.deleteCache", dict);
|
|
return methodResult;
|
|
}
|
|
|
|
partial void ValidateDeleteEntry(string cacheId, string request);
|
|
/// <summary>
|
|
/// Deletes a cache entry.
|
|
/// </summary>
|
|
/// <param name = "cacheId">Id of cache where the entry will be deleted.</param>
|
|
/// <param name = "request">URL spec of the request.</param>
|
|
/// <returns>returns System.Threading.Tasks.Task<DevToolsMethodResponse></returns>
|
|
public async System.Threading.Tasks.Task<DevToolsMethodResponse> DeleteEntryAsync(string cacheId, string request)
|
|
{
|
|
ValidateDeleteEntry(cacheId, request);
|
|
var dict = new System.Collections.Generic.Dictionary<string, object>();
|
|
dict.Add("cacheId", cacheId);
|
|
dict.Add("request", request);
|
|
var methodResult = await _client.ExecuteDevToolsMethodAsync("CacheStorage.deleteEntry", dict);
|
|
return methodResult;
|
|
}
|
|
|
|
partial void ValidateRequestCacheNames(string securityOrigin);
|
|
/// <summary>
|
|
/// Requests cache names.
|
|
/// </summary>
|
|
/// <param name = "securityOrigin">Security origin.</param>
|
|
/// <returns>returns System.Threading.Tasks.Task<RequestCacheNamesResponse></returns>
|
|
public async System.Threading.Tasks.Task<RequestCacheNamesResponse> RequestCacheNamesAsync(string securityOrigin)
|
|
{
|
|
ValidateRequestCacheNames(securityOrigin);
|
|
var dict = new System.Collections.Generic.Dictionary<string, object>();
|
|
dict.Add("securityOrigin", securityOrigin);
|
|
var methodResult = await _client.ExecuteDevToolsMethodAsync("CacheStorage.requestCacheNames", dict);
|
|
return methodResult.DeserializeJson<RequestCacheNamesResponse>();
|
|
}
|
|
|
|
partial void ValidateRequestCachedResponse(string cacheId, string requestURL, System.Collections.Generic.IList<CefSharp.DevTools.CacheStorage.Header> requestHeaders);
|
|
/// <summary>
|
|
/// Fetches cache entry.
|
|
/// </summary>
|
|
/// <param name = "cacheId">Id of cache that contains the entry.</param>
|
|
/// <param name = "requestURL">URL spec of the request.</param>
|
|
/// <param name = "requestHeaders">headers of the request.</param>
|
|
/// <returns>returns System.Threading.Tasks.Task<RequestCachedResponseResponse></returns>
|
|
public async System.Threading.Tasks.Task<RequestCachedResponseResponse> RequestCachedResponseAsync(string cacheId, string requestURL, System.Collections.Generic.IList<CefSharp.DevTools.CacheStorage.Header> requestHeaders)
|
|
{
|
|
ValidateRequestCachedResponse(cacheId, requestURL, requestHeaders);
|
|
var dict = new System.Collections.Generic.Dictionary<string, object>();
|
|
dict.Add("cacheId", cacheId);
|
|
dict.Add("requestURL", requestURL);
|
|
dict.Add("requestHeaders", requestHeaders.Select(x => x.ToDictionary()));
|
|
var methodResult = await _client.ExecuteDevToolsMethodAsync("CacheStorage.requestCachedResponse", dict);
|
|
return methodResult.DeserializeJson<RequestCachedResponseResponse>();
|
|
}
|
|
|
|
partial void ValidateRequestEntries(string cacheId, int? skipCount = null, int? pageSize = null, string pathFilter = null);
|
|
/// <summary>
|
|
/// Requests data from cache.
|
|
/// </summary>
|
|
/// <param name = "cacheId">ID of cache to get entries from.</param>
|
|
/// <param name = "skipCount">Number of records to skip.</param>
|
|
/// <param name = "pageSize">Number of records to fetch.</param>
|
|
/// <param name = "pathFilter">If present, only return the entries containing this substring in the path</param>
|
|
/// <returns>returns System.Threading.Tasks.Task<RequestEntriesResponse></returns>
|
|
public async System.Threading.Tasks.Task<RequestEntriesResponse> RequestEntriesAsync(string cacheId, int? skipCount = null, int? pageSize = null, string pathFilter = null)
|
|
{
|
|
ValidateRequestEntries(cacheId, skipCount, pageSize, pathFilter);
|
|
var dict = new System.Collections.Generic.Dictionary<string, object>();
|
|
dict.Add("cacheId", cacheId);
|
|
if (skipCount.HasValue)
|
|
{
|
|
dict.Add("skipCount", skipCount.Value);
|
|
}
|
|
|
|
if (pageSize.HasValue)
|
|
{
|
|
dict.Add("pageSize", pageSize.Value);
|
|
}
|
|
|
|
if (!(string.IsNullOrEmpty(pathFilter)))
|
|
{
|
|
dict.Add("pathFilter", pathFilter);
|
|
}
|
|
|
|
var methodResult = await _client.ExecuteDevToolsMethodAsync("CacheStorage.requestEntries", dict);
|
|
return methodResult.DeserializeJson<RequestEntriesResponse>();
|
|
}
|
|
}
|
|
} |