Changeset 130036 in webkit


Ignore:
Timestamp:
Oct 1, 2012, 4:30:40 AM (13 years ago)
Author:
commit-queue@webkit.org
Message:

[GTK] WebKitDownload: use more of GOwnPtr/GRefPtr
https://bugs.webkit.org/show_bug.cgi?id=98009

Patch by Claudio Saavedra <Claudio Saavedra> on 2012-10-01
Reviewed by Carlos Garcia Campos.

Use more GOwnPtr/GRefPtr in WebKitDownload

  • webkit/webkitdownload.cpp:

(webkit_download_open_stream_for_uri): Use GRefPtr
for a GFile and GOwnPtr for GError.
(webkit_download_set_destination_uri): Ditto.
(webkit_download_received_data): Use GOwnPtr for GError.

Location:
trunk/Source/WebKit/gtk
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebKit/gtk/ChangeLog

    r129924 r130036  
     12012-10-01  Claudio Saavedra  <csaavedra@igalia.com>
     2
     3        [GTK] WebKitDownload: use more of GOwnPtr/GRefPtr
     4        https://bugs.webkit.org/show_bug.cgi?id=98009
     5
     6        Reviewed by Carlos Garcia Campos.
     7
     8        Use more GOwnPtr/GRefPtr in WebKitDownload
     9
     10        * webkit/webkitdownload.cpp:
     11        (webkit_download_open_stream_for_uri): Use GRefPtr
     12        for a GFile and GOwnPtr for GError.
     13        (webkit_download_set_destination_uri): Ditto.
     14        (webkit_download_received_data): Use GOwnPtr for GError.
     15
    1162012-09-28  Mikhail Pozdnyakov  <mikhail.pozdnyakov@intel.com>
    217
  • trunk/Source/WebKit/gtk/webkit/webkitdownload.cpp

    r116525 r130036  
    3939#include <glib/gstdio.h>
    4040#include <wtf/Noncopyable.h>
     41#include <wtf/gobject/GOwnPtr.h>
    4142#include <wtf/gobject/GRefPtr.h>
    4243#include <wtf/text/CString.h>
     
    460461
    461462    WebKitDownloadPrivate* priv = download->priv;
    462     GFile* file = g_file_new_for_uri(uri);
    463     GError* error = NULL;
     463    GRefPtr<GFile> file = adoptGRef(g_file_new_for_uri(uri));
     464    GOwnPtr<GError> error;
    464465
    465466    if (append)
    466         priv->outputStream = g_file_append_to(file, G_FILE_CREATE_NONE, NULL, &error);
     467        priv->outputStream = g_file_append_to(file.get(), G_FILE_CREATE_NONE, NULL, &error.outPtr());
    467468    else
    468         priv->outputStream = g_file_replace(file, NULL, TRUE, G_FILE_CREATE_NONE, NULL, &error);
    469 
    470     g_object_unref(file);
     469        priv->outputStream = g_file_replace(file.get(), NULL, TRUE, G_FILE_CREATE_NONE, NULL, &error.outPtr());
    471470
    472471    if (error) {
    473472        webkitDownloadEmitError(download, downloadDestinationError(core(priv->networkResponse), error->message));
    474         g_error_free(error);
    475473        return FALSE;
    476474    }
     
    697695            webkit_download_close_stream(download);
    698696
    699         GFile* src = g_file_new_for_uri(priv->destinationURI);
    700         GFile* dest = g_file_new_for_uri(destination_uri);
    701         GError* error = NULL;
    702 
    703         g_file_move(src, dest, G_FILE_COPY_BACKUP, NULL, NULL, NULL, &error);
    704 
    705         g_object_unref(src);
    706         g_object_unref(dest);
     697        GRefPtr<GFile> src = adoptGRef(g_file_new_for_uri(priv->destinationURI));
     698        GRefPtr<GFile> dest = adoptGRef(g_file_new_for_uri(destination_uri));
     699        GOwnPtr<GError> error;
     700
     701        g_file_move(src.get(), dest.get(), G_FILE_COPY_BACKUP, 0, 0, 0, &error.outPtr());
    707702
    708703        g_free(priv->destinationURI);
     
    711706        if (error) {
    712707            webkitDownloadEmitError(download, downloadDestinationError(core(priv->networkResponse), error->message));
    713             g_error_free(error);
    714708            return;
    715709        }
     
    863857
    864858    gsize bytes_written;
    865     GError* error = NULL;
     859    GOwnPtr<GError> error;
    866860
    867861    g_output_stream_write_all(G_OUTPUT_STREAM(priv->outputStream),
    868                               data, length, &bytes_written, NULL, &error);
     862                              data, length, &bytes_written, NULL, &error.outPtr());
    869863
    870864    if (error) {
    871865        webkitDownloadEmitError(download, downloadDestinationError(core(priv->networkResponse), error->message));
    872         g_error_free(error);
    873866        return;
    874867    }
Note: See TracChangeset for help on using the changeset viewer.