Title: [122411] trunk/Source/WebKit2
Revision
122411
Author
[email protected]
Date
2012-07-11 20:22:03 -0700 (Wed, 11 Jul 2012)

Log Message

[WK2][EFL] Ewk_View should provide more resource loading notifications
https://bugs.webkit.org/show_bug.cgi?id=90601

Patch by Christophe Dumez <[email protected]> on 2012-07-11
Reviewed by Antonio Gomes.

Add new "resource,request,sent", "resource,request,response",
"resource,request,failed" and "resource,request,finished" to
Ewk_View in order to notify the clients of the main resource
load state changes.

Introduce new Ewk_Url_Response type that is used to provide
information to the clients regarding the resource load
responses that are received.

* PlatformEfl.cmake:
* UIProcess/API/efl/EWebKit2.h:
* UIProcess/API/efl/ewk_url_response.cpp: Added.
(_Ewk_Url_Response):
(ewk_url_response_ref):
(ewk_url_response_unref):
(ewk_url_response_url_get):
(ewk_url_response_status_code_get):
(ewk_url_response_mime_type_get):
(ewk_url_response_new):
* UIProcess/API/efl/ewk_url_response.h: Added.
* UIProcess/API/efl/ewk_url_response_private.h: Added.
* UIProcess/API/efl/ewk_view.cpp:
(_Ewk_View_Private_Data):
(ewk_view_resource_load_initiated):
(ewk_view_resource_load_response):
(ewk_view_resource_load_failed):
(ewk_view_resource_load_finished):
(ewk_view_resource_request_sent):
(ewk_view_load_provisional_started):
* UIProcess/API/efl/ewk_view.h:
* UIProcess/API/efl/ewk_view_private.h:
* UIProcess/API/efl/ewk_view_resource_load_client.cpp:
(toEwkView):
(didInitiateLoadForResource):
(didSendRequestForResource):
(didReceiveResponseForResource):
(didFinishLoadForResource):
(didFailLoadForResource):
(ewk_view_resource_load_client_attach):

Modified Paths

Added Paths

Diff

Modified: trunk/Source/WebKit2/ChangeLog (122410 => 122411)


--- trunk/Source/WebKit2/ChangeLog	2012-07-12 03:08:25 UTC (rev 122410)
+++ trunk/Source/WebKit2/ChangeLog	2012-07-12 03:22:03 UTC (rev 122411)
@@ -1,3 +1,50 @@
+2012-07-11  Christophe Dumez  <[email protected]>
+
+        [WK2][EFL] Ewk_View should provide more resource loading notifications
+        https://bugs.webkit.org/show_bug.cgi?id=90601
+
+        Reviewed by Antonio Gomes.
+
+        Add new "resource,request,sent", "resource,request,response",
+        "resource,request,failed" and "resource,request,finished" to
+        Ewk_View in order to notify the clients of the main resource
+        load state changes.
+
+        Introduce new Ewk_Url_Response type that is used to provide
+        information to the clients regarding the resource load
+        responses that are received.
+
+        * PlatformEfl.cmake:
+        * UIProcess/API/efl/EWebKit2.h:
+        * UIProcess/API/efl/ewk_url_response.cpp: Added.
+        (_Ewk_Url_Response):
+        (ewk_url_response_ref):
+        (ewk_url_response_unref):
+        (ewk_url_response_url_get):
+        (ewk_url_response_status_code_get):
+        (ewk_url_response_mime_type_get):
+        (ewk_url_response_new):
+        * UIProcess/API/efl/ewk_url_response.h: Added.
+        * UIProcess/API/efl/ewk_url_response_private.h: Added.
+        * UIProcess/API/efl/ewk_view.cpp:
+        (_Ewk_View_Private_Data):
+        (ewk_view_resource_load_initiated):
+        (ewk_view_resource_load_response):
+        (ewk_view_resource_load_failed):
+        (ewk_view_resource_load_finished):
+        (ewk_view_resource_request_sent):
+        (ewk_view_load_provisional_started):
+        * UIProcess/API/efl/ewk_view.h:
+        * UIProcess/API/efl/ewk_view_private.h:
+        * UIProcess/API/efl/ewk_view_resource_load_client.cpp:
+        (toEwkView):
+        (didInitiateLoadForResource):
+        (didSendRequestForResource):
+        (didReceiveResponseForResource):
+        (didFinishLoadForResource):
+        (didFailLoadForResource):
+        (ewk_view_resource_load_client_attach):
+
 2012-07-11  Mark Rowe  <[email protected]>
 
         Fix a logic error in the #if so that the correct code is compiled on Snow Leopard.

