Skip to content

Commit 09e729f

Browse files
authored
[dotnet] [bidi] Hide Broker as internal implementation (#16982)
1 parent baae3e8 commit 09e729f

File tree

13 files changed

+141
-131
lines changed

13 files changed

+141
-131
lines changed

dotnet/src/webdriver/BiDi/Broker.cs

Lines changed: 4 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@
2828

2929
namespace OpenQA.Selenium.BiDi;
3030

31-
public sealed class Broker : IAsyncDisposable
31+
internal sealed class Broker : IAsyncDisposable
3232
{
3333
private readonly ILogger _logger = Internal.Logging.Log.GetLogger<Broker>();
3434

@@ -80,7 +80,7 @@ private async Task ReceiveMessagesAsync(CancellationToken cancellationToken)
8080
{
8181
if (_logger.IsEnabled(LogEventLevel.Error))
8282
{
83-
_logger.Error($"Unhandled error occured while processing remote message: {ex}");
83+
_logger.Error($"Unhandled error occurred while processing remote message: {ex}");
8484
}
8585
}
8686
}
@@ -89,7 +89,7 @@ private async Task ReceiveMessagesAsync(CancellationToken cancellationToken)
8989
{
9090
if (_logger.IsEnabled(LogEventLevel.Error))
9191
{
92-
_logger.Error($"Unhandled error occured while receiving remote messages: {ex}");
92+
_logger.Error($"Unhandled error occurred while receiving remote messages: {ex}");
9393
}
9494

9595
throw;
@@ -145,21 +145,7 @@ public async Task<TResult> ExecuteCommandAsync<TCommand, TResult>(TCommand comma
145145
return (TResult)await tcs.Task.ConfigureAwait(false);
146146
}
147147

148-
public Task<Subscription> SubscribeAsync<TEventArgs>(string eventName, Action<TEventArgs> action, SubscriptionOptions? options, JsonTypeInfo<TEventArgs> jsonTypeInfo)
149-
where TEventArgs : EventArgs
150-
{
151-
var eventHandler = new SyncEventHandler<TEventArgs>(eventName, action);
152-
return SubscribeAsync(eventName, eventHandler, options, jsonTypeInfo);
153-
}
154-
155-
public Task<Subscription> SubscribeAsync<TEventArgs>(string eventName, Func<TEventArgs, Task> func, SubscriptionOptions? options, JsonTypeInfo<TEventArgs> jsonTypeInfo)
156-
where TEventArgs : EventArgs
157-
{
158-
var eventHandler = new AsyncEventHandler<TEventArgs>(eventName, func);
159-
return SubscribeAsync(eventName, eventHandler, options, jsonTypeInfo);
160-
}
161-
162-
private async Task<Subscription> SubscribeAsync<TEventArgs>(string eventName, EventHandler eventHandler, SubscriptionOptions? options, JsonTypeInfo<TEventArgs> jsonTypeInfo)
148+
public async Task<Subscription> SubscribeAsync<TEventArgs>(string eventName, EventHandler eventHandler, SubscriptionOptions? options, JsonTypeInfo<TEventArgs> jsonTypeInfo)
163149
where TEventArgs : EventArgs
164150
{
165151
_eventTypesMap[eventName] = jsonTypeInfo;

dotnet/src/webdriver/BiDi/Browser/BrowserModule.cs

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -30,53 +30,53 @@ public sealed class BrowserModule : Module
3030

3131
public async Task<CloseResult> CloseAsync(CloseOptions? options = null)
3232
{
33-
return await Broker.ExecuteCommandAsync(new CloseCommand(), options, _jsonContext.CloseCommand, _jsonContext.CloseResult).ConfigureAwait(false);
33+
return await ExecuteCommandAsync(new CloseCommand(), options, _jsonContext.CloseCommand, _jsonContext.CloseResult).ConfigureAwait(false);
3434
}
3535

3636
public async Task<CreateUserContextResult> CreateUserContextAsync(CreateUserContextOptions? options = null)
3737
{
3838
var @params = new CreateUserContextParameters(options?.AcceptInsecureCerts, options?.Proxy, options?.UnhandledPromptBehavior);
3939

40-
return await Broker.ExecuteCommandAsync(new CreateUserContextCommand(@params), options, _jsonContext.CreateUserContextCommand, _jsonContext.CreateUserContextResult).ConfigureAwait(false);
40+
return await ExecuteCommandAsync(new CreateUserContextCommand(@params), options, _jsonContext.CreateUserContextCommand, _jsonContext.CreateUserContextResult).ConfigureAwait(false);
4141
}
4242

4343
public async Task<GetUserContextsResult> GetUserContextsAsync(GetUserContextsOptions? options = null)
4444
{
45-
return await Broker.ExecuteCommandAsync(new GetUserContextsCommand(), options, _jsonContext.GetUserContextsCommand, _jsonContext.GetUserContextsResult).ConfigureAwait(false);
45+
return await ExecuteCommandAsync(new GetUserContextsCommand(), options, _jsonContext.GetUserContextsCommand, _jsonContext.GetUserContextsResult).ConfigureAwait(false);
4646
}
4747

4848
public async Task<RemoveUserContextResult> RemoveUserContextAsync(UserContext userContext, RemoveUserContextOptions? options = null)
4949
{
5050
var @params = new RemoveUserContextParameters(userContext);
5151

52-
return await Broker.ExecuteCommandAsync(new RemoveUserContextCommand(@params), options, _jsonContext.RemoveUserContextCommand, _jsonContext.RemoveUserContextResult).ConfigureAwait(false);
52+
return await ExecuteCommandAsync(new RemoveUserContextCommand(@params), options, _jsonContext.RemoveUserContextCommand, _jsonContext.RemoveUserContextResult).ConfigureAwait(false);
5353
}
5454

5555
public async Task<GetClientWindowsResult> GetClientWindowsAsync(GetClientWindowsOptions? options = null)
5656
{
57-
return await Broker.ExecuteCommandAsync(new(), options, _jsonContext.GetClientWindowsCommand, _jsonContext.GetClientWindowsResult
57+
return await ExecuteCommandAsync(new(), options, _jsonContext.GetClientWindowsCommand, _jsonContext.GetClientWindowsResult
5858
).ConfigureAwait(false);
5959
}
6060

6161
public async Task<SetDownloadBehaviorResult> SetDownloadBehaviorAllowedAsync(string destinationFolder, SetDownloadBehaviorOptions? options = null)
6262
{
6363
var @params = new SetDownloadBehaviorParameters(new DownloadBehaviorAllowed(destinationFolder), options?.UserContexts);
6464

65-
return await Broker.ExecuteCommandAsync(new SetDownloadBehaviorCommand(@params), options, _jsonContext.SetDownloadBehaviorCommand, _jsonContext.SetDownloadBehaviorResult).ConfigureAwait(false);
65+
return await ExecuteCommandAsync(new SetDownloadBehaviorCommand(@params), options, _jsonContext.SetDownloadBehaviorCommand, _jsonContext.SetDownloadBehaviorResult).ConfigureAwait(false);
6666
}
6767

6868
public async Task<SetDownloadBehaviorResult> SetDownloadBehaviorAllowedAsync(SetDownloadBehaviorOptions? options = null)
6969
{
7070
var @params = new SetDownloadBehaviorParameters(null, options?.UserContexts);
7171

72-
return await Broker.ExecuteCommandAsync(new SetDownloadBehaviorCommand(@params), options, _jsonContext.SetDownloadBehaviorCommand, _jsonContext.SetDownloadBehaviorResult).ConfigureAwait(false);
72+
return await ExecuteCommandAsync(new SetDownloadBehaviorCommand(@params), options, _jsonContext.SetDownloadBehaviorCommand, _jsonContext.SetDownloadBehaviorResult).ConfigureAwait(false);
7373
}
7474

7575
public async Task<SetDownloadBehaviorResult> SetDownloadBehaviorDeniedAsync(SetDownloadBehaviorOptions? options = null)
7676
{
7777
var @params = new SetDownloadBehaviorParameters(new DownloadBehaviorDenied(), options?.UserContexts);
7878

79-
return await Broker.ExecuteCommandAsync(new SetDownloadBehaviorCommand(@params), options, _jsonContext.SetDownloadBehaviorCommand, _jsonContext.SetDownloadBehaviorResult).ConfigureAwait(false);
79+
return await ExecuteCommandAsync(new SetDownloadBehaviorCommand(@params), options, _jsonContext.SetDownloadBehaviorCommand, _jsonContext.SetDownloadBehaviorResult).ConfigureAwait(false);
8080
}
8181

8282
protected override void Initialize(JsonSerializerOptions jsonSerializerOptions)

0 commit comments

Comments
 (0)