Create string tightly when retrive string from cbhm callback event
[framework/web/webkit-efl.git] / Source / WebKit2 / UIProcess / API / efl / ewk_url_response.cpp
1 /*
2  * Copyright (C) 2012 Intel Corporation. All rights reserved.
3  *
4  * Redistribution and use in source and binary forms, with or without
5  * modification, are permitted provided that the following conditions
6  * are met:
7  * 1. Redistributions of source code must retain the above copyright
8  *    notice, this list of conditions and the following disclaimer.
9  * 2. Redistributions in binary form must reproduce the above copyright
10  *    notice, this list of conditions and the following disclaimer in the
11  *    documentation and/or other materials provided with the distribution.
12  *
13  * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS''
14  * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
15  * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
16  * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS
17  * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
18  * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
19  * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
20  * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
21  * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
22  * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
23  * THE POSSIBILITY OF SUCH DAMAGE.
24  */
25
26 #include "config.h"
27 #include "ewk_url_response.h"
28
29 #include "ewk_url_response_private.h"
30 #include <wtf/text/CString.h>
31
32 using namespace WebKit;
33
34 Ewk_Url_Response::Ewk_Url_Response(const WebCore::ResourceResponse& coreResponse)
35     : m_coreResponse(coreResponse)
36     , m_url(AdoptWK, WKURLResponseCopyURL(WebKit::toAPI(coreResponse)))
37     , m_mimeType(AdoptWK, WKURLResponseCopyMIMEType(WebKit::toAPI(coreResponse)))
38 { }
39
40 int Ewk_Url_Response::httpStatusCode() const
41 {
42     return m_coreResponse.httpStatusCode();
43 }
44
45 const char* Ewk_Url_Response::url() const
46 {
47     return m_url;
48 }
49
50 const char* Ewk_Url_Response::mimeType() const
51 {
52     return m_mimeType;
53 }
54
55 unsigned long Ewk_Url_Response::contentLength() const
56 {
57     return m_coreResponse.expectedContentLength();
58 }
59
60 Ewk_Url_Response* ewk_url_response_ref(Ewk_Url_Response* response)
61 {
62     EINA_SAFETY_ON_NULL_RETURN_VAL(response, 0);
63     response->ref();
64
65     return response;
66 }
67
68 void ewk_url_response_unref(Ewk_Url_Response* response)
69 {
70     EINA_SAFETY_ON_NULL_RETURN(response);
71
72     response->deref();
73 }
74
75 const char* ewk_url_response_url_get(const Ewk_Url_Response* response)
76 {
77     EINA_SAFETY_ON_NULL_RETURN_VAL(response, 0);
78
79     return response->url();
80 }
81
82 int ewk_url_response_status_code_get(const Ewk_Url_Response* response)
83 {
84     EINA_SAFETY_ON_NULL_RETURN_VAL(response, 0);
85
86     return response->httpStatusCode();
87 }
88
89 const char* ewk_url_response_mime_type_get(const Ewk_Url_Response* response)
90 {
91     EINA_SAFETY_ON_NULL_RETURN_VAL(response, 0);
92
93     return response->mimeType();
94 }
95
96 unsigned long ewk_url_response_content_length_get(const Ewk_Url_Response* response)
97 {
98     EINA_SAFETY_ON_NULL_RETURN_VAL(response, 0);
99
100     return response->contentLength();
101 }