Modified: trunk/Source/WebKit2/PlatformEfl.cmake (122410 => 122411)


--- trunk/Source/WebKit2/PlatformEfl.cmake	2012-07-12 03:08:25 UTC (rev 122410)
+++ trunk/Source/WebKit2/PlatformEfl.cmake	2012-07-12 03:22:03 UTC (rev 122411)
@@ -38,6 +38,7 @@
     UIProcess/API/efl/ewk_intent.cpp
     UIProcess/API/efl/ewk_intent_service.cpp
     UIProcess/API/efl/ewk_url_request.cpp
+    UIProcess/API/efl/ewk_url_response.cpp
     UIProcess/API/efl/ewk_view.cpp
     UIProcess/API/efl/ewk_view_loader_client.cpp
     UIProcess/API/efl/ewk_view_resource_load_client.cpp

Modified: trunk/Source/WebKit2/UIProcess/API/efl/EWebKit2.h (122410 => 122411)


--- trunk/Source/WebKit2/UIProcess/API/efl/EWebKit2.h	2012-07-12 03:08:25 UTC (rev 122410)
+++ trunk/Source/WebKit2/UIProcess/API/efl/EWebKit2.h	2012-07-12 03:22:03 UTC (rev 122411)
@@ -31,6 +31,7 @@
 #include "ewk_intent.h"
 #include "ewk_intent_service.h"
 #include "ewk_url_request.h"
+#include "ewk_url_response.h"
 #include "ewk_view.h"
 #include "ewk_web_error.h"
 #include "ewk_web_resource.h"

Added: trunk/Source/WebKit2/UIProcess/API/efl/ewk_url_response.cpp (0 => 122411)


--- trunk/Source/WebKit2/UIProcess/API/efl/ewk_url_response.cpp	                        (rev 0)
+++ trunk/Source/WebKit2/UIProcess/API/efl/ewk_url_response.cpp	2012-07-12 03:22:03 UTC (rev 122411)
@@ -0,0 +1,100 @@
+/*
+ * Copyright (C) 2012 Intel Corporation. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS''
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
+ * THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "config.h"
+#include "ewk_url_response.h"
+
+#include "ewk_url_response_private.h"
+#include <wtf/text/CString.h>
+
+/**
+ * \struct  _Ewk_Url_Response
+ * @brief   Contains the URL response data.
+ */
+struct _Ewk_Url_Response {
+    unsigned int __ref; /**< the reference count of the object */
+    WebCore::ResourceResponse coreResponse;
+
+    const char* url;
+    const char* mimeType;
+};
+
+void ewk_url_response_ref(Ewk_Url_Response* response)
+{
+    EINA_SAFETY_ON_NULL_RETURN(response);
+    ++response->__ref;
+}
+
+void ewk_url_response_unref(Ewk_Url_Response* response)
+{
+    EINA_SAFETY_ON_NULL_RETURN(response);
+
+    if (--response->__ref)
+        return;
+
+    eina_stringshare_del(response->url);
+    eina_stringshare_del(response->mimeType);
+    free(response);
+}
+
+const char* ewk_url_response_url_get(const Ewk_Url_Response* response)
+{
+    EINA_SAFETY_ON_NULL_RETURN_VAL(response, 0);
+
+    Ewk_Url_Response* ewkResponse = const_cast<Ewk_Url_Response*>(response);
+    eina_stringshare_replace(&ewkResponse->url, response->coreResponse.url().string().utf8().data());
+
+    return response->url;
+}
+
+int ewk_url_response_status_code_get(const Ewk_Url_Response* response)
+{
+    EINA_SAFETY_ON_NULL_RETURN_VAL(response, 0);
+
+    return response->coreResponse.httpStatusCode();
+}
+
+const char* ewk_url_response_mime_type_get(const Ewk_Url_Response* response)
+{
+    EINA_SAFETY_ON_NULL_RETURN_VAL(response, 0);
+
+    Ewk_Url_Response* ewkResponse = const_cast<Ewk_Url_Response*>(response);
+    eina_stringshare_replace(&ewkResponse->mimeType, response->coreResponse.mimeType().utf8().data());
+
+    return response->mimeType;
+}
+
+/**
+ * @internal
+ * Constructs a Ewk_Url_Response from a WebCore::ResourceResponse.
+ */
+Ewk_Url_Response* ewk_url_response_new(const WebCore::ResourceResponse& coreResponse)
+{
+    Ewk_Url_Response* ewkUrlResponse = static_cast<Ewk_Url_Response*>(calloc(1, sizeof(Ewk_Url_Response)));
+    ewkUrlResponse->__ref = 1;
+    ewkUrlResponse->coreResponse = coreResponse;
+
+    return ewkUrlResponse;
+}

