- Revision
- 277666
- Author
- [email protected]
- Date
- 2021-05-18 11:48:48 -0700 (Tue, 18 May 2021)
Log Message
Allow logging minimal info about uploading media files
https://bugs.webkit.org/show_bug.cgi?id=225636
<rdar://problem/76639138>
Reviewed by Alex Christensen.
Source/WebCore:
Files can be uploaded to a server by many different ways: through a form
submit, an xhr, a file fetch or through a worker. r275103 handled the
form submit only. Instead of handling this case by case, we can add the
logging code in a shared place where all the file uploading goes through.
* html/HTMLFormElement.cpp:
(WebCore::HTMLFormElement::submit):
Delete the code which was part of r275103.
* page/Page.cpp:
(WebCore::Page::logMediaDiagnosticMessage const):
* page/Page.h:
Make the Page be responsible for logging the media files info.
* platform/network/FormData.cpp:
(WebCore::FormData::imageOrMediaFilesCount const):
* platform/network/FormData.h:
Make the FormData count how many images or media files it has.
Source/WebKit:
* WebProcess/Network/WebLoaderStrategy.cpp:
(WebKit::addParametersShared):
Centralize logging uploading the images and media files.
Modified Paths
Diff
Modified: trunk/Source/WebCore/ChangeLog (277665 => 277666)
--- trunk/Source/WebCore/ChangeLog 2021-05-18 18:01:45 UTC (rev 277665)
+++ trunk/Source/WebCore/ChangeLog 2021-05-18 18:48:48 UTC (rev 277666)
@@ -1,3 +1,30 @@
+2021-05-18 Said Abou-Hallawa <[email protected]>
+
+ Allow logging minimal info about uploading media files
+ https://bugs.webkit.org/show_bug.cgi?id=225636
+ <rdar://problem/76639138>
+
+ Reviewed by Alex Christensen.
+
+ Files can be uploaded to a server by many different ways: through a form
+ submit, an xhr, a file fetch or through a worker. r275103 handled the
+ form submit only. Instead of handling this case by case, we can add the
+ logging code in a shared place where all the file uploading goes through.
+
+ * html/HTMLFormElement.cpp:
+ (WebCore::HTMLFormElement::submit):
+ Delete the code which was part of r275103.
+
+ * page/Page.cpp:
+ (WebCore::Page::logMediaDiagnosticMessage const):
+ * page/Page.h:
+ Make the Page be responsible for logging the media files info.
+
+ * platform/network/FormData.cpp:
+ (WebCore::FormData::imageOrMediaFilesCount const):
+ * platform/network/FormData.h:
+ Make the FormData count how many images or media files it has.
+
2021-05-18 Keith Miller <[email protected]>
Temporarily revert r276592 as it breaks some native apps
Modified: trunk/Source/WebCore/html/HTMLFormElement.cpp (277665 => 277666)
--- trunk/Source/WebCore/html/HTMLFormElement.cpp 2021-05-18 18:01:45 UTC (rev 277665)
+++ trunk/Source/WebCore/html/HTMLFormElement.cpp 2021-05-18 18:48:48 UTC (rev 277666)
@@ -46,7 +46,6 @@
#include "HTMLParserIdioms.h"
#include "HTMLTableElement.h"
#include "InputTypeNames.h"
-#include "MIMETypeRegistry.h"
#include "MixedContentChecker.h"
#include "NodeRareData.h"
#include "Page.h"
@@ -399,17 +398,6 @@
if (m_plannedFormSubmission)
m_plannedFormSubmission->cancel();
- unsigned imageOrMediaFiles = 0;
- for (auto& dataElement : formSubmission->data().elements()) {
- auto* encodedFileData = WTF::get_if<FormDataElement::EncodedFileData>(dataElement.data);
- if (!encodedFileData)
- continue;
-
- auto mimeType = MIMETypeRegistry::mimeTypeForPath(encodedFileData->filename);
- if (MIMETypeRegistry::isSupportedImageMIMEType(mimeType) || MIMETypeRegistry::isSupportedMediaMIMEType(mimeType))
- ++imageOrMediaFiles;
- }
-
m_plannedFormSubmission = makeWeakPtr(formSubmission.get());
frame->loader().submitForm(WTFMove(formSubmission));
@@ -416,12 +404,6 @@
if (firstSuccessfulSubmitButton)
firstSuccessfulSubmitButton->setActivatedSubmit(false);
- if (imageOrMediaFiles) {
- auto& diagnosticLoggingClient = document().page()->diagnosticLoggingClient();
- auto message = makeString(imageOrMediaFiles, imageOrMediaFiles == 1 ? " media file has been submitted" : " media files have been submitted");
- diagnosticLoggingClient.logDiagnosticMessageWithDomain(message, DiagnosticLoggingDomain::Media);
- }
-
m_shouldSubmit = false;
m_isSubmittingOrPreparingForSubmission = false;
}
Modified: trunk/Source/WebCore/page/Page.cpp (277665 => 277666)
--- trunk/Source/WebCore/page/Page.cpp 2021-05-18 18:01:45 UTC (rev 277665)
+++ trunk/Source/WebCore/page/Page.cpp 2021-05-18 18:48:48 UTC (rev 277666)
@@ -1059,6 +1059,15 @@
return *m_diagnosticLoggingClient;
}
+void Page::logMediaDiagnosticMessage(const FormData* formData) const
+{
+ unsigned imageOrMediaFilesCount = formData ? formData->imageOrMediaFilesCount() : 0;
+ if (!imageOrMediaFilesCount)
+ return;
+ auto message = makeString(imageOrMediaFilesCount, imageOrMediaFilesCount == 1 ? " media file has been submitted" : " media files have been submitted");
+ diagnosticLoggingClient().logDiagnosticMessageWithDomain(message, DiagnosticLoggingDomain::Media);
+}
+
void Page::setMediaVolume(float volume)
{
if (!(volume >= 0 && volume <= 1))
Modified: trunk/Source/WebCore/page/Page.h (277665 => 277666)
--- trunk/Source/WebCore/page/Page.h 2021-05-18 18:01:45 UTC (rev 277665)
+++ trunk/Source/WebCore/page/Page.h 2021-05-18 18:48:48 UTC (rev 277666)
@@ -105,6 +105,7 @@
class EditorClient;
class Element;
class FocusController;
+class FormData;
class Frame;
class HTMLMediaElement;
class HistoryItem;
@@ -496,6 +497,8 @@
WEBCORE_EXPORT DiagnosticLoggingClient& diagnosticLoggingClient() const;
+ WEBCORE_EXPORT void logMediaDiagnosticMessage(const FormData*) const;
+
PerformanceLoggingClient* performanceLoggingClient() const { return m_performanceLoggingClient.get(); }
WheelEventDeltaFilter* wheelEventDeltaFilter() { return m_recentWheelEventDeltaFilter.get(); }
Modified: trunk/Source/WebCore/platform/network/FormData.cpp (277665 => 277666)
--- trunk/Source/WebCore/platform/network/FormData.cpp 2021-05-18 18:01:45 UTC (rev 277665)
+++ trunk/Source/WebCore/platform/network/FormData.cpp 2021-05-18 18:48:48 UTC (rev 277666)
@@ -28,6 +28,7 @@
#include "DOMFormData.h"
#include "File.h"
#include "FormDataBuilder.h"
+#include "MIMETypeRegistry.h"
#include "Page.h"
#include "SharedBuffer.h"
#include "TextEncoding.h"
@@ -123,6 +124,21 @@
return formData;
}
+unsigned FormData::imageOrMediaFilesCount() const
+{
+ unsigned imageOrMediaFilesCount = 0;
+ for (auto& element : m_elements) {
+ auto* encodedFileData = WTF::get_if<FormDataElement::EncodedFileData>(element.data);
+ if (!encodedFileData)
+ continue;
+
+ auto mimeType = MIMETypeRegistry::mimeTypeForPath(encodedFileData->filename);
+ if (MIMETypeRegistry::isSupportedImageMIMEType(mimeType) || MIMETypeRegistry::isSupportedMediaMIMEType(mimeType))
+ ++imageOrMediaFilesCount;
+ }
+ return imageOrMediaFilesCount;
+}
+
uint64_t FormDataElement::lengthInBytes(const Function<uint64_t(const URL&)>& blobSize) const
{
return switchOn(data,
Modified: trunk/Source/WebCore/platform/network/FormData.h (277665 => 277666)
--- trunk/Source/WebCore/platform/network/FormData.h 2021-05-18 18:01:45 UTC (rev 277665)
+++ trunk/Source/WebCore/platform/network/FormData.h 2021-05-18 18:48:48 UTC (rev 277666)
@@ -241,6 +241,7 @@
bool containsPasswordData() const { return m_containsPasswordData; }
void setContainsPasswordData(bool containsPasswordData) { m_containsPasswordData = containsPasswordData; }
+ unsigned imageOrMediaFilesCount() const;
static EncodingType parseEncodingType(const String& type)
{
Modified: trunk/Source/WebKit/ChangeLog (277665 => 277666)
--- trunk/Source/WebKit/ChangeLog 2021-05-18 18:01:45 UTC (rev 277665)
+++ trunk/Source/WebKit/ChangeLog 2021-05-18 18:48:48 UTC (rev 277666)
@@ -1,3 +1,15 @@
+2021-05-18 Said Abou-Hallawa <[email protected]>
+
+ Allow logging minimal info about uploading media files
+ https://bugs.webkit.org/show_bug.cgi?id=225636
+ <rdar://problem/76639138>
+
+ Reviewed by Alex Christensen.
+
+ * WebProcess/Network/WebLoaderStrategy.cpp:
+ (WebKit::addParametersShared):
+ Centralize logging uploading the images and media files.
+
2021-05-18 Keith Miller <[email protected]>
Temporarily revert r276592 as it breaks some native apps
Modified: trunk/Source/WebKit/WebProcess/Network/WebLoaderStrategy.cpp (277665 => 277666)
--- trunk/Source/WebKit/WebProcess/Network/WebLoaderStrategy.cpp 2021-05-18 18:01:45 UTC (rev 277665)
+++ trunk/Source/WebKit/WebProcess/Network/WebLoaderStrategy.cpp 2021-05-18 18:48:48 UTC (rev 277666)
@@ -283,6 +283,7 @@
if (auto* page = frame->page()) {
parameters.pageHasResourceLoadClient = page->hasResourceLoadClient();
parameters.shouldRelaxThirdPartyCookieBlocking = page->shouldRelaxThirdPartyCookieBlocking();
+ page->logMediaDiagnosticMessage(parameters.request.httpBody());
}
if (auto* ownerElement = frame->ownerElement()) {