Changeset 244307 in webkit
- Timestamp:
- Apr 15, 2019, 4:48:55 PM (6 years ago)
- Location:
- trunk
- Files:
-
- 25 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/WebCore/ChangeLog
r244297 r244307 1 2019-04-15 Jer Noble <jer.noble@apple.com> 2 3 Add a DiagnosticLogging method taking an arbitrary dictionary of values. 4 https://bugs.webkit.org/show_bug.cgi?id=196773 5 6 Reviewed by Alex Christensen. 7 8 * page/DiagnosticLoggingClient.h: 9 1 10 2019-04-15 Justin Fan <justin_fan@apple.com> 2 11 -
trunk/Source/WebCore/loader/EmptyClients.cpp
r242920 r244307 132 132 void logDiagnosticMessageWithValue(const String&, const String&, double, unsigned, ShouldSample) final { } 133 133 void logDiagnosticMessageWithEnhancedPrivacy(const String&, const String&, ShouldSample) final { } 134 void logDiagnosticMessageWithValueDictionary(const String&, const String&, const ValueDictionary&, ShouldSample) final { } 134 135 }; 135 136 -
trunk/Source/WebCore/page/DiagnosticLoggingClient.h
r237110 r244307 29 29 #include <wtf/FastMalloc.h> 30 30 #include <wtf/Forward.h> 31 #include <wtf/HashMap.h> 31 32 #include <wtf/RandomNumber.h> 33 #include <wtf/Variant.h> 32 34 33 35 namespace WebCore { … … 42 44 virtual void logDiagnosticMessageWithValue(const String& message, const String& description, double value, unsigned significantFigures, ShouldSample) = 0; 43 45 virtual void logDiagnosticMessageWithEnhancedPrivacy(const String& message, const String& description, ShouldSample) = 0; 46 47 using ValuePayload = Variant<String, uint64_t, int64_t, bool, double>; 48 using ValueDictionary = HashMap<String, ValuePayload>; 49 50 virtual void logDiagnosticMessageWithValueDictionary(const String& message, const String& description, const ValueDictionary&, ShouldSample) = 0; 44 51 45 52 static bool shouldLogAfterSampling(ShouldSample); -
trunk/Source/WebCore/testing/Internals.cpp
r244224 r244307 57 57 #include "DOMWindow.h" 58 58 #include "DeprecatedGlobalSettings.h" 59 #include "DiagnosticLoggingClient.h" 59 60 #include "DisabledAdaptations.h" 60 61 #include "DisplayList.h" … … 5000 5001 } 5001 5002 5003 void Internals::testDictionaryLogging() 5004 { 5005 auto* document = contextDocument(); 5006 if (!document) 5007 return; 5008 5009 auto* page = document->page(); 5010 if (!page) 5011 return; 5012 5013 DiagnosticLoggingClient::ValueDictionary dictionary; 5014 dictionary.set("stringKey"_s, String("stringValue")); 5015 dictionary.set("uint64Key"_s, std::numeric_limits<uint64_t>::max()); 5016 dictionary.set("int64Key"_s, std::numeric_limits<int64_t>::min()); 5017 dictionary.set("boolKey"_s, true); 5018 dictionary.set("doubleKey"_s, 2.7182818284590452353602874); 5019 5020 page->diagnosticLoggingClient().logDiagnosticMessageWithValueDictionary("testMessage"_s, "testDescription"_s, dictionary, ShouldSample::No); 5021 } 5022 5002 5023 } // namespace WebCore -
trunk/Source/WebCore/testing/Internals.h
r244200 r244307 815 815 void processDidResume(); 816 816 817 void testDictionaryLogging(); 818 817 819 private: 818 820 explicit Internals(Document&); -
trunk/Source/WebCore/testing/Internals.idl
r244200 r244307 745 745 void processWillSuspend(); 746 746 void processDidResume(); 747 }; 747 748 void testDictionaryLogging(); 749 }; -
trunk/Source/WebKit/ChangeLog
r244302 r244307 1 2019-04-15 Jer Noble <jer.noble@apple.com> 2 3 Add a DiagnosticLogging method taking an arbitrary dictionary of values. 4 https://bugs.webkit.org/show_bug.cgi?id=196773 5 6 Reviewed by Alex Christensen. 7 8 In addition to adding the new logging delegate method (and piping everything into it), 9 add a new APIObject class to represent a signed integer. 10 11 * Shared/API/APINumber.h: 12 * Shared/API/APIObject.h: 13 * Shared/Cocoa/APIObject.mm: 14 (API::Object::newObject): 15 * Shared/Cocoa/WKNSNumber.mm: 16 (-[WKNSNumber dealloc]): 17 (-[WKNSNumber objCType]): 18 (-[WKNSNumber getValue:]): 19 (-[WKNSNumber longLongValue]): 20 (-[WKNSNumber _apiObject]): 21 * Shared/UserData.cpp: 22 (WebKit::UserData::encode): 23 (WebKit::UserData::decode): 24 * UIProcess/API/APIDiagnosticLoggingClient.h: 25 * UIProcess/API/C/WKPageDiagnosticLoggingClient.h: 26 * UIProcess/API/Cocoa/_WKDiagnosticLoggingDelegate.h: 27 * UIProcess/Cocoa/DiagnosticLoggingClient.h: 28 * UIProcess/Cocoa/DiagnosticLoggingClient.mm: 29 (WebKit::DiagnosticLoggingClient::logDiagnosticMessageWithValueDictionary): 30 * UIProcess/ProvisionalPageProxy.cpp: 31 (WebKit::ProvisionalPageProxy::didReceiveMessage): 32 * UIProcess/WebPageDiagnosticLoggingClient.cpp: 33 (WebKit::WebPageDiagnosticLoggingClient::logDiagnosticMessageWithValueDictionary): 34 * UIProcess/WebPageDiagnosticLoggingClient.h: 35 * UIProcess/WebPageProxy.cpp: 36 (WebKit::WebPageProxy::logDiagnosticMessageWithValueDictionary): 37 * UIProcess/WebPageProxy.h: 38 * UIProcess/WebPageProxy.messages.in: 39 * WebProcess/WebCoreSupport/WebDiagnosticLoggingClient.cpp: 40 (WebKit::WebDiagnosticLoggingClient::logDiagnosticMessageWithValueDictionary): 41 * WebProcess/WebCoreSupport/WebDiagnosticLoggingClient.h: 42 1 43 2019-04-15 Dean Jackson <dino@apple.com> 2 44 -
trunk/Source/WebKit/Shared/API/APINumber.h
r204668 r244307 70 70 typedef Number<double, API::Object::Type::Double> Double; 71 71 typedef Number<uint64_t, API::Object::Type::UInt64> UInt64; 72 typedef Number<int64_t, API::Object::Type::Int64> Int64; 72 73 73 74 } // namespace API -
trunk/Source/WebKit/Shared/API/APIObject.h
r243319 r244307 89 89 Double, 90 90 UInt64, 91 Int64, 91 92 92 93 // Geometry types -
trunk/Source/WebKit/Shared/Cocoa/APIObject.mm
r243951 r244307 164 164 case Type::Double: 165 165 case Type::UInt64: 166 case Type::Int64: 166 167 wrapper = [WKNSNumber alloc]; 167 168 ((WKNSNumber *)wrapper)->_type = type; -
trunk/Source/WebKit/Shared/Cocoa/WKNSNumber.mm
r242339 r244307 34 34 API::ObjectStorage<API::Double> _double; 35 35 API::ObjectStorage<API::UInt64> _uint64; 36 API::ObjectStorage<API::Int64> _int64; 36 37 } _number; 37 38 } … … 50 51 case API::Object::Type::UInt64: 51 52 _number._uint64->~Number<uint64_t, API::Object::Type::UInt64>(); 53 break; 54 55 case API::Object::Type::Int64: 56 _number._int64->~Number<int64_t, API::Object::Type::Int64>(); 52 57 break; 53 58 … … 76 81 break; 77 82 83 case API::Object::Type::Int64: 84 return @encode(int64_t); 85 break; 86 78 87 default: 79 88 ASSERT_NOT_REACHED(); … … 96 105 case API::Object::Type::UInt64: 97 106 *reinterpret_cast<uint64_t*>(value) = _number._uint64->value(); 107 break; 108 109 case API::Object::Type::Int64: 110 *reinterpret_cast<int64_t*>(value) = _number._int64->value(); 98 111 break; 99 112 … … 129 142 } 130 143 144 - (long long)longLongValue 145 { 146 if (_type == API::Object::Type::Int64) 147 return _number._int64->value(); 148 149 return super.longLongValue; 150 } 151 131 152 // MARK: NSCopying protocol implementation 132 153 … … 153 174 break; 154 175 176 case API::Object::Type::Int64: 177 return *_number._int64; 178 break; 179 155 180 default: 156 181 ASSERT_NOT_REACHED(); -
trunk/Source/WebKit/Shared/UserData.cpp
r210181 r244307 311 311 break; 312 312 313 case API::Object::Type::Int64: 314 static_cast<const API::Int64&>(object).encode(encoder); 315 break; 316 313 317 case API::Object::Type::UserContentURLPattern: { 314 318 auto& urlPattern = static_cast<const API::UserContentURLPattern&>(object); … … 573 577 break; 574 578 579 case API::Object::Type::Int64: 580 if (!API::Int64::decode(decoder, result)) 581 return false; 582 break; 583 575 584 case API::Object::Type::UserContentURLPattern: { 576 585 String string; -
trunk/Source/WebKit/UIProcess/API/APIDiagnosticLoggingClient.h
r219154 r244307 24 24 */ 25 25 26 #ifndef APIDiagnosticLoggingClient_h 27 #define APIDiagnosticLoggingClient_h 26 #pragma once 28 27 29 28 #include <WebCore/DiagnosticLoggingResultType.h> … … 36 35 namespace API { 37 36 37 class Dictionary; 38 38 39 class DiagnosticLoggingClient { 39 40 public: … … 44 45 virtual void logDiagnosticMessageWithValue(WebKit::WebPageProxy*, const WTF::String& message, const WTF::String& description, const WTF::String& value) = 0; 45 46 virtual void logDiagnosticMessageWithEnhancedPrivacy(WebKit::WebPageProxy*, const WTF::String& message, const WTF::String& description) = 0; 47 48 virtual void logDiagnosticMessageWithValueDictionary(WebKit::WebPageProxy*, const WTF::String& message, const WTF::String& description, Ref<API::Dictionary>&&) = 0; 46 49 }; 47 50 48 51 } // namespace API 49 50 #endif // APIDiagnosticLoggingClient_h51 -
trunk/Source/WebKit/UIProcess/API/Cocoa/_WKDiagnosticLoggingDelegate.h
r243376 r244307 41 41 - (void)_webView:(WKWebView *)webView logDiagnosticMessageWithValue:(NSString *)message description:(NSString *)description value:(NSString *) value; 42 42 - (void)_webView:(WKWebView *)webView logDiagnosticMessageWithEnhancedPrivacy:(NSString *)message description:(NSString *)description WK_API_AVAILABLE(macos(10.13), ios(11.0)); 43 - (void)_webView:(WKWebView *)webView logDiagnosticMessage:(NSString *)message description:(NSString *)description valueDictionary:(NSDictionary *)valueDictionary WK_API_AVAILABLE(macos(WK_MAC_TBA), ios(WK_IOS_TBA)); 43 44 44 45 @end -
trunk/Source/WebKit/UIProcess/Cocoa/DiagnosticLoggingClient.h
r242339 r244307 52 52 void logDiagnosticMessageWithValue(WebPageProxy*, const String& message, const String& description, const String& value) override; 53 53 void logDiagnosticMessageWithEnhancedPrivacy(WebPageProxy*, const String& message, const String& description) override; 54 void logDiagnosticMessageWithValueDictionary(WebPageProxy*, const String& message, const String& description, Ref<API::Dictionary>&&) override; 54 55 55 56 WKWebView *m_webView; … … 61 62 unsigned webviewLogDiagnosticMessageWithValue : 1; 62 63 unsigned webviewLogDiagnosticMessageWithEnhancedPrivacy : 1; 64 unsigned webviewLogDiagnosticMessageWithValueDictionary : 1; 63 65 } m_delegateMethods; 64 66 }; -
trunk/Source/WebKit/UIProcess/Cocoa/DiagnosticLoggingClient.mm
r242339 r244307 27 27 #import "DiagnosticLoggingClient.h" 28 28 29 #import "APIDictionary.h" 29 30 #import "WKSharedAPICast.h" 30 31 #import "_WKDiagnosticLoggingDelegate.h" … … 50 51 m_delegateMethods.webviewLogDiagnosticMessageWithValue = [delegate respondsToSelector:@selector(_webView:logDiagnosticMessageWithValue:description:value:)]; 51 52 m_delegateMethods.webviewLogDiagnosticMessageWithEnhancedPrivacy = [delegate respondsToSelector:@selector(_webView:logDiagnosticMessageWithEnhancedPrivacy:description:)]; 53 m_delegateMethods.webviewLogDiagnosticMessageWithValueDictionary = [delegate respondsToSelector:@selector(_webView:logDiagnosticMessage:description:valueDictionary:)]; 52 54 } 53 55 … … 88 90 } 89 91 92 void DiagnosticLoggingClient::logDiagnosticMessageWithValueDictionary(WebPageProxy*, const String& message, const String& description, Ref<API::Dictionary>&& valueDictionary) 93 { 94 if (m_delegateMethods.webviewLogDiagnosticMessageWithValueDictionary) 95 [m_delegate.get() _webView:m_webView logDiagnosticMessage:message description:description valueDictionary:static_cast<NSDictionary*>(valueDictionary->wrapper())]; 96 } 97 98 90 99 } // namespace WebKit -
trunk/Source/WebKit/UIProcess/ProvisionalPageProxy.cpp
r244243 r244307 382 382 || decoder.messageName() == Messages::WebPageProxy::LogDiagnosticMessage::name() 383 383 || decoder.messageName() == Messages::WebPageProxy::LogDiagnosticMessageWithEnhancedPrivacy::name() 384 || decoder.messageName() == Messages::WebPageProxy::LogDiagnosticMessageWithValueDictionary::name() 384 385 || decoder.messageName() == Messages::WebPageProxy::SetNetworkRequestsInProgress::name() 385 386 #if USE(QUICK_LOOK) -
trunk/Source/WebKit/UIProcess/WebPageDiagnosticLoggingClient.h
r211870 r244307 53 53 void logDiagnosticMessageWithValue(WebPageProxy*, const String& message, const String& description, const String& value) override; 54 54 void logDiagnosticMessageWithEnhancedPrivacy(WebPageProxy*, const String& message, const String& description) override; 55 void logDiagnosticMessageWithValueDictionary(WebKit::WebPageProxy*, const WTF::String& message, const WTF::String& description, Ref<API::Dictionary>&&) override { } 55 56 }; 56 57 -
trunk/Source/WebKit/UIProcess/WebPageProxy.cpp
r244288 r244307 6533 6533 } 6534 6534 6535 void WebPageProxy::logDiagnosticMessageWithValueDictionary(const String& message, const String& description, const WebCore::DiagnosticLoggingClient::ValueDictionary& valueDictionary, WebCore::ShouldSample shouldSample) 6536 { 6537 auto* effectiveClient = effectiveDiagnosticLoggingClient(shouldSample); 6538 if (!effectiveClient) 6539 return; 6540 6541 auto apiDictionary = API::Dictionary::create(); 6542 6543 for (auto& keyValuePair : valueDictionary) { 6544 apiDictionary->add(keyValuePair.key, WTF::switchOn(keyValuePair.value, 6545 [](const String& value) -> Ref<Object> { return API::String::create(value); }, 6546 [](uint64_t value) -> Ref<Object> { return API::UInt64::create(value); }, 6547 [](int64_t value) -> Ref<Object> { return API::Int64::create(value); }, 6548 [](bool value) -> Ref<Object> { return API::Boolean::create(value); }, 6549 [](double value) -> Ref<Object> { return API::Double::create(value); } 6550 )); 6551 } 6552 6553 effectiveClient->logDiagnosticMessageWithValueDictionary(this, message, description, WTFMove(apiDictionary)); 6554 } 6555 6535 6556 void WebPageProxy::logScrollingEvent(uint32_t eventType, MonotonicTime timestamp, uint64_t data) 6536 6557 { -
trunk/Source/WebKit/UIProcess/WebPageProxy.h
r244288 r244307 71 71 #include <WebCore/AutoplayEvent.h> 72 72 #include <WebCore/Color.h> 73 #include <WebCore/DiagnosticLoggingClient.h> 73 74 #include <WebCore/DragActions.h> 74 75 #include <WebCore/EventTrackingRegions.h> … … 1346 1347 void logDiagnosticMessageWithValue(const String& message, const String& description, double value, unsigned significantFigures, WebCore::ShouldSample); 1347 1348 void logDiagnosticMessageWithEnhancedPrivacy(const String& message, const String& description, WebCore::ShouldSample); 1349 void logDiagnosticMessageWithValueDictionary(const String& message, const String& description, const WebCore::DiagnosticLoggingClient::ValueDictionary&, WebCore::ShouldSample); 1348 1350 1349 1351 // Performance logging. -
trunk/Source/WebKit/UIProcess/WebPageProxy.messages.in
r244202 r244307 243 243 LogDiagnosticMessageWithValue(String message, String description, double value, unsigned significantFigures, enum:bool WebCore::ShouldSample shouldSample) 244 244 LogDiagnosticMessageWithEnhancedPrivacy(String message, String description, enum:bool WebCore::ShouldSample shouldSample) 245 LogDiagnosticMessageWithValueDictionary(String message, String description, WebCore::DiagnosticLoggingClient::ValueDictionary value, enum:bool WebCore::ShouldSample shouldSample) 245 246 246 247 # Performance logging -
trunk/Source/WebKit/WebProcess/WebCoreSupport/WebDiagnosticLoggingClient.cpp
r235205 r244307 84 84 } 85 85 86 void WebDiagnosticLoggingClient::logDiagnosticMessageWithValueDictionary(const String& message, const String& description, const ValueDictionary& value, ShouldSample shouldSample) 87 { 88 ASSERT(!m_page.corePage() || m_page.corePage()->settings().diagnosticLoggingEnabled()); 89 90 if (!shouldLogAfterSampling(shouldSample)) 91 return; 92 93 m_page.send(Messages::WebPageProxy::LogDiagnosticMessageWithValueDictionary(message, description, value, ShouldSample::No)); 94 } 95 86 96 } // namespace WebKit -
trunk/Source/WebKit/WebProcess/WebCoreSupport/WebDiagnosticLoggingClient.h
r211870 r244307 44 44 void logDiagnosticMessageWithValue(const String& message, const String& description, double value, unsigned significantFigures, WebCore::ShouldSample) override; 45 45 void logDiagnosticMessageWithEnhancedPrivacy(const String& message, const String& description, WebCore::ShouldSample) override; 46 void logDiagnosticMessageWithValueDictionary(const String& message, const String& description, const ValueDictionary&, WebCore::ShouldSample) override; 46 47 47 48 WebPage& m_page; -
trunk/Tools/ChangeLog
r244306 r244307 1 2019-04-15 Alex Christensen <achristensen@webkit.org> 2 3 Add a DiagnosticLogging method taking an arbitrary dictionary of values. 4 https://bugs.webkit.org/show_bug.cgi?id=196773 5 6 Reviewed by Jer Noble. 7 8 * TestWebKitAPI/Tests/WebKitCocoa/WKWebViewDiagnosticLogging.mm: 9 (-[TestLoggingDelegate _webView:logDiagnosticMessage:description:valueDictionary:]): 10 (TEST): 11 1 12 2019-04-15 Aakash Jain <aakash_jain@apple.com> 2 13 -
trunk/Tools/TestWebKitAPI/Tests/WebKitCocoa/WKWebViewDiagnosticLogging.mm
r242339 r244307 29 29 #import "Test.h" 30 30 #import "TestNavigationDelegate.h" 31 #import "WKWebViewConfigurationExtras.h" 32 #import <WebKit/WKPreferencesPrivate.h> 31 33 #import <WebKit/WKWebViewPrivate.h> 32 34 #import <WebKit/_WKDiagnosticLoggingDelegate.h> 33 35 #import <wtf/RetainPtr.h> 36 37 static bool isDone; 34 38 35 39 @interface TestLoggingDelegate : NSObject <_WKDiagnosticLoggingDelegate> … … 37 41 38 42 @implementation TestLoggingDelegate 43 44 - (void)_webView:(WKWebView *)webView logDiagnosticMessage:(NSString *)message description:(NSString *)description valueDictionary:(NSDictionary *)valueDictionary 45 { 46 EXPECT_TRUE([[valueDictionary objectForKey:@"stringKey"] isEqualToString:@"stringValue"]); 47 EXPECT_TRUE([[valueDictionary objectForKey:@"uint64Key"] unsignedLongLongValue] == std::numeric_limits<uint64_t>::max()); 48 EXPECT_TRUE([[valueDictionary objectForKey:@"int64Key"] longLongValue] == std::numeric_limits<int64_t>::min()); 49 EXPECT_TRUE([[valueDictionary objectForKey:@"boolKey"] boolValue]); 50 EXPECT_TRUE([[valueDictionary objectForKey:@"doubleKey"] doubleValue] == 2.7182818284590452353602874); 51 52 isDone = true; 53 } 54 39 55 @end 40 56 … … 70 86 } 71 87 88 TEST(WKWebView, DiagnosticLoggingDictionary) 89 { 90 auto webView = adoptNS([[WKWebView alloc] initWithFrame:CGRectZero configuration:[WKWebViewConfiguration _test_configurationWithTestPlugInClassName:@"WebProcessPlugInWithInternals"]]); 91 auto testLoggingDelegate = adoptNS([TestLoggingDelegate new]); 92 [webView _setDiagnosticLoggingDelegate:testLoggingDelegate.get()]; 93 [webView configuration].preferences._diagnosticLoggingEnabled = YES; 94 95 [webView loadHTMLString:@"<script>window.internals.testDictionaryLogging()</script>" baseURL:nil]; 96 TestWebKitAPI::Util::run(&isDone); 97 }
Note:
See TracChangeset
for help on using the changeset viewer.