Skip to content

Commit d91874a

Browse files
authored
Update and rename TryUpdateRuntime.md to UpdateRuntime.md
1 parent d34b060 commit d91874a

1 file changed

Lines changed: 27 additions & 24 deletions

File tree

Lines changed: 27 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,15 @@
11
# Background
2-
The new version of an app might requires a newer version of Edge WebView2 Runtime. The app updater might want to ensure that the newer version of Edge WebView2 Runtime
3-
is installed before updating the app to the newer version. The app could also update to newer version with some feature disabled, and then request update so that it
4-
could move to newer version of Edge WebView2 Runtime and enable those features faster.
2+
The new version of an app might require a newer version of Edge WebView2 Runtime.
3+
4+
An app updater may wish to ensure that a particular minimum version of the Edge WebView2 Runtime is installed before upgrading the app to a version that requires those features.
5+
6+
Alternatively, the newer version of the app could use feature detection to disable portions of the app that rely on new WebView2 Runtime features. In this alternate scenario, the app updater would install the new version of the app immediately, and then request that the Edge WebView2 Runtime be updated, so that the updated app can start taking advantage of the new features.
7+
58
Edge WebView2 Runtime is auto updated and normally the latest version should be already installed. However, there could be cases that we need trigger Edge WebView2 Runtime
6-
update to ensure coordinated app and runtime update.
9+
update to ensure coordinated app and WebView2 Runtime update.
710

811
# Description
9-
You may call the `TryUpdateRuntime` API to check and install updates to installed Edge WebView2 Runtime. This is useful when the app wants to coordinate app and
12+
You may call the `UpdateRuntime` API to check and install updates to installed Edge WebView2 Runtime. This is useful when the app wants to coordinate app and
1013
Edge WebView2 Runtime update.
1114

1215
# Examples
@@ -19,12 +22,12 @@ async protected bool EnsureWebView2RuntimeVersion(string minimalVersionRequired)
1922
if (CoreWebView2Environment.CompareBrowserVersions(currentRuntimeVersion, minimalVersionRequired) < 0)
2023
{
2124
auto environment = await CoreWebView2Environment.CreateAsync();
22-
auto updateResult = await environment.TryUpdateRuntimeAsync();
25+
auto updateResult = await environment.UpdateRuntimeAsync();
2326
if (updateResult.UpdateRuntimeStatus != CoreWebView2RuntimeUpdateStatus.Updated)
2427
return false;
28+
// check runtime version again
29+
currentRuntimeVersion = CoreWebView2Environment.GetAvailableBrowserVersionString();
2530
}
26-
// check runtime version again
27-
currentRuntimeVersion = CoreWebView2Environment.GetAvailableBrowserVersionString();
2831
return (CoreWebView2Environment.CompareBrowserVersions(currentRuntimeVersion, minimalVersionRequired) >= 0);
2932
}
3033