Added: trunk/Source/WebKit2/UIProcess/API/efl/ewk_url_response.h (0 => 122411)


--- trunk/Source/WebKit2/UIProcess/API/efl/ewk_url_response.h	                        (rev 0)
+++ trunk/Source/WebKit2/UIProcess/API/efl/ewk_url_response.h	2012-07-12 03:22:03 UTC (rev 122411)
@@ -0,0 +1,101 @@
+/*
+ * Copyright (C) 2012 Intel Corporation. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS''
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
+ * THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+/**
+ * @file    ewk_url_response.h
+ * @brief   Describes the Ewk URL response API.
+ */
+
+#ifndef ewk_url_response_h
+#define ewk_url_response_h
+
+#include <Eina.h>
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+/** Creates a type name for _Ewk_Url_Response */
+typedef struct _Ewk_Url_Response Ewk_Url_Response;
+
+/**
+ * Increases the reference count of the given object.
+ *
+ * @param response the URL response object to increase the reference count
+ */
+EAPI void ewk_url_response_ref(Ewk_Url_Response *response);
+
+/**
+ * Decreases the reference count of the given object, possibly freeing it.
+ *
+ * When the reference count it's reached 0, the URL request is freed.
+ *
+ * @param response the URL response object to decrease the reference count
+ */
+EAPI void ewk_url_response_unref(Ewk_Url_Response *response);
+
+/**
+ * Query URL for this response.
+ *
+ * @param response response object to query.
+ *
+ * @return the URL pointer, that may be @c NULL. This pointer is
+ *         guaranteed to be eina_stringshare, so whenever possible
+ *         save yourself some cpu cycles and use
+ *         eina_stringshare_ref() instead of eina_stringshare_add() or
+ *         strdup().
+ */
+EAPI const char *ewk_url_response_url_get(const Ewk_Url_Response *response);
+
+/**
+ * Query HTTP status code for this response.
+ *
+ * HTTP status code are defined by:
+ * http://www.w3.org/Protocols/rfc2616/rfc2616-sec10.html
+ *
+ * @param response response object to query.
+ *
+ * @return the HTTP status code.
+ */
+EAPI int ewk_url_response_status_code_get(const Ewk_Url_Response *response);
+
+/**
+ * Query MIME type for this response.
+ *
+ * @param response response object to query.
+ *
+ * @return the MIME type pointer, that may be @c NULL. This pointer is
+ *         guaranteed to be eina_stringshare, so whenever possible
+ *         save yourself some cpu cycles and use
+ *         eina_stringshare_ref() instead of eina_stringshare_add() or
+ *         strdup().
+ */
+EAPI const char *ewk_url_response_mime_type_get(const Ewk_Url_Response *response);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif // ewk_url_response_h

Added: trunk/Source/WebKit2/UIProcess/API/efl/ewk_url_response_private.h (0 => 122411)


