Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(3)

Side by Side Diff: sky/engine/platform/exported/WebHTTPBody.cpp

Issue 1239633002: Remove //sky/engine/platform/network (Closed) Base URL: git@github.com:domokit/mojo.git@master
Patch Set: rebase Created 5 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « sky/engine/platform/BUILD.gn ('k') | sky/engine/platform/exported/WebHTTPLoadInfo.cpp » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
1 /*
2 * Copyright (C) 2009 Google Inc. 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 are
6 * met:
7 *
8 * * Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer.
10 * * Redistributions in binary form must reproduce the above
11 * copyright notice, this list of conditions and the following disclaimer
12 * in the documentation and/or other materials provided with the
13 * distribution.
14 * * Neither the name of Google Inc. nor the names of its
15 * contributors may be used to endorse or promote products derived from
16 * this software without specific prior written permission.
17 *
18 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
19 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
20 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
21 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
22 * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
23 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
24 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
25 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
26 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
27 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
28 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
29 */
30
31 #include "sky/engine/public/platform/WebHTTPBody.h"
32
33 #include "sky/engine/platform/network/FormData.h"
34
35 namespace blink {
36
37 class WebHTTPBodyPrivate : public FormData {
38 };
39
40 void WebHTTPBody::initialize()
41 {
42 assign(static_cast<WebHTTPBodyPrivate*>(FormData::create().leakRef()));
43 }
44
45 void WebHTTPBody::reset()
46 {
47 assign(0);
48 }
49
50 void WebHTTPBody::assign(const WebHTTPBody& other)
51 {
52 WebHTTPBodyPrivate* p = const_cast<WebHTTPBodyPrivate*>(other.m_private);
53 if (p)
54 p->ref();
55 assign(p);
56 }
57
58 size_t WebHTTPBody::elementCount() const
59 {
60 ASSERT(!isNull());
61 return m_private->elements().size();
62 }
63
64 bool WebHTTPBody::elementAt(size_t index, Element& result) const
65 {
66 ASSERT(!isNull());
67
68 if (index >= m_private->elements().size())
69 return false;
70
71 const FormDataElement& element = m_private->elements()[index];
72
73 result.data.reset();
74
75 switch (element.m_type) {
76 case FormDataElement::data:
77 result.type = Element::TypeData;
78 result.data.assign(element.m_data.data(), element.m_data.size());
79 break;
80 default:
81 ASSERT_NOT_REACHED();
82 return false;
83 }
84
85 return true;
86 }
87
88 void WebHTTPBody::appendData(const WebData& data)
89 {
90 ensureMutable();
91 // FIXME: FormDataElement::m_data should be a SharedBuffer<char>. Then we
92 // could avoid this buffer copy.
93 m_private->appendData(data.data(), data.size());
94 }
95
96 long long WebHTTPBody::identifier() const
97 {
98 ASSERT(!isNull());
99 return m_private->identifier();
100 }
101
102 void WebHTTPBody::setIdentifier(long long identifier)
103 {
104 ensureMutable();
105 return m_private->setIdentifier(identifier);
106 }
107
108 bool WebHTTPBody::containsPasswordData() const
109 {
110 return m_private->containsPasswordData();
111 }
112
113 void WebHTTPBody::setContainsPasswordData(bool containsPasswordData)
114 {
115 m_private->setContainsPasswordData(containsPasswordData);
116 }
117
118 WebHTTPBody::WebHTTPBody(const PassRefPtr<FormData>& data)
119 : m_private(static_cast<WebHTTPBodyPrivate*>(data.leakRef()))
120 {
121 }
122
123 WebHTTPBody& WebHTTPBody::operator=(const PassRefPtr<FormData>& data)
124 {
125 assign(static_cast<WebHTTPBodyPrivate*>(data.leakRef()));
126 return *this;
127 }
128
129 WebHTTPBody::operator PassRefPtr<FormData>() const
130 {
131 return m_private;
132 }
133
134 void WebHTTPBody::assign(WebHTTPBodyPrivate* p)
135 {
136 // p is already ref'd for us by the caller
137 if (m_private)
138 m_private->deref();
139 m_private = p;
140 }
141
142 void WebHTTPBody::ensureMutable()
143 {
144 ASSERT(!isNull());
145 if (!m_private->hasOneRef())
146 assign(static_cast<WebHTTPBodyPrivate*>(m_private->copy().leakRef()));
147 }
148
149 } // namespace blink
OLDNEW
« no previous file with comments | « sky/engine/platform/BUILD.gn ('k') | sky/engine/platform/exported/WebHTTPLoadInfo.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698