<html>
    <head>
      <base href="https://bugs.webkit.org/">
    </head>
    <body><span class="vcard"><a class="email" href="mailto:aperez@igalia.com" title="Adrian Perez <aperez@igalia.com>"> <span class="fn">Adrian Perez</span></a>
</span> changed
          <a class="bz_bug_link 
          bz_status_NEW "
   title="NEW - [GLIB] Simplify SleepDisabler by checking if we are under sandbox"
   href="https://bugs.webkit.org/show_bug.cgi?id=231670">bug 231670</a>
          <br>
             <table border="1" cellspacing="0" cellpadding="8">
          <tr>
            <th>What</th>
            <th>Removed</th>
            <th>Added</th>
          </tr>

         <tr>
           <td style="text-align:right;">CC</td>
           <td>
                
           </td>
           <td>aperez@igalia.com
           </td>
         </tr>

         <tr>
           <td style="text-align:right;">Attachment #441571 Flags</td>
           <td>review?
           </td>
           <td>review+
           </td>
         </tr></table>
      <p>
        <div>
            <b><a class="bz_bug_link 
          bz_status_NEW "
   title="NEW - [GLIB] Simplify SleepDisabler by checking if we are under sandbox"
   href="https://bugs.webkit.org/show_bug.cgi?id=231670#c12">Comment # 12</a>
              on <a class="bz_bug_link 
          bz_status_NEW "
   title="NEW - [GLIB] Simplify SleepDisabler by checking if we are under sandbox"
   href="https://bugs.webkit.org/show_bug.cgi?id=231670">bug 231670</a>
              from <span class="vcard"><a class="email" href="mailto:aperez@igalia.com" title="Adrian Perez <aperez@igalia.com>"> <span class="fn">Adrian Perez</span></a>
</span></b>
        <pre>Comment on <span class=""><a href="attachment.cgi?id=441571&action=diff" name="attach_441571" title="Patch">attachment 441571</a> <a href="attachment.cgi?id=441571&action=edit" title="Patch">[details]</a></span>
Patch

I left some comments about the helper functions, but as the code was just
moved around it's fineā€”but if you feel like changing them before landing,
that would be neat :)


View in context: <a href="https://bugs.webkit.org/attachment.cgi?id=441571&action=review">https://bugs.webkit.org/attachment.cgi?id=441571&action=review</a>

<span class="quote">> Source/WTF/wtf/glib/Sandbox.cpp:39
> +    return *ret;</span >

It should not be needed to use std::optional here, you can just:

   bool isInsideFlatpak()
   {
       static bool ret = g_file_test("/.flatpak-info", G_FILE_TEST_EXISTS);
       return ret;
   }

The C++11 specification guarantees that a static local is initialized only
once when program control flow goes through it, and that it is thread-safe
(amusingly, manually checking the optional is not thread-safe :D)

The same applies to the other checks below.

<span class="quote">> Source/WTF/wtf/glib/Sandbox.cpp:70
> +    return usePortal[0] != '0';</span >

This one is a bit trickier, but one can use a lambda that gets invoked
immediately to initialize the static value:

    bool shouldUsePortal() {
        static bool ret = ([]() -> bool {
            // do checks, return true/false
        })();
        return ret;
    }</pre>
        </div>
      </p>


      <hr>
      <span>You are receiving this mail because:</span>

      <ul>
          <li>You are the assignee for the bug.</li>
      </ul>
    </body>
</html>