• nhiroki's avatar
    WebMessaging: Send transferable ArrayBuffers by copy-and-neuter semantics · 99a27564
    nhiroki authored
    Before this CL, MessagePort/ServiceWorker/Client can send an ArrayBuffer with
    copy semantics, but it cannot send an ArrayBuffer with move semantics even if
    it's specified as a transferable object.
    
      // Copy semantics.
      port.postMessage(arrayBuffer);
    
      // Move semantics. Currently, this doesn't work and shows a warning message
      // instead. See https://codereview.chromium.org/1301953002
      port.postMessage(arrayBuffer, [arrayBuffer]);
    
    After this CL, they emulate move semantics by copy-and-neuter semantics that
    sends an ArrayBuffer by copy semantics and neuters the original ArrayBuffer.
    
    <Context of this change>
    
    Because of Chromium's multi-process architecture, a target object can be in a
    different process from a sender object. This makes it difficult to support
    zero-copy transfer (move semantics) because it needs to stride over process
    memory boundaries. Using shared memory is a possible solution, but that seems to
    need architectual changes and introduce complexity. Therefore, as a stopgap, we
    support sending a transferable ArrayBuffer with copy-and-neuter semantics.
    
    See this document for more details:
    https://docs.google.com/document/d/17o_cjtc3Gk5cDZhoUc37EyhhvBb4wMlCROJvoC2Aokg/edit#
    
    BUG=334408, 511119
    
    Review-Url: https://codereview.chromium.org/2414333003
    Cr-Commit-Position: refs/heads/master@{#427015}
    99a27564
methods.cpp.tmpl 30.3 KB