• Antonio Gomes's avatar
    Migrate WebRtcEventLogUploaderImpl to SimpleURLLoader · 75cdb263
    Antonio Gomes authored
    URLFetcher will stop working with advent of Network Service, and
    SimpleURLLoader is the replacement API for most clients.
    This CL migrates WebRtcEventLogUploaderImpl et al away from URLFetcher.
    
    Note that this CL slightly changes the flow of the WebRtcEventLogUploader code.
    Previously, an URLRequestContextGetter instance was acquired on UI thread,
    passed to the IO-capable task runner, used there, and ultimately deleted either
    on the UI thread or on the IO-capable task runner thread, depending on the
    termination circumstance (eg BrowserProcessImpl shutdown or upload completion,
    respectively).
    
    However, URLLoaderFactory and SimpleURLLoader have stricter threading
    restrictions than URLFetcher and URLRequestContextGetter. For instance, a
    SharedURLLoaderFactory instance needs to be created, used and deleted on
    the same thread.
    Given this scenario, a natural approach to tackle this migration would be
    the use of CrossThreadSharedURLLoaderFactory{Info} classes. However, as
    mentioned earlier, the fact that WebRtcEventLogUploader instances are
    constructed the aforementioned IO-capable task runner thread and the
    deletion thread varies, make the use of CrossThreadSharedURLLoaderFactory{Info}
    less straightforward.
    
    This CL makes use of the thread agnostic network::mojom::URLLoaderFactoryPtrInfo
    class instead: from the IO-capable task runner it posts a message to the UI thread
    to bind a network::mojom::URLLoaderFactory object. As per the mojo documentation [1]:
    
      "Once the LoggerPtr is bound we can immediately begin calling Logger interface
      methods on it, which will immediately write messages into the pipe. These
      messages will stay queued on the receiving end of the pipe until someone
      binds to it and starts reading them."
    
    [1] https://chromium.googlesource.com/chromium/src/+/master/mojo/public/cpp/bindings/README.md#Binding-an-Interface-Request
    
    BUG=773295,873187
    
    Change-Id: Ic29222ea63e90dcb26f3124bdea1c627570dc04d
    Reviewed-on: https://chromium-review.googlesource.com/1171622
    Commit-Queue: Antonio Gomes <tonikitoo@igalia.com>
    Reviewed-by: default avatarElad Alon <eladalon@chromium.org>
    Reviewed-by: default avatarMatt Menke <mmenke@chromium.org>
    Cr-Commit-Position: refs/heads/master@{#584048}
    75cdb263
webrtc_event_log_manager.cc 33.5 KB