--- trunk/Source/WebKit2/UIProcess/API/efl/ewk_url_response_private.h	                        (rev 0)
+++ trunk/Source/WebKit2/UIProcess/API/efl/ewk_url_response_private.h	2012-07-12 03:22:03 UTC (rev 122411)
@@ -0,0 +1,35 @@
+/*
+ * Copyright (C) 2012 Intel Corporation. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS''
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
+ * THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#ifndef ewk_url_response_private_h
+#define ewk_url_response_private_h
+
+#include <WebCore/ResourceResponse.h>
+
+typedef struct _Ewk_Url_Response Ewk_Url_Response;
+
+Ewk_Url_Response* ewk_url_response_new(const WebCore::ResourceResponse& resourceResponse);
+
+#endif // ewk_url_response_private_h

Modified: trunk/Source/WebKit2/UIProcess/API/efl/ewk_view.cpp (122410 => 122411)


--- trunk/Source/WebKit2/UIProcess/API/efl/ewk_view.cpp	2012-07-12 03:08:25 UTC (rev 122410)
+++ trunk/Source/WebKit2/UIProcess/API/efl/ewk_view.cpp	2012-07-12 03:22:03 UTC (rev 122411)
@@ -34,6 +34,7 @@
 #include "ewk_view_loader_client_private.h"
 #include "ewk_view_private.h"
 #include "ewk_view_resource_load_client_private.h"
+#include "ewk_web_resource.h"
 #include <wtf/text/CString.h>
 
 using namespace WebKit;
@@ -41,10 +42,13 @@
 
 static const char EWK_VIEW_TYPE_STR[] = "EWK2_View";
 
+typedef HashMap<uint64_t, Ewk_Web_Resource*> LoadingResourcesMap;
+
 struct _Ewk_View_Private_Data {
     OwnPtr<PageClientImpl> pageClient;
     const char* uri;
     const char* title;
+    LoadingResourcesMap loadingResourcesMap;
 };
 
 #define EWK_VIEW_TYPE_CHECK(ewkView, result)                                   \
@@ -567,12 +571,96 @@
  */
 void ewk_view_resource_load_initiated(Evas_Object* ewkView, uint64_t resourceIdentifier, Ewk_Web_Resource* resource, Ewk_Url_Request* request)
 {
-    Ewk_Web_Resource_Request resourceRequest = {resource, request};
-    // FIXME: We will need to store the resource and its identifier at some point
-    // to get the resource back from the identifier on resource load finish.
+    EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData);
+    EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv);
+
+    Ewk_Web_Resource_Request resourceRequest = {resource, request, 0};
+
+    // Keep the resource internally to reuse it later.
+    ewk_web_resource_ref(resource);
+    priv->loadingResourcesMap.add(resourceIdentifier, resource);
+
     evas_object_smart_callback_call(ewkView, "resource,request,new", &resourceRequest);
 }
 
+/**
+ * @internal
+ * Received a response to a resource load request in the view.
+ *
+ * Emits signal: "resource,request,response" with pointer to resource response.
+ */
+void ewk_view_resource_load_response(Evas_Object* ewkView, uint64_t resourceIdentifier, Ewk_Url_Response* response)
+{
+    EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData);
+    EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv);
+
+    if (!priv->loadingResourcesMap.contains(resourceIdentifier))
+        return;
+
+    Ewk_Web_Resource* resource = priv->loadingResourcesMap.get(resourceIdentifier);
+    Ewk_Web_Resource_Load_Response resourceLoadResponse = {resource, response};
+    evas_object_smart_callback_call(ewkView, "resource,request,response", &resourceLoadResponse);
+}
+
+/**
+ * @internal
+ * Failed loading a resource in the view.
+ *
+ * Emits signal: "resource,request,finished" with pointer to the resource load error.
+ */
+void ewk_view_resource_load_failed(Evas_Object* ewkView, uint64_t resourceIdentifier, Ewk_Web_Error* error)
+{
+    EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData);
+    EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv);
+
+    if (!priv->loadingResourcesMap.contains(resourceIdentifier))
+        return;
+
+    Ewk_Web_Resource* resource = priv->loadingResourcesMap.get(resourceIdentifier);
+    Ewk_Web_Resource_Load_Error resourceLoadError = {resource, error};
+    evas_object_smart_callback_call(ewkView, "resource,request,failed", &resourceLoadError);
+}
+
+/**
+ * @internal
+ * Finished loading a resource in the view.
+ *
+ * Emits signal: "resource,request,finished" with pointer to the resource.
+ */
+void ewk_view_resource_load_finished(Evas_Object* ewkView, uint64_t resourceIdentifier)
+{
+    EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData);
+    EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv);
+
+    if (!priv->loadingResourcesMap.contains(resourceIdentifier))
+        return;
+
+    Ewk_Web_Resource* resource = priv->loadingResourcesMap.take(resourceIdentifier);
+    evas_object_smart_callback_call(ewkView, "resource,request,finished", resource);
+
+    ewk_web_resource_unref(resource);
+}
+
+/**
+ * @internal
+ * Request was sent for a resource in the view.
+ *
+ * Emits signal: "resource,request,sent" with pointer to resource request and possible redirect response.
+ */
+void ewk_view_resource_request_sent(Evas_Object* ewkView, uint64_t resourceIdentifier, Ewk_Url_Request* request, Ewk_Url_Response* redirectResponse)
+{
+    EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData);
+    EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv);
+
+    if (!priv->loadingResourcesMap.contains(resourceIdentifier))
+        return;
+
+    Ewk_Web_Resource* resource = priv->loadingResourcesMap.get(resourceIdentifier);
+    Ewk_Web_Resource_Request resourceRequest = {resource, request, redirectResponse};
+
+    evas_object_smart_callback_call(ewkView, "resource,request,sent", &resourceRequest);
+}
+
 const char* ewk_view_title_get(const Evas_Object* ewkView)
 {
     EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, 0);