@@ -74,8 +77,8 @@ void EnsureWebView2RuntimeVersion(std::function<void(bool)> const& callback, std
7477
wil::com_ptr<ICoreWebView2Environment> webViewEnvironment = environment;
7578
auto experimentalEnvironment3 =
7679
webViewEnvironment.try_query<ICoreWebView2ExperimentalEnvironment3>();
77-
HRESULT hr = experimentalEnvironment3->TryUpdateRuntime(
78-
Callback<ICoreWebView2ExperimentalTryUpdateRuntimeCompletedHandler>(
80+
HRESULT hr = experimentalEnvironment3->UpdateRuntime(
81+
Callback<ICoreWebView2ExperimentalUpdateRuntimeCompletedHandler>(
7982
[callback, minimalVersionRequired, experimentalEnvironment3](HRESULT errorCode,
8083
ICoreWebView2ExperimentalUpdateRuntimeResult* result) -> HRESULT {
8184
COREWEBVIEW2_RUNTIME_UPDATE_STATUS updateStatus =
@@ -112,7 +115,7 @@ See [API Details](#api-details) section below for API reference.
112115
113116
## Win32 C++
114117
```IDL
115-
/// Status of TryUpdateRuntime operation result.
118+
/// Status of UpdateRuntime operation result.
116119
[v1_enum] typedef enum COREWEBVIEW2_UPDATE_RUNTIME_STATUS {
117120
118121
/// No update for Edge WebView2 Runtime is available.
@@ -132,23 +135,23 @@ See [API Details](#api-details) section below for API reference.
132135
} COREWEBVIEW2_UPDATE_RUNTIME_STATUS;
133136
134137
135-
/// The TryUpdateRuntime operation result.
138+
/// The UpdateRuntime operation result.
136139
[uuid(DD503E49-AB19-47C0-B2AD-6DDD09CC3E3A), object, pointer_default(unique)]
137140
interface ICoreWebView2ExperimentalUpdateRuntimeResult : IUnknown {
138141
139-
/// The status for the TryUpdateRuntime operation.
142+
/// The status for the UpdateRuntime operation.
140143
[propget] HRESULT Status(
141144
[ out, retval ] COREWEBVIEW2_UPDATE_RUNTIME_STATUS * status);
142145
143146
/// The update error happened while trying to update Edge WebView2 Runtime.
144147
[propget] HRESULT UpdateError([out, retval] HRESULT* updateError);
145148
}
146149
147-
/// The caller implements this interface to receive the TryUpdateRuntime result.
150+
/// The caller implements this interface to receive the UpdateRuntime result.
148151
[uuid(F1D2D722-3721-499C-87F5-4C405260697A), object, pointer_default(unique)]
149-
interface ICoreWebView2ExperimentalTryUpdateRuntimeCompletedHandler : IUnknown {
152+
interface ICoreWebView2ExperimentalUpdateRuntimeCompletedHandler : IUnknown {
150153
151-
/// Provides the result for the TryUpdateRuntime operation.
154+
/// Provides the result for the UpdateRuntime operation.
152155
/// `errorCode` will be S_OK if the update operation can be performed
153156
/// normally, regardless of whether we could update the Edge WebView2
154157
/// Runtime. If an unexpected error interrupts the update operation, error
@@ -169,31 +172,31 @@ interface ICoreWebView2ExperimentalEnvironment3 : IUnknown {
169172
/// This will potentially result in a new version of the Edge WebView2
170173
/// Runtime being installed and `NewBrowserVersionAvailable` event being raised.
171174
/// There is no guarantee on the order of that event being raised and
172-
/// TryUpdateRuntime's completed handler being invoked. Besides the
175+
/// UpdateRuntime's completed handler being invoked. Besides the
173176
/// `NewBrowserVersionAvailable` event, there will be no impact to any
174177
/// currently running WebView2s when the update is installed.
175178
/// The latest version can always be queried using the
176179
/// `GetAvailableCoreWebView2BrowserVersionString` API.
177-
/// The TryUpdateRuntime method is only supported for an installed Edge WebView2
180+
/// The UpdateRuntime method is only supported for an installed Edge WebView2
178181
/// Runtime. When running a fixed version Edge WebView2 Runtime or non stable
179182
/// channel Edge browser, this API will return `HRESULT_FROM_WIN32(ERROR_NOT_SUPPORTED)`.
180-
/// There could only be one active TryUpdateRuntime operation, calling this API
183+
/// There could only be one active UpdateRuntime operation, calling this API
181184
/// before completed handler for previous call is invoked will fail with
182185
/// `HRESULT_FROM_WIN32(ERROR_BUSY)`.
183186
/// Calling this API repeatedly in a short period of time, will also fail with
184187
/// `HRESULT_FROM_WIN32(ERROR_BUSY)`. Don't call the API more than 3 times
185188
/// within 5 minutes.
186-
/// The TryUpdateRuntime operation is associated with the CoreWebView2Environment
187-
/// object and any ongoing TryUpdateRuntime operation will be aborted when the
189+
/// The UpdateRuntime operation is associated with the CoreWebView2Environment
190+
/// object and any ongoing UpdateRuntime operation will be aborted when the
188191
/// associated CoreWebView2Environment along with the CoreWebView2 objects that
189192
/// are created by the CoreWebView2Environment object are all released. In this
190193
/// case, the completed handler will be invoked with `S_OK` as `errorCode` and a
191194
/// result object with `Status` of COREWEBVIEW2_UPDATE_RUNTIME_STATUS_FAILED and
192195
/// `UpdateError` as `E_ABORT`.
193196
///
194197
/// \snippet AppWindow.cpp UpdateRuntime
195-
HRESULT TryUpdateRuntime(
196-
[in] ICoreWebView2ExperimentalTryUpdateRuntimeCompletedHandler *
198+
HRESULT UpdateRuntime(
199+
[in] ICoreWebView2ExperimentalUpdateRuntimeCompletedHandler *
197200
handler);
198201
}
199202
```
@@ -223,7 +226,7 @@ namespace Microsoft.Web.WebView2.Core
223226

224227
public partial class CoreWebView2Environment
225228
{
226-
public async Task<CoreWebView2UpdateRuntimeResult> TryUpdateRuntimeAsync()
229+
public async Task<CoreWebView2UpdateRuntimeResult> UpdateRuntimeAsync()
227230
}
228231
}
229232
```

0 commit comments

Comments
 (0)