• Mahmoud Gawad's avatar
    diagnostics: ScopedAllowBlocking cros mojo utils · 7f4bd4fc
    Mahmoud Gawad authored
    Allow mojo_utils in wilco_dtc_supportd to use ScopedAllowBlocking's
    private ctor.
    
    GetStringPieceFromMojoHandle() runs in the browser process and has
    DCHECK errors. This is because GetStringPieceFromMojoHandle() uses
    base::file::Fstat() that is marked with ScopedBlockingCall.
    
    Background: Referring to the discussion in
    https://chromium-review.googlesource.com/c/chromium/src/+/2042611, the
    ideal solution to this problem is to upgrade mojo library in chromeos
    (mojo library in chromeos is 1-2 years older than chrome). Doing that,
    the new shmem builtin types can be used and we won't need to get the
    handle's length in the first place.
    
    The problem with that is upgrade will take time. So, as a temporary
    solution, allow mojo_utils in wilco_dtc_supportd to use
    ScopedAllowBlocking's private ctor by making the class friend with
    ScopedAllowBlocking.
    
    The justification as per alexilin@ is that: Fstat() shouldn't be
    blocking for shared memory descriptors (i.e. mojo handle). Fstat() will
    read tmpfs metadata that is always stored in RAM. That metadata is
    never swapped to disk since it's part of kernel-allocated memory that
    is never swapped out.
    
    Bug: 1055467,b:146119375
    TEST=building and running unittests
    
    Change-Id: Iba688b7f311c07b051687a1f619b594475892178
    Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2070160
    Commit-Queue: Mahmoud Gawad <mgawad@google.com>
    Reviewed-by: default avatarLei Zhang <thestig@chromium.org>
    Reviewed-by: default avatarOleh Lamzin <lamzin@google.com>
    Reviewed-by: default avatarFrançois Doray <fdoray@chromium.org>
    Reviewed-by: default avatarMaksim Ivanov <emaxx@chromium.org>
    Reviewed-by: default avatarAlex Ilin <alexilin@chromium.org>
    Cr-Commit-Position: refs/heads/master@{#746317}
    7f4bd4fc
thread_restrictions.h 21.8 KB