[WK2] Add logging to validate the network cache efficacy (Part 2)
https://bugs.webkit.org/show_bug.cgi?id=141345
<rdar://problem/19632080>

Reviewed by Sam Weinig.

Source/WebCore:

Add a few more diagnostic logging keys for the network cache efficacy
logging.

Source/WebKit2:

Add diagnostic logging messages to validate the network cache efficacy.
The following 4 messages are added:
- networkCache / retrieval / success
- networkCache / retrieval / unhandledRequestFailure
- networkCache / retrieval / noLongerInCacheFailure
- networkCache / retrieval / unusableCachedEntryFailure

The messages are sent via IPC from the NetworkProcess to the UIProcess,
where the WebPageProxy code already handles diagnostic messages sent by
the WebProcess.

git-svn-id: http://svn.webkit.org/repository/webkit/trunk@179972 268f45cc-cd09-0410-ab3c-d52691b4dbfc
diff --git a/Source/WebKit2/UIProcess/Network/NetworkProcessProxy.cpp b/Source/WebKit2/UIProcess/Network/NetworkProcessProxy.cpp
index d5f33fc..732c1b5 100644
--- a/Source/WebKit2/UIProcess/Network/NetworkProcessProxy.cpp
+++ b/Source/WebKit2/UIProcess/Network/NetworkProcessProxy.cpp
@@ -230,6 +230,39 @@
 #endif
 }
 
+void NetworkProcessProxy::logDiagnosticMessage(uint64_t pageID, const String& message, const String& description)
+{
+    WebPageProxy* page = WebProcessProxy::webPage(pageID);
+    // FIXME: We do this null-check because by the time the decision to log is made, the page may be gone. We should refactor to avoid this,
+    // but for now we simply drop the message in the rare case this happens.
+    if (!page)
+        return;
+
+    page->logDiagnosticMessage(message, description);
+}
+
+void NetworkProcessProxy::logDiagnosticMessageWithResult(uint64_t pageID, const String& message, const String& description, uint32_t result)
+{
+    WebPageProxy* page = WebProcessProxy::webPage(pageID);
+    // FIXME: We do this null-check because by the time the decision to log is made, the page may be gone. We should refactor to avoid this,
+    // but for now we simply drop the message in the rare case this happens.
+    if (!page)
+        return;
+
+    page->logDiagnosticMessageWithResult(message, description, result);
+}
+
+void NetworkProcessProxy::logDiagnosticMessageWithValue(uint64_t pageID, const String& message, const String& description, const String& value)
+{
+    WebPageProxy* page = WebProcessProxy::webPage(pageID);
+    // FIXME: We do this null-check because by the time the decision to log is made, the page may be gone. We should refactor to avoid this,
+    // but for now we simply drop the message in the rare case this happens.
+    if (!page)
+        return;
+
+    page->logDiagnosticMessageWithValue(message, description, value);
+}
+
 } // namespace WebKit
 
 #endif // ENABLE(NETWORK_PROCESS)