[Webkit-unassigned] [Bug 231706] Implement File System standard

bugzilla-daemon at webkit.org bugzilla-daemon at webkit.org
Mon Aug 19 09:05:55 PDT 2024


https://bugs.webkit.org/show_bug.cgi?id=231706

Andrew Hodel <andrewhodel at gmail.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |andrewhodel at gmail.com

--- Comment #10 from Andrew Hodel <andrewhodel at gmail.com> ---
This is needed in Safari, requiring HTTP range requests and a request per file does not allow a protocol buffer implementation to handle transmission priority.

This works in every browser except Safari and allows the ability to prioritize messages, that's a requirement for control messages.

Protocol Buffer JavaScript Example:
```
var inbound_message_callback = function(m) {

        console.log('inbound_message_callback() called.', m);

        var c = create_message_element(inbound_element, m, 'inbound');

        var file_handle = null;
        var writable_stream = null;
        var file_mem_buf = [];
        var file_data_index = 0;
        var data_chunks_read_into_memory = 0;
        var downloaded = false;

        c.c.addEventListener('dblclick', function(e) {

                if (downloaded === true) {
                        alert('already downloaded');
                        return;
                }

                // create new file handle with name
                var fh_promise = window.showSaveFilePicker();

                fh_promise.then(function(fh_fullfillment) {

                        // if the fullfillment happens of window.showSaveFilePicker()
                        // do not allow it to happen again, in order to regain the memory used by file_mem_buf
                        // as an inbound message can be terabytes in size
                        // and the download to file can be started during and after the message arrival
                        downloaded = true;

                        file_handle = fh_fullfillment

                        console.log('created file handle for message_type 1 message data', file_handle);

                        var wrs_promise = fh_fullfillment.createWritable();

                        wrs_promise.then(function(wrs_fullfillment) {

                                writable_stream = wrs_fullfillment;
                                console.log('created writable stream for message_type 1 message data', writable_stream);

                                if (data_chunks_read_into_memory === m.total_chunks) {

                                        // data is already in memory
                                        // no more activity_callback() invocations

                                        // add data from memory buffer to file_handle
                                        for (var l in file_mem_buf) {
                                                writable_stream.write(file_mem_buf[l]);
                                        }

                                        // empty file_mem_buf, this is in the main thread and this activity_callback function must complete before another is run
                                        file_mem_buf = [];

                                        // close the writable stream
                                        writable_stream.close();

                                }

                        }, function(wrs_rejection) {

                                console.log('wrs_rejection', wrs_rejection);

                        });

                }, function(fh_rejection) {

                        console.log('fh_rejection', fh_rejection);

                });

        });

        m.activity_callback = function(e, data_progress, data) {

                // (event String, data_progress Number, data ArrayBuffer)
                // data is always nil unless it is a "data_progress" or "data_complete" event of a message in the ReceiveQueue

                //console.log('inbound message activity_callback', e, data_progress, data, m.transfer_rate_bits_per_microsecond + 'mbps');

                c.update(data_progress);

                if (e === 'data_progress') {

                        c.data_chunk(data);

                        if (writable_stream === null) {

                                // add data to memory buffer
                                file_mem_buf.push(data);

                                data_chunks_read_into_memory++;

                        } else {

                                // add data from memory buffer to file_handle
                                for (var l in file_mem_buf) {
                                        writable_stream.write(file_mem_buf[l]);
                                }

                                // empty file_mem_buf, this is in the main thread and this activity_callback function must complete before another is run
                                file_mem_buf = [];

                                // add data to file_handle
                                writable_stream.write(data);

                        }

                        // increment the file_data_index
                        file_data_index++;

                } else if (e === 'data_complete') {

                        if (writable_stream !== null && file_mem_buf.length === 0) {

                                // all data in file_mem_buf has been written to a file

                                // close the writable stream
                                writable_stream.close();

                        }

                }

        }

}
```

-- 
You are receiving this mail because:
You are the assignee for the bug.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.webkit.org/pipermail/webkit-unassigned/attachments/20240819/b17dec21/attachment.htm>


More information about the webkit-unassigned mailing list