Bug 220764 - [SOUP] Stop using SoupRequest API in preparation for libsoup3
Summary: [SOUP] Stop using SoupRequest API in preparation for libsoup3
Status: RESOLVED FIXED
Alias: None
Product: WebKit
Classification: Unclassified
Component: WebKitGTK (show other bugs)
Version: WebKit Nightly Build
Hardware: Unspecified Unspecified
: P2 Normal
Assignee: Nobody
URL:
Keywords: Gtk
Depends on: 220509 220981
Blocks: libsoup3 221034
  Show dependency treegraph
 
Reported: 2021-01-20 05:18 PST by Carlos Garcia Campos
Modified: 2021-01-28 04:42 PST (History)
6 users (show)

See Also:


Attachments
Patch (37.10 KB, patch)
2021-01-20 05:33 PST, Carlos Garcia Campos
aperez: review+
aperez: commit-queue-
Details | Formatted Diff | Diff
Patch for landing (36.88 KB, patch)
2021-01-26 03:55 PST, Carlos Garcia Campos
no flags Details | Formatted Diff | Diff
Patch for landing (36.88 KB, patch)
2021-01-26 04:33 PST, Carlos Garcia Campos
no flags Details | Formatted Diff | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Carlos Garcia Campos 2021-01-20 05:18:33 PST
It's gone in libsoup3, we can just use soup_session_send_async() instead, which is what SoupRequest does internally.
Comment 1 Carlos Garcia Campos 2021-01-20 05:33:17 PST
Created attachment 417962 [details]
Patch
Comment 2 Adrian Perez 2021-01-25 13:45:06 PST
Comment on attachment 417962 [details]
Patch

Patch LGTM with a couple of nits. Please check them out before landing, in
particular I would like to see the suggested simplification for ”m_acceptEncoding”
in the final version that lands; the other two suggestions I will leave them up
to you =)


View in context: https://bugs.webkit.org/attachment.cgi?id=417962&action=review

> Source/WebCore/platform/network/soup/ResourceRequest.h:85
> +    bool m_acceptEncoding : 1;

It does not make sense to specify a bit width of “1” here. This is the
only member for which the bit width is indicated, which will result in
the compiler adding padding anyway—which defeats the intent of saving
some bytes of memory. We may as well do:

  bool m_acceptEncoding { true };

…and skip setting the initial value in the constructors above.

Just tested:

  % cat > t.cc <<EOF
  #include <cstdio>
  enum Flag { FLAG_FOO, FLAG_BAR, FLAG_BAZ };
  class X { bool bit: 1; enum Flag f; };
  class Y { bool bit;    enum Flag f; };
  int main() {
    std::printf("X: %zu bytes, Y: %zu bytes\n", sizeof(X), sizeof(Y));
  }
  EOF
  % g++ -o t t.cc && ./t
  X: 8 bytes, Y: 8 bytes
  %

> Source/WebCore/platform/network/soup/ResourceRequestSoup.cpp:-219
> -

Nice to see this bit gone \o/

> Source/WebKit/NetworkProcess/soup/NetworkDataTaskSoup.cpp:333
> +        g_object_set_data_full(G_OBJECT(task->m_pendingResult.get()), "wk-send-request-data", protectedData.release(), [](gpointer data) {

Is there any reason not to use “g_object_set_qdata_full()”? That would
avoid the string→GQuark conversion on each usage. Maybe we should open
a new bug to convert all the uses of “g_object_{g,s}et_data” to use the
“qdata” variants, WDYT?

> Source/WebKit/NetworkProcess/soup/NetworkDataTaskSoup.cpp:477
> +}

The “didSniffContent()” member function is private and only ever called from
the “didSniffContentCallback()” function right above. I think it's may not be
worth it to have this function containing a single assignment, it could be done
just directly inside “didSniffContentCallback()” — though I have no strong
preference, feel free to leave this as-is.
Comment 3 Carlos Garcia Campos 2021-01-26 03:53:38 PST
Comment on attachment 417962 [details]
Patch

View in context: https://bugs.webkit.org/attachment.cgi?id=417962&action=review

>> Source/WebCore/platform/network/soup/ResourceRequest.h:85
>> +    bool m_acceptEncoding : 1;
> 
> It does not make sense to specify a bit width of “1” here. This is the
> only member for which the bit width is indicated, which will result in
> the compiler adding padding anyway—which defeats the intent of saving
> some bytes of memory. We may as well do:
> 
>   bool m_acceptEncoding { true };
> 
> …and skip setting the initial value in the constructors above.
> 
> Just tested:
> 
>   % cat > t.cc <<EOF
>   #include <cstdio>
>   enum Flag { FLAG_FOO, FLAG_BAR, FLAG_BAZ };
>   class X { bool bit: 1; enum Flag f; };
>   class Y { bool bit;    enum Flag f; };
>   int main() {
>     std::printf("X: %zu bytes, Y: %zu bytes\n", sizeof(X), sizeof(Y));
>   }
>   EOF
>   % g++ -o t t.cc && ./t
>   X: 8 bytes, Y: 8 bytes
>   %

Sure.

>> Source/WebKit/NetworkProcess/soup/NetworkDataTaskSoup.cpp:333
>> +        g_object_set_data_full(G_OBJECT(task->m_pendingResult.get()), "wk-send-request-data", protectedData.release(), [](gpointer data) {
> 
> Is there any reason not to use “g_object_set_qdata_full()”? That would
> avoid the string→GQuark conversion on each usage. Maybe we should open
> a new bug to convert all the uses of “g_object_{g,s}et_data” to use the
> “qdata” variants, WDYT?

I don't know if it really has any impact. But it's probably better to do that in a separate commit for all the set_data cases instead.

>> Source/WebKit/NetworkProcess/soup/NetworkDataTaskSoup.cpp:477
>> +}
> 
> The “didSniffContent()” member function is private and only ever called from
> the “didSniffContentCallback()” function right above. I think it's may not be
> worth it to have this function containing a single assignment, it could be done
> just directly inside “didSniffContentCallback()” — though I have no strong
> preference, feel free to leave this as-is.

Yes, this is just to follow the pattern for all other async ops in this file, didFooCallback -> didFoo
Comment 4 Carlos Garcia Campos 2021-01-26 03:55:24 PST
Created attachment 418390 [details]
Patch for landing
Comment 5 Carlos Garcia Campos 2021-01-26 04:33:21 PST
Created attachment 418394 [details]
Patch for landing
Comment 6 EWS Watchlist 2021-01-26 04:47:07 PST
Thanks for the patch. If this patch contains new public API please make sure it follows the guidelines for new WebKit2 GTK+ API. See https://trac.webkit.org/wiki/WebKitGTK/AddingNewWebKit2API
Comment 7 Lauro Moura 2021-01-26 20:44:18 PST
Linking the bug with the regressions from r271879. (Should have gardened with this one instead).
Comment 8 Carlos Garcia Campos 2021-01-28 04:42:22 PST
Committed r272010: <https://trac.webkit.org/changeset/272010>