~ubuntu-branches/ubuntu/lucid/webkit/lucid-updates

« back to all changes in this revision

Viewing changes to WebKit/gtk/webkit/webkitdownload.cpp

  • Committer: Bazaar Package Importer
  • Author(s): Gustavo Noronha Silva
  • Date: 2010-01-06 21:25:06 UTC
  • mfrom: (1.2.6 upstream) (4.3.7 sid)
  • Revision ID: james.westby@ubuntu.com-20100106212506-gd0czn4zrwf1j19l
* New upstream release
- adds basic Content-Encoding support, thanks to soup
  (Closes: #529271)
- fixes over-advertising content types as supported by
  the media player (Closes: #559420)
* debian/control:
- updated libsoup build requirement (>= 2.28.2)
* debian/libwebkit-1.0-2.symbols:
- updated with new symbols
* debian/copyright:
- updated information since 1.1.17
* Imported patch from https://bugs.webkit.org/show_bug.cgi?id=30623
- I am shipping this patch because I believe it is correct, it is the
  way to go, it fixes a race, and it needs testing.

Show diffs side-by-side

added added

removed removed

Lines of Context:
22
22
 
23
23
#include "CString.h"
24
24
#include <glib/gi18n-lib.h>
 
25
#include "GRefPtr.h"
25
26
#include "Noncopyable.h"
26
27
#include "NotImplemented.h"
27
28
#include "ResourceHandleClient.h"
853
854
    if (priv->currentSize > webkit_download_get_total_size(download))
854
855
        g_object_notify(G_OBJECT(download), "total-size");
855
856
 
856
 
    gdouble lastProgress = webkit_download_get_progress(download);
857
 
 
858
857
    // Throttle progress notification to not consume high amounts of
859
 
    // CPU on fast links, except when the progress is >= 3%, or we
860
 
    // reached the end.
 
858
    // CPU on fast links, except when the last notification occured
 
859
    // in more then 0.7 secs from now, or the last notified progress
 
860
    // is passed in 1% or we reached the end.
 
861
    static gdouble lastProgress = 0;
861
862
    static gdouble lastElapsed = 0;
862
863
    gdouble currentElapsed = g_timer_elapsed(priv->timer, NULL);
 
864
    gdouble currentProgress = webkit_download_get_progress(download);
863
865
 
864
866
    if (lastElapsed
865
 
        && (currentElapsed - lastElapsed) < 0.1
866
 
        && (webkit_download_get_progress(download) - lastProgress) < 0.03
867
 
        && webkit_download_get_progress(download) < 1.0) {
868
 
        lastElapsed = currentElapsed;
 
867
        && lastProgress
 
868
        && (currentElapsed - lastElapsed) < 0.7
 
869
        && (currentProgress - lastProgress) < 0.01
 
870
        && currentProgress < 1.0) {
869
871
        return;
870
872
    }
871
873
    lastElapsed = currentElapsed;
 
874
    lastProgress = currentProgress;
872
875
 
873
876
    g_object_notify(G_OBJECT(download), "progress");
874
877
}
890
893
    webkit_download_close_stream(download);
891
894
 
892
895
    WebKitDownloadPrivate* priv = download->priv;
 
896
    GRefPtr<WebKitDownload> protect(download);
893
897
 
894
898
    g_timer_stop(priv->timer);
895
899
    webkit_download_set_status(download, WEBKIT_DOWNLOAD_STATUS_ERROR);