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