OLD | NEW |
1 /* | 1 /* |
2 Copyright (C) 1998 Lars Knoll (knoll@mpi-hd.mpg.de) | 2 Copyright (C) 1998 Lars Knoll (knoll@mpi-hd.mpg.de) |
3 Copyright (C) 2001 Dirk Mueller (mueller@kde.org) | 3 Copyright (C) 2001 Dirk Mueller (mueller@kde.org) |
4 Copyright (C) 2002 Waldo Bastian (bastian@kde.org) | 4 Copyright (C) 2002 Waldo Bastian (bastian@kde.org) |
5 Copyright (C) 2006 Samuel Weinig (sam.weinig@gmail.com) | 5 Copyright (C) 2006 Samuel Weinig (sam.weinig@gmail.com) |
6 Copyright (C) 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011 Apple Inc. All
rights reserved. | 6 Copyright (C) 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011 Apple Inc. All
rights reserved. |
7 | 7 |
8 This library is free software; you can redistribute it and/or | 8 This library is free software; you can redistribute it and/or |
9 modify it under the terms of the GNU Library General Public | 9 modify it under the terms of the GNU Library General Public |
10 License as published by the Free Software Foundation; either | 10 License as published by the Free Software Foundation; either |
(...skipping 163 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
174 | 174 |
175 // FIXME: It's unfortunate that the cache layer and below get to know anythi
ng about fragment identifiers. | 175 // FIXME: It's unfortunate that the cache layer and below get to know anythi
ng about fragment identifiers. |
176 // We should look into removing the expectation of that knowledge from the p
latform network stacks. | 176 // We should look into removing the expectation of that knowledge from the p
latform network stacks. |
177 ResourceRequest request(m_resourceRequest); | 177 ResourceRequest request(m_resourceRequest); |
178 if (!m_fragmentIdentifierForRequest.isNull()) { | 178 if (!m_fragmentIdentifierForRequest.isNull()) { |
179 KURL url = request.url(); | 179 KURL url = request.url(); |
180 url.setFragmentIdentifier(m_fragmentIdentifierForRequest); | 180 url.setFragmentIdentifier(m_fragmentIdentifierForRequest); |
181 request.setURL(url); | 181 request.setURL(url); |
182 m_fragmentIdentifierForRequest = String(); | 182 m_fragmentIdentifierForRequest = String(); |
183 } | 183 } |
184 | 184 m_status = Pending; |
185 m_loader = ResourceLoader::create(fetcher, this, request, options); | 185 m_loader = ResourceLoader::create(fetcher, this, request, options); |
186 if (!m_loader) { | 186 m_loader->start(); |
187 failBeforeStarting(); | |
188 return; | |
189 } | |
190 m_status = Pending; | |
191 } | 187 } |
192 | 188 |
193 void Resource::checkNotify() | 189 void Resource::checkNotify() |
194 { | 190 { |
195 if (isLoading()) | 191 if (isLoading()) |
196 return; | 192 return; |
197 | 193 |
198 ResourceClientWalker<ResourceClient> w(m_clients); | 194 ResourceClientWalker<ResourceClient> w(m_clients); |
199 while (ResourceClient* c = w.next()) | 195 while (ResourceClient* c = w.next()) |
200 c->notifyFinished(this); | 196 c->notifyFinished(this); |
201 } | 197 } |
202 | 198 |
203 void Resource::appendData(const char* data, int length) | 199 void Resource::appendData(const char* data, int length) |
204 { | 200 { |
205 ASSERT(!m_resourceToRevalidate); | 201 ASSERT(!m_resourceToRevalidate); |
206 ASSERT(!errorOccurred()); | 202 ASSERT(!errorOccurred()); |
207 if (m_options.dataBufferingPolicy == DoNotBufferData) | 203 if (m_options.dataBufferingPolicy == DoNotBufferData) |
208 return; | 204 return; |
209 if (m_data) | 205 if (m_data) |
210 m_data->append(data, length); | 206 m_data->append(data, length); |
211 else | 207 else |
212 m_data = SharedBuffer::create(data, length); | 208 m_data = SharedBuffer::create(data, length); |
213 setEncodedSize(m_data->size()); | 209 setEncodedSize(m_data->size()); |
214 } | 210 } |
215 | 211 |
| 212 void Resource::setResourceBuffer(PassRefPtr<SharedBuffer> resourceBuffer) |
| 213 { |
| 214 ASSERT(!m_resourceToRevalidate); |
| 215 ASSERT(!errorOccurred()); |
| 216 ASSERT(m_options.dataBufferingPolicy == BufferData); |
| 217 m_data = resourceBuffer; |
| 218 setEncodedSize(m_data->size()); |
| 219 } |
| 220 |
216 void Resource::error(Resource::Status status) | 221 void Resource::error(Resource::Status status) |
217 { | 222 { |
218 if (m_resourceToRevalidate) | 223 if (m_resourceToRevalidate) |
219 revalidationFailed(); | 224 revalidationFailed(); |
220 | 225 |
221 if (!m_error.isNull() && (m_error.isCancellation() || !isPreloaded())) | 226 if (!m_error.isNull() && (m_error.isCancellation() || !isPreloaded())) |
222 memoryCache()->remove(this); | 227 memoryCache()->remove(this); |
223 | 228 |
224 setStatus(status); | 229 setStatus(status); |
225 ASSERT(errorOccurred()); | 230 ASSERT(errorOccurred()); |
(...skipping 646 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
872 Vector<ResourcePtr<Resource> > resources; | 877 Vector<ResourcePtr<Resource> > resources; |
873 for (HashSet<Resource*>::iterator it = m_resourcesWithPendingClients.begin()
; it != end; ++it) | 878 for (HashSet<Resource*>::iterator it = m_resourcesWithPendingClients.begin()
; it != end; ++it) |
874 resources.append(*it); | 879 resources.append(*it); |
875 m_resourcesWithPendingClients.clear(); | 880 m_resourcesWithPendingClients.clear(); |
876 for (size_t i = 0; i < resources.size(); i++) | 881 for (size_t i = 0; i < resources.size(); i++) |
877 resources[i]->finishPendingClients(); | 882 resources[i]->finishPendingClients(); |
878 } | 883 } |
879 | 884 |
880 } | 885 } |
881 | 886 |
OLD | NEW |