Skip to content

Commit b0dfb60

Browse files
committed
IResourceHandler now implements IDisposable - you can cleanup and resources when the handler is disposed
1 parent 8eb8b84 commit b0dfb60

File tree

4 files changed

+16
-1
lines changed

4 files changed

+16
-1
lines changed

CefSharp.Core/ResourceHandlerWrapper.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@ namespace CefSharp
3333

3434
~ResourceHandlerWrapper()
3535
{
36+
delete _handler;
3637
_handler = nullptr;
3738
}
3839

CefSharp.Example/CefSharpSchemeHandler.cs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -170,5 +170,10 @@ void IResourceHandler.Cancel()
170170
{
171171

172172
}
173+
174+
void IDisposable.Dispose()
175+
{
176+
177+
}
173178
}
174179
}

CefSharp/IResourceHandler.cs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
//
33
// Use of this source code is governed by a BSD-style license that can be found in the LICENSE file.
44

5+
using System;
56
using System.IO;
67

78
namespace CefSharp
@@ -16,7 +17,7 @@ namespace CefSharp
1617
/// a previous version <see cref="ResourceHandler"/>. For those upgrading, inherit from ResourceHandler instead of IResourceHandler
1718
/// add the override keywoard to existing methods e.g. ProcessRequestAsync.
1819
/// </summary>
19-
public interface IResourceHandler
20+
public interface IResourceHandler : IDisposable
2021
{
2122
/// <summary>
2223
/// Begin processing the request.

CefSharp/ResourceHandler.cs

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -829,5 +829,13 @@ public static string GetMimeType(string extension)
829829
string mime;
830830
return Mappings.TryGetValue(extension, out mime) ? mime : "application/octet-stream";
831831
}
832+
833+
/// <summary>
834+
/// Dispose of resources here
835+
/// </summary>
836+
public virtual void Dispose()
837+
{
838+
839+
}
832840
}
833841
}

0 commit comments

Comments
 (0)