@@ -773,6 +861,17 @@
  */
 void ewk_view_load_provisional_started(Evas_Object* ewkView)
 {
+    EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData);
+    EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv);
+
+    // The main frame started provisional load, we should clear
+    // the loadingResources HashMap to start clean.
+    LoadingResourcesMap::iterator it = priv->loadingResourcesMap.begin();
+    LoadingResourcesMap::iterator end = priv->loadingResourcesMap.end();
+    for ( ; it != end; ++it)
+        ewk_web_resource_unref(it->second);
+    priv->loadingResourcesMap.clear();
+
     evas_object_smart_callback_call(ewkView, "load,provisional,started", 0);
 }
 

Modified: trunk/Source/WebKit2/UIProcess/API/efl/ewk_view.h (122410 => 122411)


--- trunk/Source/WebKit2/UIProcess/API/efl/ewk_view.h	2012-07-12 03:08:25 UTC (rev 122410)
+++ trunk/Source/WebKit2/UIProcess/API/efl/ewk_view.h	2012-07-12 03:22:03 UTC (rev 122411)
@@ -34,7 +34,11 @@
  * - "load,provisional,failed", const Ewk_Web_Error*: view provisional load failed.
  * - "load,provisional,redirect", void: view received redirect for provisional load.
  * - "load,provisional,started", void: view started provisional load.
+ * - "resource,request,failed", const Ewk_Web_Resource_Load_Error*: a resource failed loading.
+ * - "resource,request,finished", const Ewk_Web_Resource*: a resource finished loading.
  * - "resource,request,new", const Ewk_Web_Resource_Request*: a resource request was initiated.
+ * - "resource,request,response", Ewk_Web_Resource_Load_Response*: a response to a resource request was received.
+ * - "resource,request,sent", const Ewk_Web_Resource_Request*: a resource request was sent.
  * - "title,changed", const char*: title of the main frame was changed.
  */
 
@@ -44,6 +48,8 @@
 #include "ewk_context.h"
 #include "ewk_intent.h"
 #include "ewk_url_request.h"
+#include "ewk_url_response.h"
+#include "ewk_web_error.h"
 #include "ewk_web_resource.h"
 #include <Evas.h>
 
@@ -145,15 +151,38 @@
 
 /**
  * @brief Structure containing details about a resource request.
- *
- * Details given about a resource is loaded.
  */
 struct _Ewk_Web_Resource_Request {
     Ewk_Web_Resource *resource; /**< resource being requested */
     Ewk_Url_Request *request; /**< URL request for the resource */
+    Ewk_Url_Response *redirect_response; /**< Possible redirect response for the resource */
 };
 
