Skip to content

Commit 2dcfdf5

Browse files
committed
Rpc Interface renaming
1 parent a731a27 commit 2dcfdf5

7 files changed

Lines changed: 146 additions & 59 deletions

File tree

CefSharp.OutOfProcess.BrowserProcess/BrowserProcessHandler.cs

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -10,15 +10,15 @@
1010

1111
namespace CefSharp.OutOfProcess.BrowserProcess
1212
{
13-
public class BrowserProcessHandler : CefSharp.Handler.BrowserProcessHandler, IBrowserProcessServer
13+
public class BrowserProcessHandler : CefSharp.Handler.BrowserProcessHandler, IOutOfProcessClientRpc
1414
{
1515
private readonly int _parentProcessId;
1616
private IList<OutOfProcessChromiumWebBrowser> _browsers = new List<OutOfProcessChromiumWebBrowser>();
1717
/// <summary>
1818
/// JSON RPC used for IPC with host
1919
/// </summary>
2020
private JsonRpc _jsonRpc;
21-
private IOutOfProcessServer _outOfProcessServer;
21+
private IOutOfProcessHostRpc _outOfProcessServer;
2222

2323
public BrowserProcessHandler(int parentProcessId)
2424
{
@@ -30,9 +30,9 @@ protected override void OnContextInitialized()
3030
base.OnContextInitialized();
3131

3232
_jsonRpc = JsonRpc.Attach(Console.OpenStandardOutput(), Console.OpenStandardInput());
33-
_outOfProcessServer = _jsonRpc.Attach<IOutOfProcessServer>();
33+
_outOfProcessServer = _jsonRpc.Attach<IOutOfProcessHostRpc>();
3434
_jsonRpc.AllowModificationWhileListening = true;
35-
_jsonRpc.AddLocalRpcTarget<IBrowserProcessServer>(this, null);
35+
_jsonRpc.AddLocalRpcTarget<IOutOfProcessClientRpc>(this, null);
3636
_jsonRpc.AllowModificationWhileListening = false;
3737

3838
var threadId = Kernel32.GetCurrentThreadId();
@@ -51,7 +51,7 @@ protected override void Dispose(bool disposing)
5151
}
5252
}
5353

54-
Task IBrowserProcessServer.CloseBrowser(int browserId)
54+
Task IOutOfProcessClientRpc.CloseBrowser(int browserId)
5555
{
5656
return CefThread.ExecuteOnUiThread(() =>
5757
{
@@ -65,7 +65,7 @@ Task IBrowserProcessServer.CloseBrowser(int browserId)
6565
});
6666
}
6767

68-
Task IBrowserProcessServer.SendDevToolsMessage(int browserId, string message)
68+
Task IOutOfProcessClientRpc.SendDevToolsMessage(int browserId, string message)
6969
{
7070
return CefThread.ExecuteOnUiThread(() =>
7171
{
@@ -77,7 +77,7 @@ Task IBrowserProcessServer.SendDevToolsMessage(int browserId, string message)
7777
});
7878
}
7979

80-
Task IBrowserProcessServer.CloseHost()
80+
Task IOutOfProcessClientRpc.CloseHost()
8181
{
8282
return CefThread.ExecuteOnUiThread(() =>
8383
{
@@ -87,7 +87,7 @@ Task IBrowserProcessServer.CloseHost()
8787
});
8888
}
8989

90-
Task IBrowserProcessServer.CreateBrowser(IntPtr parentHwnd, string url, int id)
90+
Task IOutOfProcessClientRpc.CreateBrowser(IntPtr parentHwnd, string url, int id)
9191
{
9292
//Debugger.Break();
9393

CefSharp.OutOfProcess.BrowserProcess/OutOfProcessChromiumWebBrowser.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ public partial class OutOfProcessChromiumWebBrowser : IWebBrowserInternal
3535
/// <summary>
3636
/// JSON RPC used for IPC with host
3737
/// </summary>
38-
private IOutOfProcessServer outOfProcessServer;
38+
private IOutOfProcessHostRpc outOfProcessServer;
3939

4040
/// <summary>
4141
/// Flag to guard the creation of the underlying browser - only one instance can be created
@@ -670,7 +670,7 @@ public bool IsBrowserInitialized
670670
/// you have a chance to subscribe to the event as the CEF Browser is created async. (Issue https://github.com/cefsharp/CefSharp/issues/3552).
671671
/// </param>
672672
/// <exception cref="System.InvalidOperationException">Cef::Initialize() failed</exception>
673-
public OutOfProcessChromiumWebBrowser(IOutOfProcessServer outOfProcessServer, int id, string address = "",
673+
public OutOfProcessChromiumWebBrowser(IOutOfProcessHostRpc outOfProcessServer, int id, string address = "",
674674
IRequestContext requestContext = null)
675675
{
676676
_id = id;

CefSharp.OutOfProcess.Core/OutOfProcessHost.cs

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010

1111
namespace CefSharp.OutOfProcess
1212
{
13-
public class OutOfProcessHost : IOutOfProcessServer, IDisposable
13+
public class OutOfProcessHost : IOutOfProcessHostRpc, IDisposable
1414
{
1515
/// <summary>
1616
/// The CefSharp.OutOfProcess.BrowserProcess.exe name
@@ -19,7 +19,7 @@ public class OutOfProcessHost : IOutOfProcessServer, IDisposable
1919

2020
private Process _browserProcess;
2121
private JsonRpc _jsonRpc;
22-
private IBrowserProcessServer _browserProcessServer;
22+
private IOutOfProcessClientRpc _browserProcessServer;
2323
private string _cefSharpVersion;
2424
private string _cefVersion;
2525
private string _chromiumVersion;
@@ -117,31 +117,31 @@ private void Init()
117117

118118
_jsonRpc = JsonRpc.Attach(_browserProcess.StandardInput.BaseStream, _browserProcess.StandardOutput.BaseStream);
119119

120-
_browserProcessServer = _jsonRpc.Attach<IBrowserProcessServer>();
120+
_browserProcessServer = _jsonRpc.Attach<IOutOfProcessClientRpc>();
121121
_jsonRpc.AllowModificationWhileListening = true;
122-
_jsonRpc.AddLocalRpcTarget<IOutOfProcessServer>(this, null);
122+
_jsonRpc.AddLocalRpcTarget<IOutOfProcessHostRpc>(this, null);
123123
_jsonRpc.AllowModificationWhileListening = false;
124124

125125
_uiThreadId = Kernel32.GetCurrentThreadId();
126126
}
127127

128-
void IOutOfProcessServer.NotifyAddressChanged(int browserId, string address)
128+
void IOutOfProcessHostRpc.NotifyAddressChanged(int browserId, string address)
129129
{
130130
if (_browsers.TryGetValue(browserId, out var chromiumWebBrowser))
131131
{
132132
chromiumWebBrowser.SetAddress(address);
133133
}
134134
}
135135

136-
void IOutOfProcessServer.NotifyBrowserCreated(int browserId, IntPtr browserHwnd)
136+
void IOutOfProcessHostRpc.NotifyBrowserCreated(int browserId, IntPtr browserHwnd)
137137
{
138138
if (_browsers.TryGetValue(browserId, out var chromiumWebBrowser))
139139
{
140140
chromiumWebBrowser.SetBrowserHwnd(browserHwnd);
141141
}
142142
}
143143

144-
void IOutOfProcessServer.NotifyContextInitialized(int threadId, string cefSharpVersion, string cefVersion, string chromiumVersion)
144+
void IOutOfProcessHostRpc.NotifyContextInitialized(int threadId, string cefSharpVersion, string cefVersion, string chromiumVersion)
145145
{
146146
_remoteuiThreadId = threadId;
147147
_cefSharpVersion = cefSharpVersion;
@@ -151,47 +151,47 @@ void IOutOfProcessServer.NotifyContextInitialized(int threadId, string cefSharpV
151151
_processInitialized.TrySetResult(this);
152152
}
153153

154-
void IOutOfProcessServer.NotifyDevToolsAgentDetached(int browserId)
154+
void IOutOfProcessHostRpc.NotifyDevToolsAgentDetached(int browserId)
155155
{
156156
if (_browsers.TryGetValue(browserId, out var chromiumWebBrowser))
157157
{
158158

159159
}
160160
}
161161

162-
void IOutOfProcessServer.NotifyDevToolsMessage(int browserId, string devToolsMessage)
162+
void IOutOfProcessHostRpc.NotifyDevToolsMessage(int browserId, string devToolsMessage)
163163
{
164164
if (_browsers.TryGetValue(browserId, out var chromiumWebBrowser))
165165
{
166166
chromiumWebBrowser.OnDevToolsMessage(devToolsMessage);
167167
}
168168
}
169169

170-
void IOutOfProcessServer.NotifyDevToolsReady(int browserId)
170+
void IOutOfProcessHostRpc.NotifyDevToolsReady(int browserId)
171171
{
172172
if (_browsers.TryGetValue(browserId, out var chromiumWebBrowser))
173173
{
174174
chromiumWebBrowser.OnDevToolsReady();
175175
}
176176
}
177177

178-
void IOutOfProcessServer.NotifyLoadingStateChange(int browserId, bool canGoBack, bool canGoForward, bool isLoading)
178+
void IOutOfProcessHostRpc.NotifyLoadingStateChange(int browserId, bool canGoBack, bool canGoForward, bool isLoading)
179179
{
180180
if (_browsers.TryGetValue(browserId, out var chromiumWebBrowser))
181181
{
182182
chromiumWebBrowser.SetLoadingStateChange(canGoBack, canGoForward, isLoading);
183183
}
184184
}
185185

186-
void IOutOfProcessServer.NotifyStatusMessage(int browserId, string statusMessage)
186+
void IOutOfProcessHostRpc.NotifyStatusMessage(int browserId, string statusMessage)
187187
{
188188
if (_browsers.TryGetValue(browserId, out var chromiumWebBrowser))
189189
{
190190
chromiumWebBrowser.SetStatusMessage(statusMessage);
191191
}
192192
}
193193

194-
void IOutOfProcessServer.NotifyTitleChanged(int browserId, string title)
194+
void IOutOfProcessHostRpc.NotifyTitleChanged(int browserId, string title)
195195
{
196196
if (_browsers.TryGetValue(browserId, out var chromiumWebBrowser))
197197
{

CefSharp.OutOfProcess.Interface/IBrowserProcessServer.cs

Lines changed: 0 additions & 13 deletions
This file was deleted.
Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
using System;
2+
using System.Threading.Tasks;
3+
4+
namespace CefSharp.OutOfProcess.Interface
5+
{
6+
/// <summary>
7+
/// Send messages to the Remote Host (Browser process)
8+
/// </summary>
9+
public interface IOutOfProcessClientRpc
10+
{
11+
/// <summary>
12+
/// Close Browser
13+
/// </summary>
14+
/// <param name="browserId">browser Id</param>
15+
/// <returns>Task</returns>
16+
Task CloseBrowser(int browserId);
17+
18+
/// <summary>
19+
/// Send DevTools message
20+
/// </summary>
21+
/// <param name="browserId">browser Id</param>
22+
/// <param name="message"devtools message (json)></param>
23+
/// <returns></returns>
24+
Task SendDevToolsMessage(int browserId, string message);
25+
26+
/// <summary>
27+
/// Close the Browser Process (host)
28+
/// </summary>
29+
/// <returns>Task</returns>
30+
Task CloseHost();
31+
32+
/// <summary>
33+
/// Create a new browser within the Browser Process
34+
/// </summary>
35+
/// <param name="parentHwnd">parent Hwnd</param>
36+
/// <param name="url">start url</param>
37+
/// <param name="id">browser id</param>
38+
/// <returns>Task</returns>
39+
Task CreateBrowser(IntPtr parentHwnd, string url, int id);
40+
}
41+
}
Lines changed: 82 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,82 @@
1+
using System;
2+
3+
namespace CefSharp.OutOfProcess.Interface
4+
{
5+
/// <summary>
6+
/// Receive messages from the Remote Host (Browser process).
7+
/// Methods on this interface are invoked in response to messages
8+
/// originating from the Remote Host (browser process).
9+
/// </summary>
10+
public interface IOutOfProcessHostRpc
11+
{
12+
/// <summary>
13+
/// Invoked after the CEF browser has been created
14+
/// </summary>
15+
/// <param name="browserId">browser Id</param>
16+
/// <param name="browserHwnd">HWND</param>
17+
/// <returns>Task</returns>
18+
void NotifyBrowserCreated(int browserId, IntPtr browserHwnd);
19+
20+
/// <summary>
21+
/// Status message changed for the specified browser
22+
/// </summary>
23+
/// <param name="browserId">browser Id</param>
24+
/// <param name="statusMessage">status message</param>
25+
void NotifyStatusMessage(int browserId, string statusMessage);
26+
27+
/// <summary>
28+
/// DevTools agent was attached for the specified browser
29+
/// </summary>
30+
/// <param name="browserId">browser Id</param>
31+
void NotifyDevToolsAgentDetached(int browserId);
32+
33+
/// <summary>
34+
/// DevTools message was received from the specified browser
35+
/// </summary>
36+
/// <param name="browserId">browser Id</param>
37+
/// <param name="devToolsMessage">devtools message (json)</param>
38+
void NotifyDevToolsMessage(int browserId, string devToolsMessage);
39+
40+
/// <summary>
41+
/// DevTools is ready for the specified browser
42+
/// </summary>
43+
/// <param name="browserId">browser Id</param>
44+
void NotifyDevToolsReady(int browserId);
45+
46+
/// <summary>
47+
/// Adress changed for the specified browser
48+
/// </summary>
49+
/// <param name="browserId">browser Id</param>
50+
/// <param name="address">address</param>
51+
void NotifyAddressChanged(int browserId, string address);
52+
53+
/// <summary>
54+
/// Loading State changed for the specified browser.
55+
/// This will be called twice, once when the browser starts loading
56+
/// with <paramref name="isLoading"/> set to true and a second time
57+
/// with <paramref name="isLoading"/> set to false when the browser
58+
/// has finished loading.
59+
/// </summary>
60+
/// <param name="browserId">browser Id</param>
61+
/// <param name="canGoBack">can go back</param>
62+
/// <param name="canGoForward">can go forward</param>
63+
/// <param name="isLoading">is loading</param>
64+
void NotifyLoadingStateChange(int browserId, bool canGoBack, bool canGoForward, bool isLoading);
65+
66+
/// <summary>
67+
/// Title was changed for the specified browser
68+
/// </summary>
69+
/// <param name="browserId">browser Id</param>
70+
/// <param name="title">title</param>
71+
void NotifyTitleChanged(int browserId, string title);
72+
73+
/// <summary>
74+
/// Context has been initialized in the Remote Host (Browser Process)
75+
/// </summary>
76+
/// <param name="threadId">thread Id</param>
77+
/// <param name="cefSharpVersion">CefSharp Version</param>
78+
/// <param name="cefVersion">Cef Version</param>
79+
/// <param name="chromiumVersion">Chromium Version</param>
80+
void NotifyContextInitialized(int threadId, string cefSharpVersion, string cefVersion, string chromiumVersion);
81+
}
82+
}

CefSharp.OutOfProcess.Interface/IOutOfProcessServer.cs

Lines changed: 0 additions & 23 deletions
This file was deleted.

0 commit comments

Comments
 (0)