bpd1069 / naclports

Automatically exported from code.google.com/p/naclports
0 stars 0 forks source link

Progress patch for URLLoaderJob #52

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
The simplest way to fetch files with Native Client is to do something like this:

       UrlLoaderJob* job = new UrlLoaderJob;
        job->set_url("http://www.mydatasource.com/mydata.tar");
        std::vector<char> data;
        job->set_dst(&data);
        m_pRunner->RunJob(job);
        int fh = open("/mydata.tar", O_CREAT | O_WRONLY);
        write(fh, &data[0], data.size());
        close(fh);

One downside to this approach is that RunJob is blocking, and there's no way to 
get any progress notification from UrlLoaderJob. 

Attached is a patch that adds a new "get_progress" function to UrlLoaderJob, 
which allows you to poll it to see how many bytes have been received:

    void get_progress(int64_t& bytes_recvd, int64_t& bytes_total);

In the example above, you would spawn a thread right before calling RunJob(), 
which then polls the job and reports the download progress.

Original issue reported on code.google.com by albert.s...@gmail.com on 1 Aug 2012 at 11:54

Attachments:

GoogleCodeExporter commented 9 years ago
nacl-mounts is basically dead.  We are moving towards using the nacl_io library 
which is part of the nacl SDK.

If you are still using nacl_mounts and would still like to land this change 
please use 'git cl upload' to upload it to code review and we can take it from 
there.  Feel free to reopen this bug in that case.

Original comment by sbc@google.com on 13 Jun 2013 at 10:40