+/// Creates a type name for _Ewk_Web_Resource_Load_Response.
+typedef struct _Ewk_Web_Resource_Load_Response Ewk_Web_Resource_Load_Response;
+
 /**
+ * @brief Structure containing details about a response to a resource request.
+ */
+struct _Ewk_Web_Resource_Load_Response {
+     Ewk_Web_Resource *resource; /**< resource requested */
+     Ewk_Url_Response *response; /**< resource load response */
+};
+
+/// Creates a type name for _Ewk_Web_Resource_Load_Error.
+typedef struct _Ewk_Web_Resource_Load_Error Ewk_Web_Resource_Load_Error;
+
+/**
+ * @brief Structure containing details about a resource load error.
+ *
+ * Details given about a resource load failure.
+ */
+struct _Ewk_Web_Resource_Load_Error {
+    Ewk_Web_Resource *resource; /**< resource that failed loading */
+    Ewk_Web_Error *error; /**< load error */
+};
+
+/**
  * Creates a new EFL WebKit view object.
  *
  * @param e canvas object where to create the view object

Modified: trunk/Source/WebKit2/UIProcess/API/efl/ewk_view_private.h (122410 => 122411)


--- trunk/Source/WebKit2/UIProcess/API/efl/ewk_view_private.h	2012-07-12 03:08:25 UTC (rev 122410)
+++ trunk/Source/WebKit2/UIProcess/API/efl/ewk_view_private.h	2012-07-12 03:22:03 UTC (rev 122411)
@@ -31,6 +31,7 @@
 }
 
 typedef struct _Ewk_Url_Request Ewk_Url_Request;
+typedef struct _Ewk_Url_Response Ewk_Url_Response;
 typedef struct _Ewk_Web_Error Ewk_Web_Error;
 typedef struct _Ewk_Web_Resource Ewk_Web_Resource;
 #if ENABLE(WEB_INTENTS)
@@ -49,7 +50,11 @@
 void ewk_view_load_provisional_redirect(Evas_Object* ewkView);
 void ewk_view_load_provisional_started(Evas_Object* ewkView);
 void ewk_view_title_changed(Evas_Object* ewkView, const char* title);
+void ewk_view_resource_load_failed(Evas_Object* ewkView, uint64_t resourceIdentifier, Ewk_Web_Error* error);
+void ewk_view_resource_load_finished(Evas_Object* ewkView, uint64_t resourceIdentifier);
 void ewk_view_resource_load_initiated(Evas_Object* ewkView, uint64_t resourceIdentifier, Ewk_Web_Resource* resource, Ewk_Url_Request* request);
+void ewk_view_resource_load_response(Evas_Object* ewkView, uint64_t resourceIdentifier, Ewk_Url_Response* response);
+void ewk_view_resource_request_sent(Evas_Object* ewkView, uint64_t resourceIdentifier, Ewk_Url_Request* request, Ewk_Url_Response* redirectResponse);
 
 Evas_Object* ewk_view_base_add(Evas* canvas, WKContextRef, WKPageGroupRef);
 

Modified: trunk/Source/WebKit2/UIProcess/API/efl/ewk_view_resource_load_client.cpp (122410 => 122411)


--- trunk/Source/WebKit2/UIProcess/API/efl/ewk_view_resource_load_client.cpp	2012-07-12 03:08:25 UTC (rev 122410)
+++ trunk/Source/WebKit2/UIProcess/API/efl/ewk_view_resource_load_client.cpp	2012-07-12 03:22:03 UTC (rev 122411)
@@ -31,29 +31,67 @@
 #include "WKRetainPtr.h"
 #include "WKURL.h"
 #include "WKURLRequest.h"
+#include "WKURLResponse.h"
 #include "ewk_url_request.h"
 #include "ewk_url_request_private.h"
+#include "ewk_url_response.h"
+#include "ewk_url_response_private.h"
 #include "ewk_view_private.h"
 #include "ewk_view_resource_load_client_private.h"
+#include "ewk_web_error.h"
+#include "ewk_web_error_private.h"
 #include "ewk_web_resource.h"
 #include "ewk_web_resource_private.h"
 #include <wtf/text/CString.h>
 
 using namespace WebKit;
 
+static inline Evas_Object* toEwkView(const void* clientInfo)
+{
+    return static_cast<Evas_Object*>(const_cast<void*>(clientInfo));
+}
+
 static void didInitiateLoadForResource(WKPageRef, WKFrameRef wkFrame, uint64_t resourceIdentifier, WKURLRequestRef wkRequest, bool pageIsProvisionallyLoading, const void* clientInfo)
 {
-    Evas_Object* ewkView = static_cast<Evas_Object*>(const_cast<void*>(clientInfo));
     bool isMainResource = (WKFrameIsMainFrame(wkFrame) && pageIsProvisionallyLoading);
     WKRetainPtr<WKURLRef> wkUrl(AdoptWK, WKURLRequestCopyURL(wkRequest));
 
     Ewk_Web_Resource* resource = ewk_web_resource_new(toImpl(wkUrl.get())->string().utf8().data(), isMainResource);
     Ewk_Url_Request* request = ewk_url_request_new(wkRequest);
-    ewk_view_resource_load_initiated(ewkView, resourceIdentifier, resource, request);
+    ewk_view_resource_load_initiated(toEwkView(clientInfo), resourceIdentifier, resource, request);
     ewk_web_resource_unref(resource);
     ewk_url_request_unref(request);
 }
 
+static void didSendRequestForResource(WKPageRef, WKFrameRef, uint64_t resourceIdentifier, WKURLRequestRef wkRequest, WKURLResponseRef wkRedirectResponse, const void* clientInfo)
+{
+    Ewk_Url_Request* request = ewk_url_request_new(wkRequest);
+    Ewk_Url_Response* redirectResponse = ewk_url_response_new(toImpl(wkRedirectResponse)->resourceResponse());
+    ewk_view_resource_request_sent(toEwkView(clientInfo), resourceIdentifier, request, redirectResponse);
+    ewk_url_request_unref(request);
+    ewk_url_response_unref(redirectResponse);
+}
+
+static void didReceiveResponseForResource(WKPageRef, WKFrameRef, uint64_t resourceIdentifier, WKURLResponseRef wkResponse, const void* clientInfo)
+{
+    Ewk_Url_Response* response = ewk_url_response_new(toImpl(wkResponse)->resourceResponse());
+    ewk_view_resource_load_response(toEwkView(clientInfo), resourceIdentifier, response);
+    ewk_url_response_unref(response);
+}
+
+static void didFinishLoadForResource(WKPageRef, WKFrameRef, uint64_t resourceIdentifier, const void* clientInfo)
+{
+    ewk_view_resource_load_finished(toEwkView(clientInfo), resourceIdentifier);
+}
+
+static void didFailLoadForResource(WKPageRef, WKFrameRef, uint64_t resourceIdentifier, WKErrorRef wkError, const void* clientInfo)
+{
+    Ewk_Web_Error* ewkError = ewk_web_error_new(wkError);
+    ewk_view_resource_load_failed(toEwkView(clientInfo), resourceIdentifier, ewkError);
+    ewk_view_resource_load_finished(toEwkView(clientInfo), resourceIdentifier);
+    ewk_web_error_free(ewkError);
+}
+
 void ewk_view_resource_load_client_attach(WKPageRef pageRef, Evas_Object* ewkView)
 {
     WKPageResourceLoadClient wkResourceLoadClient;
@@ -61,6 +99,10 @@
     wkResourceLoadClient.version = kWKPageResourceLoadClientCurrentVersion;
     wkResourceLoadClient.clientInfo = ewkView;
     wkResourceLoadClient.didInitiateLoadForResource = didInitiateLoadForResource;
+    wkResourceLoadClient.didSendRequestForResource = didSendRequestForResource;
+    wkResourceLoadClient.didReceiveResponseForResource = didReceiveResponseForResource;
+    wkResourceLoadClient.didFinishLoadForResource = didFinishLoadForResource;
+    wkResourceLoadClient.didFailLoadForResource = didFailLoadForResource;
 
     WKPageSetPageResourceLoadClient(pageRef, &wkResourceLoadClient);
 }
_______________________________________________
webkit-changes mailing list
[email protected]
http://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to