@@ -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,12 +119,12 @@ 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;
@@ -164,7 +164,7 @@ public class DiagnosticComponent : IDisposable
164164 // Add a filter for NetworkError. Pass "{}" to
165165 // receive all network errors without field-level
166166 // filtering.
167- _monitor.AddDiagnosticReceivedFilter (
167+ _monitor.SetDiagnosticFilter (
168168 CoreWebView2DiagnosticCategory.NetworkError,
169169 "{}");
170170
@@ -175,11 +175,11 @@ public class DiagnosticComponent : IDisposable
175175
176176 private void OnDiagnosticReceived(
177177 CoreWebView2DiagnosticMonitor sender,
178- CoreWebView2DiagnosticEventArgs args)
178+ CoreWebView2DiagnosticReceivedEventArgs args)
179179 {
180180 CoreWebView2DiagnosticCategory category =
181181 args.Category;
182- CoreWebView2DiagnosticSourceScope scope =
182+ CoreWebView2DiagnosticScope scope =
183183 args.Scope;
184184 long timestamp = args.Timestamp;
185185 string detailsJson =
@@ -207,7 +207,7 @@ public class DiagnosticComponent : IDisposable
207207
208208## Filter with field-level JSON criteria
209209
210- You can pass a JSON object to ` AddDiagnosticReceivedFilter ` to
210+ You can pass a JSON object to ` SetDiagnosticFilter ` to
211211restrict which events are delivered. An empty JSON object ` "{}" ` receives
212212all events in that category. A non-empty JSON object applies field-level
213213matching. Calling the method again for the same category replaces
@@ -225,7 +225,7 @@ void DiagnosticComponent::SetupFilteredDiagnostics()
225225 // and timeout (ERR_TIMED_OUT, -7) errors
226226 // for GET/POST requests from the "Default" profile.
227227 CHECK_FAILURE (
228- m_monitor->AddDiagnosticReceivedFilter (
228+ m_monitor->SetDiagnosticFilter (
229229 COREWEBVIEW2_DIAGNOSTIC_CATEGORY_NETWORK_ERROR,
230230 LR"({
231231 "profileName": "Default",
@@ -238,7 +238,7 @@ void DiagnosticComponent::SetupFilteredDiagnostics()
238238 ICoreWebView2DiagnosticReceivedEventHandler>(
239239 [ this] (
240240 ICoreWebView2DiagnosticMonitor* sender,
241- ICoreWebView2DiagnosticEventArgs * args)
241+ ICoreWebView2DiagnosticReceivedEventArgs * args)
242242 -> HRESULT
243243 {
244244 HandleDiagnosticEvent(args);
@@ -261,7 +261,7 @@ private void SetupFilteredDiagnostics()
261261 // Only DNS (ERR_NAME_NOT_RESOLVED, -105) and timeout
262262 // (ERR_TIMED_OUT, -7) errors for GET/POST requests
263263 // from the "Default" profile.
264- _monitor .AddDiagnosticReceivedFilter (
264+ _monitor .SetDiagnosticFilter (
265265 CoreWebView2DiagnosticCategory .NetworkError ,
266266 @" {
267267 "" profileName"" : "" Default"" ,
@@ -292,28 +292,27 @@ typedef enum COREWEBVIEW2_DIAGNOSTIC_CATEGORY {
292292
293293/// Specifies the scope that originated a diagnostic event.
294294[v1_enum]
295- typedef enum COREWEBVIEW2_DIAGNOSTIC_SOURCE_SCOPE {
295+ typedef enum COREWEBVIEW2_DIAGNOSTIC_SCOPE {
296296 /// The diagnostic signal originated from a specific
297297 /// WebView instance.
298- COREWEBVIEW2_DIAGNOSTIC_SOURCE_SCOPE_WEB_VIEW ,
298+ COREWEBVIEW2_DIAGNOSTIC_SCOPE_WEB_VIEW ,
299299
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,
300+ /// The diagnostic signal originated from a profile
301+ /// but is not tied to a specific WebView.
302+ COREWEBVIEW2_DIAGNOSTIC_SCOPE_PROFILE,
304303
305304 /// The diagnostic signal originated from the environment
306305 /// (for example, a browser-wide event that affects all
307306 /// WebViews).
308- COREWEBVIEW2_DIAGNOSTIC_SOURCE_SCOPE_ENVIRONMENT ,
309- } COREWEBVIEW2_DIAGNOSTIC_SOURCE_SCOPE ;
307+ COREWEBVIEW2_DIAGNOSTIC_SCOPE_ENVIRONMENT ,
308+ } COREWEBVIEW2_DIAGNOSTIC_SCOPE ;
310309
311310/// Event args for the `DiagnosticReceived` event on
312311/// `ICoreWebView2DiagnosticMonitor`. Each instance
313312/// represents a single diagnostic signal.
314313[uuid(A1B2C3D4-E5F6-7890-ABCD-EF1234567890),
315314 object, pointer_default(unique)]
316- interface ICoreWebView2DiagnosticEventArgs : IUnknown {
315+ interface ICoreWebView2DiagnosticReceivedEventArgs : IUnknown {
317316 /// The diagnostic category that this event belongs to.
318317 [propget] HRESULT Category(
319318 [out, retval]
@@ -322,7 +321,7 @@ interface ICoreWebView2DiagnosticEventArgs : IUnknown {
322321 /// The scope that originated this diagnostic signal.
323322 [propget] HRESULT Scope(
324323 [out, retval]
325- COREWEBVIEW2_DIAGNOSTIC_SOURCE_SCOPE * value);
324+ COREWEBVIEW2_DIAGNOSTIC_SCOPE * value);
326325
327326 /// Monotonic timestamp in microseconds since an
328327 /// unspecified epoch. You can use this value to order
@@ -335,7 +334,7 @@ interface ICoreWebView2DiagnosticEventArgs : IUnknown {
335334 ///
336335 /// The `category` parameter must match the value
337336 /// returned by `get_Category`. If a different category
338- /// is passed, the method returns `"{}" `.
337+ /// is passed, the method returns `E_INVALIDARG `.
339338 ///
340339 /// For `COREWEBVIEW2_DIAGNOSTIC_CATEGORY_NETWORK_ERROR`
341340 /// the JSON schema is:
@@ -377,7 +376,7 @@ interface ICoreWebView2DiagnosticReceivedEventHandler
377376 /// Provides the event args for the corresponding event.
378377 HRESULT Invoke(
379378 [in] ICoreWebView2DiagnosticMonitor* sender,
380- [in] ICoreWebView2DiagnosticEventArgs * args);
379+ [in] ICoreWebView2DiagnosticReceivedEventArgs * args);
381380}
382381
383382/// A diagnostic monitor that receives diagnostic signals
@@ -392,11 +391,17 @@ interface ICoreWebView2DiagnosticReceivedEventHandler
392391/// The monitor is active from creation until it is
393392/// released. Releasing the monitor automatically stops all
394393/// events and clears all filters.
394+ ///
395+ /// All members of this interface must be called on the
396+ /// same thread that created the
397+ /// `ICoreWebView2Environment`. Calling from a different
398+ /// thread returns `RPC_E_WRONG_THREAD`. Handlers must
399+ /// not block this thread.
395400[uuid(E4F5A6B7-C8D9-0123-ABCD-456789012345),
396401 object, pointer_default(unique)]
397402interface ICoreWebView2DiagnosticMonitor : IUnknown {
398403
399- /// Adds a diagnostic filter for the specified category.
404+ /// Sets a diagnostic filter for the specified category.
400405 /// After this call, `DiagnosticReceived` will fire for
401406 /// events in this category that match the JSON criteria.
402407 ///
@@ -433,24 +438,24 @@ interface ICoreWebView2DiagnosticMonitor : IUnknown {
433438 ///
434439 /// Returns `E_INVALIDARG` if the JSON is malformed.
435440 /// On failure, the filter state is unchanged.
436- HRESULT AddDiagnosticReceivedFilter (
441+ HRESULT SetDiagnosticFilter (
437442 [in] COREWEBVIEW2_DIAGNOSTIC_CATEGORY category,
438443 [in] LPCWSTR jsonFilter);
439444
440445 /// Removes the diagnostic filter for the specified
441446 /// category. After this call, `DiagnosticReceived`
442447 /// will no longer fire for events in this category.
443448 ///
444- /// If no filter was previously added for the category,
449+ /// If no filter was previously set for the category,
445450 /// this method is a no-op and returns `S_OK`.
446- HRESULT RemoveDiagnosticReceivedFilter (
451+ HRESULT RemoveDiagnosticFilter (
447452 [in] COREWEBVIEW2_DIAGNOSTIC_CATEGORY category);
448453
449454 /// Subscribes to diagnostic events on this monitor.
450455 /// The handler is invoked on the thread that created
451456 /// the environment. It fires every time a diagnostic
452- /// signal passes a filter added with
453- /// `AddDiagnosticReceivedFilter `.
457+ /// signal passes a filter set with
458+ /// `SetDiagnosticFilter `.
454459 ///
455460 /// Multiple handlers can be registered. They are
456461 /// invoked in registration order.
@@ -479,8 +484,8 @@ interface ICoreWebView2Environment17
479484 /// panel to operate without interfering with each other.
480485 ///
481486 /// The monitor is active immediately, but no events fire
482- /// until a filter is added via
483- /// `AddDiagnosticReceivedFilter `.
487+ /// until a filter is set via
488+ /// `SetDiagnosticFilter `.
484489 ///
485490 /// Release the monitor to stop receiving events and
486491 /// free resources.
@@ -505,7 +510,7 @@ namespace Microsoft.Web.WebView2.Core
505510
506511 /// Specifies the scope that originated a diagnostic
507512 /// event.
508- enum CoreWebView2DiagnosticSourceScope
513+ enum CoreWebView2DiagnosticScope
509514 {
510515 /// Signal from a specific WebView instance.
511516 WebView = 0 ,
@@ -518,10 +523,10 @@ namespace Microsoft.Web.WebView2.Core
518523 };
519524
520525 /// Event args for the DiagnosticReceived event.
521- runtimeclass CoreWebView2DiagnosticEventArgs
526+ runtimeclass CoreWebView2DiagnosticReceivedEventArgs
522527 {
523528 CoreWebView2DiagnosticCategory Category { get; };
524- CoreWebView2DiagnosticSourceScope Scope { get ; };
529+ CoreWebView2DiagnosticScope Scope { get ; };
525530 Int64 Timestamp { get ; };
526531
527532 /// Returns category-specific data as a JSON
@@ -537,16 +542,16 @@ namespace Microsoft.Web.WebView2.Core
537542 runtimeclass CoreWebView2DiagnosticMonitor
538543 : Windows .Foundation .IClosable
539544 {
540- void AddDiagnosticReceivedFilter (
545+ void SetDiagnosticFilter (
541546 CoreWebView2DiagnosticCategory category ,
542547 String jsonFilter );
543548
544- void RemoveDiagnosticReceivedFilter (
549+ void RemoveDiagnosticFilter (
545550 CoreWebView2DiagnosticCategory category );
546551
547552 event Windows .Foundation .TypedEventHandler <
548553 CoreWebView2DiagnosticMonitor ,
549- CoreWebView2DiagnosticEventArgs >
554+ CoreWebView2DiagnosticReceivedEventArgs >
550555 DiagnosticReceived ;
551556 }
552557
0 commit comments