Changeset 152446 in webkit


Ignore:
Timestamp:
Jul 8, 2013 3:13:06 AM (11 years ago)
Author:
commit-queue@webkit.org
Message:

[GTK] FrameLoaderClient: Refactor naked pointers to use smart pointers
https://bugs.webkit.org/show_bug.cgi?id=118417

Patch by Brian Holt <brian.holt@samsung.com> on 2013-07-08
Reviewed by Carlos Garcia Campos.

Use GOwnPtr and GRefPtr where possible.

  • WebCoreSupport/FrameLoaderClientGtk.cpp:

(WebKit::FrameLoaderClient::dispatchDidFailLoad):

Location:
trunk/Source
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebCore/platform/gtk/SharedBufferGtk.cpp

    r95901 r152446  
    2121
    2222#include "FileSystem.h"
     23#include <wtf/gobject/GOwnPtr.h>
    2324#include <wtf/text/CString.h>
    2425
     
    3435
    3536    CString filename = fileSystemRepresentation(filePath);
    36     gchar* contents;
     37    GOwnPtr<gchar> contents;
    3738    gsize size;
    38     GError* error = 0;
    39     if (!g_file_get_contents(filename.data(), &contents, &size, &error)) {
     39    GOwnPtr<GError> error;
     40    if (!g_file_get_contents(filename.data(), &contents.outPtr(), &size, &error.outPtr())) {
    4041        LOG_ERROR("Failed to fully read contents of file %s - %s", filenameForDisplay(filePath).utf8().data(), error->message);
    41         g_error_free(error);
    4242        return 0;
    4343    }
    4444
    45     RefPtr<SharedBuffer> result = SharedBuffer::create(contents, size);
    46     g_free(contents);
     45    RefPtr<SharedBuffer> result = SharedBuffer::create(contents.get(), size);
    4746
    4847    return result.release();
  • trunk/Source/WebKit/gtk/ChangeLog

    r152396 r152446  
     12013-07-08  Brian Holt  <brian.holt@samsung.com>
     2
     3        [GTK] FrameLoaderClient: Refactor naked pointers to use smart pointers
     4        https://bugs.webkit.org/show_bug.cgi?id=118417
     5
     6        Reviewed by Carlos Garcia Campos.
     7
     8        Use GOwnPtr and GRefPtr where possible.
     9
     10        * WebCoreSupport/FrameLoaderClientGtk.cpp:
     11        (WebKit::FrameLoaderClient::dispatchDidFailLoad):
     12
    1132013-07-04  Mario Sanchez Prada  <mario.prada@samsung.com>
    214
  • trunk/Source/WebKit/gtk/WebCoreSupport/FrameLoaderClientGtk.cpp

    r149952 r152446  
    10661066
    10671067    WebKitWebView* webView = getViewFromFrame(m_frame);
    1068     GError* webError = g_error_new_literal(g_quark_from_string(error.domain().utf8().data()),
    1069                                            error.errorCode(),
    1070                                            error.localizedDescription().utf8().data());
     1068    GOwnPtr<GError> webError(g_error_new_literal(
     1069        g_quark_from_string(error.domain().utf8().data()),
     1070        error.errorCode(),
     1071        error.localizedDescription().utf8().data()));
    10711072    gboolean isHandled = false;
    1072     g_signal_emit_by_name(webView, "load-error", m_frame, error.failingURL().utf8().data(), webError, &isHandled);
    1073 
    1074     if (isHandled) {
    1075         g_error_free(webError);
    1076         return;
    1077     }
    1078 
    1079     if (!shouldFallBack(error)) {
    1080         g_error_free(webError);
    1081         return;
    1082     }
     1073    g_signal_emit_by_name(webView, "load-error", m_frame, error.failingURL().utf8().data(), webError.get(), &isHandled);
     1074
     1075    if (isHandled || !shouldFallBack(error))
     1076        return;
    10831077
    10841078    m_loadingErrorPage = true;
    10851079
    10861080    String content;
    1087     gchar* fileContent = 0;
    10881081    GOwnPtr<gchar> errorPath(g_build_filename(sharedResourcesPath().data(), "resources", "error.html", NULL));
    1089     gchar* errorURI = g_filename_to_uri(errorPath.get(), 0, 0);
    1090 
    1091     GFile* errorFile = g_file_new_for_uri(errorURI);
    1092     g_free(errorURI);
     1082    GRefPtr<GFile> errorFile = adoptGRef(g_file_new_for_path(errorPath.get()));
    10931083
    10941084    if (!errorFile)
    10951085        content = makeString("<html><body>", webError->message, "</body></html>");
    10961086    else {
    1097         gboolean loaded = g_file_load_contents(errorFile, 0, &fileContent, 0, 0, 0);
    1098         if (!loaded)
     1087        GOwnPtr<gchar> fileContent;
     1088        if (!g_file_load_contents(errorFile.get(), 0, &fileContent.outPtr(), 0, 0, 0))
    10991089            content = makeString("<html><body>", webError->message, "</body></html>");
    11001090        else
    1101             content = String::format(fileContent, error.failingURL().utf8().data(), webError->message);
     1091            content = String::format(fileContent.get(), error.failingURL().utf8().data(), webError->message);
    11021092    }
    11031093
    11041094    webkit_web_frame_load_alternate_string(m_frame, content.utf8().data(), 0, error.failingURL().utf8().data());
    1105 
    1106     g_free(fileContent);
    1107 
    1108     if (errorFile)
    1109         g_object_unref(errorFile);
    1110 
    1111     g_error_free(webError);
    11121095}
    11131096
Note: See TracChangeset for help on using the changeset viewer.