@@ -14,7 +14,7 @@ The Diagnostic Monitor API introduces an observation-only monitor
1414object that delivers diagnostic signals from all layers — WebView,
1515Profile, and Environment — through a single ` DiagnosticReceived `
1616event. Host apps create a monitor from the environment and opt in
17- per category using ` AddDiagnosticReceivedFilter ` .
17+ per category using ` SetDiagnosticFilter ` .
1818
1919
2020# Description
@@ -23,7 +23,7 @@ You create an `ICoreWebView2DiagnosticMonitor` from the environment
2323using ` CreateDiagnosticMonitor ` . The monitor observes diagnostic
2424signals across all WebViews, profiles, and the environment itself.
2525You control which categories of events are delivered by calling
26- ` AddDiagnosticReceivedFilter ` with a category and an optional JSON
26+ ` SetDiagnosticFilter ` with a category and an optional JSON
2727filter string.
2828
2929Key scenarios:
@@ -60,7 +60,7 @@ public:
6060private:
6161 void SetupDiagnostics();
6262 void HandleDiagnosticEvent(
63- ICoreWebView2DiagnosticEventArgs * args);
63+ ICoreWebView2DiagnosticReceivedEventArgs * args);
6464
6565 wil::com_ptr<ICoreWebView2Environment17> m_environment;
6666 wil::com_ptr<ICoreWebView2DiagnosticMonitor> m_monitor;
@@ -98,7 +98,7 @@ void DiagnosticComponent::SetupDiagnostics()
9898 // Add a filter for NETWORK_ERROR. Pass "{}" to receive
9999 // all network errors without field-level filtering.
100100 CHECK_FAILURE(
101- m_monitor->AddDiagnosticReceivedFilter (
101+ m_monitor->SetDiagnosticFilter (
102102 COREWEBVIEW2_DIAGNOSTIC_CATEGORY_NETWORK_ERROR,
103103 L"{}"));
104104
@@ -108,7 +108,7 @@ void DiagnosticComponent::SetupDiagnostics()
108108 ICoreWebView2DiagnosticReceivedEventHandler>(
109109 [this](
110110 ICoreWebView2DiagnosticMonitor* sender,
111- ICoreWebView2DiagnosticEventArgs * args)
111+ ICoreWebView2DiagnosticReceivedEventArgs * args)
112112 -> HRESULT
113113 {
114114 HandleDiagnosticEvent(args);
@@ -119,17 +119,16 @@ void DiagnosticComponent::SetupDiagnostics()
119119}
120120
121121void DiagnosticComponent::HandleDiagnosticEvent(
122- ICoreWebView2DiagnosticEventArgs * args)
122+ ICoreWebView2DiagnosticReceivedEventArgs * args)
123123{
124124 COREWEBVIEW2_DIAGNOSTIC_CATEGORY category;
125125 CHECK_FAILURE(args->get_Category(&category));
126126
127- COREWEBVIEW2_DIAGNOSTIC_SOURCE_SCOPE scope;
127+ COREWEBVIEW2_DIAGNOSTIC_SCOPE scope;
128128 CHECK_FAILURE(args->get_Scope(&scope));
129129
130130 wil::unique_cotaskmem_string detailsJson;
131- CHECK_FAILURE(args->GetCategoryDetailsAsJson(
132- category, &detailsJson));
131+ CHECK_FAILURE(args->GetDetailsAsJson(&detailsJson));
133132
134133 INT64 timestamp = 0;
135134 CHECK_FAILURE(args->get_Timestamp(×tamp));
@@ -164,7 +163,7 @@ public class DiagnosticComponent : IDisposable
164163 // Add a filter for NetworkError. Pass "{}" to
165164 // receive all network errors without field-level
166165 // filtering.
167- _monitor.AddDiagnosticReceivedFilter (
166+ _monitor.SetDiagnosticFilter (
168167 CoreWebView2DiagnosticCategory.NetworkError,
169168 "{}");
170169
@@ -175,15 +174,15 @@ public class DiagnosticComponent : IDisposable
175174
176175 private void OnDiagnosticReceived(
177176 CoreWebView2DiagnosticMonitor sender,
178- CoreWebView2DiagnosticEventArgs args)
177+ CoreWebView2DiagnosticReceivedEventArgs args)
179178 {
180179 CoreWebView2DiagnosticCategory category =
181180 args.Category;
182- CoreWebView2DiagnosticSourceScope scope =
181+ CoreWebView2DiagnosticScope scope =
183182 args.Scope;
184183 long timestamp = args.Timestamp;
185184 string detailsJson =
186- args.GetCategoryDetailsAsJson(category );
185+ args.GetDetailsAsJson( );
187186
188187 Debug.WriteLine(
189188 $"[Diagnostic] category={category} " +
@@ -207,7 +206,7 @@ public class DiagnosticComponent : IDisposable
207206
208207## Filter with field-level JSON criteria
209208
210- You can pass a JSON object to ` AddDiagnosticReceivedFilter ` to
209+ You can pass a JSON object to ` SetDiagnosticFilter ` to
211210restrict which events are delivered. An empty JSON object ` "{}" ` receives
212211all events in that category. A non-empty JSON object applies field-level
213212matching. Calling the method again for the same category replaces
@@ -225,7 +224,7 @@ void DiagnosticComponent::SetupFilteredDiagnostics()
225224 // and timeout (ERR_TIMED_OUT, -7) errors
226225 // for GET/POST requests from the "Default" profile.
227226 CHECK_FAILURE (
228- m_monitor->AddDiagnosticReceivedFilter (
227+ m_monitor->SetDiagnosticFilter (
229228 COREWEBVIEW2_DIAGNOSTIC_CATEGORY_NETWORK_ERROR,
230229 LR"({
231230 "profileName": "Default",
@@ -238,7 +237,7 @@ void DiagnosticComponent::SetupFilteredDiagnostics()
238237 ICoreWebView2DiagnosticReceivedEventHandler>(
239238 [ this] (
240239 ICoreWebView2DiagnosticMonitor* sender,
241- ICoreWebView2DiagnosticEventArgs * args)
240+ ICoreWebView2DiagnosticReceivedEventArgs * args)
242241 -> HRESULT
243242 {
244243 HandleDiagnosticEvent(args);
@@ -261,7 +260,7 @@ private void SetupFilteredDiagnostics()
261260 // Only DNS (ERR_NAME_NOT_RESOLVED, -105) and timeout
262261 // (ERR_TIMED_OUT, -7) errors for GET/POST requests
263262 // from the "Default" profile.
264- _monitor .AddDiagnosticReceivedFilter (
263+ _monitor .SetDiagnosticFilter (
265264 CoreWebView2DiagnosticCategory .NetworkError ,
266265 @" {
267266 "" profileName"" : "" Default"" ,
@@ -292,28 +291,27 @@ typedef enum COREWEBVIEW2_DIAGNOSTIC_CATEGORY {
292291
293292/// Specifies the scope that originated a diagnostic event.
294293[v1_enum]
295- typedef enum COREWEBVIEW2_DIAGNOSTIC_SOURCE_SCOPE {
294+ typedef enum COREWEBVIEW2_DIAGNOSTIC_SCOPE {
296295 /// The diagnostic signal originated from a specific
297296 /// WebView instance.
298- COREWEBVIEW2_DIAGNOSTIC_SOURCE_SCOPE_WEB_VIEW ,
297+ COREWEBVIEW2_DIAGNOSTIC_SCOPE_WEB_VIEW ,
299298
300- /// The diagnostic signal originated from a profile or
301- /// its underlying network context but is not tied to a
302- /// specific WebView.
303- COREWEBVIEW2_DIAGNOSTIC_SOURCE_SCOPE_PROFILE,
299+ /// The diagnostic signal originated from a profile
300+ /// but is not tied to a specific WebView.
301+ COREWEBVIEW2_DIAGNOSTIC_SCOPE_PROFILE,
304302
305303 /// The diagnostic signal originated from the environment
306304 /// (for example, a browser-wide event that affects all
307305 /// WebViews).
308- COREWEBVIEW2_DIAGNOSTIC_SOURCE_SCOPE_ENVIRONMENT ,
309- } COREWEBVIEW2_DIAGNOSTIC_SOURCE_SCOPE ;
306+ COREWEBVIEW2_DIAGNOSTIC_SCOPE_ENVIRONMENT ,
307+ } COREWEBVIEW2_DIAGNOSTIC_SCOPE ;
310308
311309/// Event args for the `DiagnosticReceived` event on
312310/// `ICoreWebView2DiagnosticMonitor`. Each instance
313311/// represents a single diagnostic signal.
314312[uuid(A1B2C3D4-E5F6-7890-ABCD-EF1234567890),
315313 object, pointer_default(unique)]
316- interface ICoreWebView2DiagnosticEventArgs : IUnknown {
314+ interface ICoreWebView2DiagnosticReceivedEventArgs : IUnknown {
317315 /// The diagnostic category that this event belongs to.
318316 [propget] HRESULT Category(
319317 [out, retval]
@@ -322,7 +320,7 @@ interface ICoreWebView2DiagnosticEventArgs : IUnknown {
322320 /// The scope that originated this diagnostic signal.
323321 [propget] HRESULT Scope(
324322 [out, retval]
325- COREWEBVIEW2_DIAGNOSTIC_SOURCE_SCOPE * value);
323+ COREWEBVIEW2_DIAGNOSTIC_SCOPE * value);
326324
327325 /// Monotonic timestamp in microseconds since an
328326 /// unspecified epoch. You can use this value to order
@@ -331,11 +329,7 @@ interface ICoreWebView2DiagnosticEventArgs : IUnknown {
331329 [out, retval] INT64* value);
332330
333331 /// Returns category-specific diagnostic data as a JSON
334- /// string for the specified category.
335- ///
336- /// The `category` parameter must match the value
337- /// returned by `get_Category`. If a different category
338- /// is passed, the method returns `"{}"`.
332+ /// string.
339333 ///
340334 /// For `COREWEBVIEW2_DIAGNOSTIC_CATEGORY_NETWORK_ERROR`
341335 /// the JSON schema is:
@@ -363,8 +357,7 @@ interface ICoreWebView2DiagnosticEventArgs : IUnknown {
363357 /// this method returns `"{}"`.
364358 ///
365359 /// Free the returned string with `CoTaskMemFree`.
366- HRESULT GetCategoryDetailsAsJson(
367- [in] COREWEBVIEW2_DIAGNOSTIC_CATEGORY category,
360+ HRESULT GetDetailsAsJson(
368361 [out, retval] LPWSTR* value);
369362}
370363
@@ -377,7 +370,7 @@ interface ICoreWebView2DiagnosticReceivedEventHandler
377370 /// Provides the event args for the corresponding event.
378371 HRESULT Invoke(
379372 [in] ICoreWebView2DiagnosticMonitor* sender,
380- [in] ICoreWebView2DiagnosticEventArgs * args);
373+ [in] ICoreWebView2DiagnosticReceivedEventArgs * args);
381374}
382375
383376/// A diagnostic monitor that receives diagnostic signals
@@ -392,11 +385,17 @@ interface ICoreWebView2DiagnosticReceivedEventHandler
392385/// The monitor is active from creation until it is
393386/// released. Releasing the monitor automatically stops all
394387/// events and clears all filters.
388+ ///
389+ /// All members of this interface must be called on the
390+ /// same thread that created the
391+ /// `ICoreWebView2Environment`. Calling from a different
392+ /// thread returns `RPC_E_WRONG_THREAD`. Handlers must
393+ /// not block this thread.
395394[uuid(E4F5A6B7-C8D9-0123-ABCD-456789012345),
396395 object, pointer_default(unique)]
397396interface ICoreWebView2DiagnosticMonitor : IUnknown {
398397
399- /// Adds a diagnostic filter for the specified category.
398+ /// Sets a diagnostic filter for the specified category.
400399 /// After this call, `DiagnosticReceived` will fire for
401400 /// events in this category that match the JSON criteria.
402401 ///
@@ -433,24 +432,24 @@ interface ICoreWebView2DiagnosticMonitor : IUnknown {
433432 ///
434433 /// Returns `E_INVALIDARG` if the JSON is malformed.
435434 /// On failure, the filter state is unchanged.
436- HRESULT AddDiagnosticReceivedFilter (
435+ HRESULT SetDiagnosticFilter (
437436 [in] COREWEBVIEW2_DIAGNOSTIC_CATEGORY category,
438437 [in] LPCWSTR jsonFilter);
439438
440439 /// Removes the diagnostic filter for the specified
441440 /// category. After this call, `DiagnosticReceived`
442441 /// will no longer fire for events in this category.
443442 ///
444- /// If no filter was previously added for the category,
443+ /// If no filter was previously set for the category,
445444 /// this method is a no-op and returns `S_OK`.
446- HRESULT RemoveDiagnosticReceivedFilter (
445+ HRESULT RemoveDiagnosticFilter (
447446 [in] COREWEBVIEW2_DIAGNOSTIC_CATEGORY category);
448447
449448 /// Subscribes to diagnostic events on this monitor.
450449 /// The handler is invoked on the thread that created
451450 /// the environment. It fires every time a diagnostic
452- /// signal passes a filter added with
453- /// `AddDiagnosticReceivedFilter `.
451+ /// signal passes a filter set with
452+ /// `SetDiagnosticFilter `.
454453 ///
455454 /// Multiple handlers can be registered. They are
456455 /// invoked in registration order.
@@ -479,8 +478,8 @@ interface ICoreWebView2Environment17
479478 /// panel to operate without interfering with each other.
480479 ///
481480 /// The monitor is active immediately, but no events fire
482- /// until a filter is added via
483- /// `AddDiagnosticReceivedFilter `.
481+ /// until a filter is set via
482+ /// `SetDiagnosticFilter `.
484483 ///
485484 /// Release the monitor to stop receiving events and
486485 /// free resources.
@@ -505,7 +504,7 @@ namespace Microsoft.Web.WebView2.Core
505504
506505 /// Specifies the scope that originated a diagnostic
507506 /// event.
508- enum CoreWebView2DiagnosticSourceScope
507+ enum CoreWebView2DiagnosticScope
509508 {
510509 /// Signal from a specific WebView instance.
511510 WebView = 0 ,
@@ -518,17 +517,16 @@ namespace Microsoft.Web.WebView2.Core
518517 };
519518
520519 /// Event args for the DiagnosticReceived event.
521- runtimeclass CoreWebView2DiagnosticEventArgs
520+ runtimeclass CoreWebView2DiagnosticReceivedEventArgs
522521 {
523522 CoreWebView2DiagnosticCategory Category { get; };
524- CoreWebView2DiagnosticSourceScope Scope { get ; };
523+ CoreWebView2DiagnosticScope Scope { get ; };
525524 Int64 Timestamp { get ; };
526525
527526 /// Returns category-specific data as a JSON
528527 /// string. Returns "{}" for unrecognized
529528 /// categories.
530- String GetCategoryDetailsAsJson (
531- CoreWebView2DiagnosticCategory category );
529+ String GetDetailsAsJson ();
532530 }
533531
534532 /// A diagnostic monitor that receives signals from
@@ -537,16 +535,16 @@ namespace Microsoft.Web.WebView2.Core
537535 runtimeclass CoreWebView2DiagnosticMonitor
538536 : Windows .Foundation .IClosable
539537 {
540- void AddDiagnosticReceivedFilter (
538+ void SetDiagnosticFilter (
541539 CoreWebView2DiagnosticCategory category ,
542540 String jsonFilter );
543541
544- void RemoveDiagnosticReceivedFilter (
542+ void RemoveDiagnosticFilter (
545543 CoreWebView2DiagnosticCategory category );
546544
547545 event Windows .Foundation .TypedEventHandler <
548546 CoreWebView2DiagnosticMonitor ,
549- CoreWebView2DiagnosticEventArgs >
547+ CoreWebView2DiagnosticReceivedEventArgs >
550548 DiagnosticReceived ;
551549 }
552550
0 commit comments