mirror of
https://github.com/salvadordf/CEF4Delphi.git
synced 2024-11-24 08:02:15 +02:00
Fixed circular reference in TCustomCefUrlrequestClient
Added the TCefApplication.DisableBackgroundNetworking and TCefApplication.MetricsRecordingOnly properties
This commit is contained in:
parent
f7ffd5c4c9
commit
0688b10e1d
@ -147,6 +147,8 @@ type
|
||||
FWidevinePath : ustring;
|
||||
FMustFreeLibrary : boolean;
|
||||
FAutoplayPolicy : TCefAutoplayPolicy;
|
||||
FDisableBackgroundNetworking : boolean;
|
||||
FMetricsRecordingOnly : boolean;
|
||||
|
||||
FMustCreateResourceBundleHandler : boolean;
|
||||
FMustCreateBrowserProcessHandler : boolean;
|
||||
@ -389,6 +391,8 @@ type
|
||||
property WidevinePath : ustring read FWidevinePath write FWidevinePath;
|
||||
property MustFreeLibrary : boolean read FMustFreeLibrary write FMustFreeLibrary;
|
||||
property AutoplayPolicy : TCefAutoplayPolicy read FAutoplayPolicy write FAutoplayPolicy;
|
||||
property DisableBackgroundNetworking : boolean read FDisableBackgroundNetworking write FDisableBackgroundNetworking;
|
||||
property MetricsRecordingOnly : boolean read FMetricsRecordingOnly write FMetricsRecordingOnly;
|
||||
property ChildProcessesCount : integer read GetChildProcessesCount;
|
||||
property UsedMemory : cardinal read GetUsedMemory;
|
||||
property TotalSystemMemory : uint64 read GetTotalSystemMemory;
|
||||
@ -548,6 +552,8 @@ begin
|
||||
FWidevinePath := '';
|
||||
FMustFreeLibrary := False;
|
||||
FAutoplayPolicy := appDefault;
|
||||
FDisableBackgroundNetworking := False;
|
||||
FMetricsRecordingOnly := False;
|
||||
|
||||
FMustCreateResourceBundleHandler := False;
|
||||
FMustCreateBrowserProcessHandler := True;
|
||||
@ -1510,6 +1516,12 @@ begin
|
||||
if FDisableExtensions then
|
||||
commandLine.AppendSwitch('--disable-extensions');
|
||||
|
||||
if FDisableBackgroundNetworking then
|
||||
commandLine.AppendSwitch('--disable-background-networking');
|
||||
|
||||
if FMetricsRecordingOnly then
|
||||
commandLine.AppendSwitch('--metrics-recording-only');
|
||||
|
||||
if (FCustomCommandLines <> nil) and
|
||||
(FCustomCommandLineValues <> nil) and
|
||||
(FCustomCommandLines.Count = FCustomCommandLineValues.Count) then
|
||||
|
@ -1798,6 +1798,8 @@ type
|
||||
procedure OnDownloadProgress(const request: ICefUrlRequest; current, total: Int64);
|
||||
procedure OnDownloadData(const request: ICefUrlRequest; data: Pointer; dataLength: NativeUInt);
|
||||
function OnGetAuthCredentials(isProxy: Boolean; const host: ustring; port: Integer; const realm, scheme: ustring; const callback: ICefAuthCallback): Boolean;
|
||||
|
||||
procedure RemoveReferences; // custom procedure to clear all references
|
||||
end;
|
||||
|
||||
// TCefWebPluginInfoVisitor
|
||||
|
@ -85,10 +85,12 @@ type
|
||||
// Custom
|
||||
procedure doOnCreateURLRequest;
|
||||
|
||||
procedure DestroyRequestClient;
|
||||
|
||||
public
|
||||
constructor Create(AOwner: TComponent); override;
|
||||
destructor Destroy; override;
|
||||
procedure AfterConstruction; override;
|
||||
procedure BeforeDestruction; override;
|
||||
|
||||
procedure AddURLRequest;
|
||||
|
||||
@ -133,13 +135,6 @@ begin
|
||||
FOnCreateURLRequest := nil;
|
||||
end;
|
||||
|
||||
destructor TCEFUrlRequestClientComponent.Destroy;
|
||||
begin
|
||||
FClient := nil;
|
||||
|
||||
inherited Destroy;
|
||||
end;
|
||||
|
||||
procedure TCEFUrlRequestClientComponent.AfterConstruction;
|
||||
begin
|
||||
inherited AfterConstruction;
|
||||
@ -148,6 +143,27 @@ begin
|
||||
FClient := TCustomCefUrlrequestClient.Create(self);
|
||||
end;
|
||||
|
||||
procedure TCEFUrlRequestClientComponent.BeforeDestruction;
|
||||
begin
|
||||
DestroyRequestClient;
|
||||
|
||||
inherited BeforeDestruction;
|
||||
end;
|
||||
|
||||
procedure TCEFUrlRequestClientComponent.DestroyRequestClient;
|
||||
begin
|
||||
try
|
||||
if (FClient <> nil) then
|
||||
begin
|
||||
FClient.RemoveReferences;
|
||||
FClient := nil;
|
||||
end;
|
||||
except
|
||||
on e : exception do
|
||||
if CustomExceptionHandler('TCEFUrlRequestClientComponent.DestroyRequestClient', e) then raise;
|
||||
end;
|
||||
end;
|
||||
|
||||
procedure TCEFUrlRequestClientComponent.doOnRequestComplete(const request: ICefUrlRequest);
|
||||
begin
|
||||
if assigned(FOnRequestComplete) then FOnRequestComplete(self, request);
|
||||
|
@ -59,19 +59,25 @@ type
|
||||
procedure OnDownloadProgress(const request: ICefUrlRequest; current, total: Int64); virtual;
|
||||
procedure OnDownloadData(const request: ICefUrlRequest; data: Pointer; dataLength: NativeUInt); virtual;
|
||||
function OnGetAuthCredentials(isProxy: Boolean; const host: ustring; port: Integer; const realm, scheme: ustring; const callback: ICefAuthCallback): Boolean; virtual;
|
||||
|
||||
procedure RemoveReferences; virtual;
|
||||
|
||||
public
|
||||
constructor Create; virtual;
|
||||
end;
|
||||
|
||||
TCustomCefUrlrequestClient = class(TCefUrlrequestClientOwn)
|
||||
protected
|
||||
FEvents : ICEFUrlRequestClientEvents;
|
||||
FEvents : Pointer;
|
||||
|
||||
procedure OnRequestComplete(const request: ICefUrlRequest); override;
|
||||
procedure OnUploadProgress(const request: ICefUrlRequest; current, total: Int64); override;
|
||||
procedure OnDownloadProgress(const request: ICefUrlRequest; current, total: Int64); override;
|
||||
procedure OnDownloadData(const request: ICefUrlRequest; data: Pointer; dataLength: NativeUInt); override;
|
||||
function OnGetAuthCredentials(isProxy: Boolean; const host: ustring; port: Integer; const realm, scheme: ustring; const callback: ICefAuthCallback): Boolean; override;
|
||||
|
||||
procedure RemoveReferences; override;
|
||||
|
||||
public
|
||||
constructor Create(const events: ICEFUrlRequestClientEvents); reintroduce;
|
||||
destructor Destroy; override;
|
||||
@ -198,6 +204,11 @@ begin
|
||||
Result := False;
|
||||
end;
|
||||
|
||||
procedure TCefUrlrequestClientOwn.RemoveReferences;
|
||||
begin
|
||||
//
|
||||
end;
|
||||
|
||||
procedure TCefUrlrequestClientOwn.OnRequestComplete(const request: ICefUrlRequest);
|
||||
begin
|
||||
//
|
||||
@ -215,12 +226,12 @@ constructor TCustomCefUrlrequestClient.Create(const events: ICEFUrlRequestClient
|
||||
begin
|
||||
inherited Create;
|
||||
|
||||
FEvents := events;
|
||||
FEvents := Pointer(events);
|
||||
end;
|
||||
|
||||
destructor TCustomCefUrlrequestClient.Destroy;
|
||||
begin
|
||||
FEvents := nil;
|
||||
RemoveReferences;
|
||||
|
||||
inherited Destroy;
|
||||
end;
|
||||
@ -228,7 +239,8 @@ end;
|
||||
procedure TCustomCefUrlrequestClient.OnRequestComplete(const request: ICefUrlRequest);
|
||||
begin
|
||||
try
|
||||
if (FEvents <> nil) then FEvents.doOnRequestComplete(request);
|
||||
if (FEvents <> nil) then
|
||||
ICEFUrlRequestClientEvents(FEvents).doOnRequestComplete(request);
|
||||
except
|
||||
on e : exception do
|
||||
if CustomExceptionHandler('TCustomCefUrlrequestClient.OnRequestComplete', e) then raise;
|
||||
@ -238,7 +250,8 @@ end;
|
||||
procedure TCustomCefUrlrequestClient.OnUploadProgress(const request: ICefUrlRequest; current, total: Int64);
|
||||
begin
|
||||
try
|
||||
if (FEvents <> nil) then FEvents.doOnUploadProgress(request, current, total);
|
||||
if (FEvents <> nil) then
|
||||
ICEFUrlRequestClientEvents(FEvents).doOnUploadProgress(request, current, total);
|
||||
except
|
||||
on e : exception do
|
||||
if CustomExceptionHandler('TCustomCefUrlrequestClient.OnUploadProgress', e) then raise;
|
||||
@ -248,7 +261,8 @@ end;
|
||||
procedure TCustomCefUrlrequestClient.OnDownloadProgress(const request: ICefUrlRequest; current, total: Int64);
|
||||
begin
|
||||
try
|
||||
if (FEvents <> nil) then FEvents.doOnDownloadProgress(request, current, total);
|
||||
if (FEvents <> nil) then
|
||||
ICEFUrlRequestClientEvents(FEvents).doOnDownloadProgress(request, current, total);
|
||||
except
|
||||
on e : exception do
|
||||
if CustomExceptionHandler('TCustomCefUrlrequestClient.OnDownloadProgress', e) then raise;
|
||||
@ -258,7 +272,8 @@ end;
|
||||
procedure TCustomCefUrlrequestClient.OnDownloadData(const request: ICefUrlRequest; data: Pointer; dataLength: NativeUInt);
|
||||
begin
|
||||
try
|
||||
if (FEvents <> nil) then FEvents.doOnDownloadData(request, data, dataLength);
|
||||
if (FEvents <> nil) then
|
||||
ICEFUrlRequestClientEvents(FEvents).doOnDownloadData(request, data, dataLength);
|
||||
except
|
||||
on e : exception do
|
||||
if CustomExceptionHandler('TCustomCefUrlrequestClient.OnDownloadData', e) then raise;
|
||||
@ -269,12 +284,17 @@ function TCustomCefUrlrequestClient.OnGetAuthCredentials(isProxy: Boolean; const
|
||||
begin
|
||||
Result := False;
|
||||
try
|
||||
if (FEvents <> nil) then Result := FEvents.doOnGetAuthCredentials(isProxy, host, port, realm, scheme, callback);
|
||||
if (FEvents <> nil) then
|
||||
Result := ICEFUrlRequestClientEvents(FEvents).doOnGetAuthCredentials(isProxy, host, port, realm, scheme, callback);
|
||||
except
|
||||
on e : exception do
|
||||
if CustomExceptionHandler('TCustomCefUrlrequestClient.OnGetAuthCredentials', e) then raise;
|
||||
end;
|
||||
end;
|
||||
|
||||
procedure TCustomCefUrlrequestClient.RemoveReferences;
|
||||
begin
|
||||
FEvents := nil;
|
||||
end;
|
||||
|
||||
end.
|
||||
|
Loading…
Reference in New Issue
Block a user