~ubuntu-branches/ubuntu/raring/qtwebkit-source/raring-proposed

« back to all changes in this revision

Viewing changes to Source/WebCore/loader/ResourceLoader.cpp

  • Committer: Package Import Robot
  • Author(s): Jonathan Riddell
  • Date: 2013-02-18 14:24:18 UTC
  • Revision ID: package-import@ubuntu.com-20130218142418-eon0jmjg3nj438uy
Tags: upstream-2.3
ImportĀ upstreamĀ versionĀ 2.3

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/*
 
2
 * Copyright (C) 2006, 2007, 2010, 2011 Apple Inc. All rights reserved.
 
3
 *           (C) 2007 Graham Dennis (graham.dennis@gmail.com)
 
4
 *
 
5
 * Redistribution and use in source and binary forms, with or without
 
6
 * modification, are permitted provided that the following conditions
 
7
 * are met:
 
8
 *
 
9
 * 1.  Redistributions of source code must retain the above copyright
 
10
 *     notice, this list of conditions and the following disclaimer. 
 
11
 * 2.  Redistributions in binary form must reproduce the above copyright
 
12
 *     notice, this list of conditions and the following disclaimer in the
 
13
 *     documentation and/or other materials provided with the distribution. 
 
14
 * 3.  Neither the name of Apple Computer, Inc. ("Apple") nor the names of
 
15
 *     its contributors may be used to endorse or promote products derived
 
16
 *     from this software without specific prior written permission. 
 
17
 *
 
18
 * THIS SOFTWARE IS PROVIDED BY APPLE AND ITS CONTRIBUTORS "AS IS" AND ANY
 
19
 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
 
20
 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
 
21
 * DISCLAIMED. IN NO EVENT SHALL APPLE OR ITS CONTRIBUTORS BE LIABLE FOR ANY
 
22
 * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
 
23
 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
 
24
 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
 
25
 * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
 
26
 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
 
27
 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
 
28
 */
 
29
 
 
30
#include "config.h"
 
31
#include "ResourceLoader.h"
 
32
 
 
33
#include "ApplicationCacheHost.h"
 
34
#include "AsyncFileStream.h"
 
35
#include "DocumentLoader.h"
 
36
#include "Frame.h"
 
37
#include "FrameLoader.h"
 
38
#include "FrameLoaderClient.h"
 
39
#include "InspectorInstrumentation.h"
 
40
#include "LoaderStrategy.h"
 
41
#include "Page.h"
 
42
#include "PlatformStrategies.h"
 
43
#include "ProgressTracker.h"
 
44
#include "ResourceBuffer.h"
 
45
#include "ResourceError.h"
 
46
#include "ResourceHandle.h"
 
47
#include "ResourceLoadScheduler.h"
 
48
#include "SecurityOrigin.h"
 
49
#include "Settings.h"
 
50
#include "SharedBuffer.h"
 
51
 
 
52
namespace WebCore {
 
53
 
 
54
PassRefPtr<ResourceBuffer> ResourceLoader::resourceData()
 
55
{
 
56
    return m_resourceData;
 
57
}
 
58
 
 
59
ResourceLoader::ResourceLoader(Frame* frame, ResourceLoaderOptions options)
 
60
    : m_frame(frame)
 
61
    , m_documentLoader(frame->loader()->activeDocumentLoader())
 
62
    , m_identifier(0)
 
63
    , m_reachedTerminalState(false)
 
64
    , m_calledWillCancel(false)
 
65
    , m_cancelled(false)
 
66
    , m_notifiedLoadComplete(false)
 
67
    , m_defersLoading(frame->page()->defersLoading())
 
68
    , m_options(options)
 
69
{
 
70
}
 
71
 
 
72
ResourceLoader::~ResourceLoader()
 
73
{
 
74
    ASSERT(m_reachedTerminalState);
 
75
}
 
76
 
 
77
void ResourceLoader::releaseResources()
 
78
{
 
79
    ASSERT(!m_reachedTerminalState);
 
80
    
 
81
    // It's possible that when we release the handle, it will be
 
82
    // deallocated and release the last reference to this object.
 
83
    // We need to retain to avoid accessing the object after it
 
84
    // has been deallocated and also to avoid reentering this method.
 
85
    RefPtr<ResourceLoader> protector(this);
 
86
 
 
87
    m_frame = 0;
 
88
    m_documentLoader = 0;
 
89
    
 
90
    // We need to set reachedTerminalState to true before we release
 
91
    // the resources to prevent a double dealloc of WebView <rdar://problem/4372628>
 
92
    m_reachedTerminalState = true;
 
93
 
 
94
#if USE(PLATFORM_STRATEGIES)
 
95
    platformStrategies()->loaderStrategy()->resourceLoadScheduler()->remove(this);
 
96
#endif
 
97
    m_identifier = 0;
 
98
#if !USE(PLATFORM_STRATEGIES)
 
99
    resourceLoadScheduler()->remove(this);
 
100
#endif
 
101
 
 
102
    if (m_handle) {
 
103
        // Clear out the ResourceHandle's client so that it doesn't try to call
 
104
        // us back after we release it, unless it has been replaced by someone else.
 
105
        if (m_handle->client() == this)
 
106
            m_handle->setClient(0);
 
107
        m_handle = 0;
 
108
    }
 
109
 
 
110
    m_resourceData = 0;
 
111
    m_deferredRequest = ResourceRequest();
 
112
}
 
113
 
 
114
bool ResourceLoader::init(const ResourceRequest& r)
 
115
{
 
116
    ASSERT(!m_handle);
 
117
    ASSERT(m_request.isNull());
 
118
    ASSERT(m_deferredRequest.isNull());
 
119
    ASSERT(!m_documentLoader->isSubstituteLoadPending(this));
 
120
    
 
121
    ResourceRequest clientRequest(r);
 
122
    
 
123
    m_defersLoading = m_frame->page()->defersLoading();
 
124
    if (m_options.securityCheck == DoSecurityCheck && !m_frame->document()->securityOrigin()->canDisplay(clientRequest.url())) {
 
125
        FrameLoader::reportLocalLoadFailed(m_frame.get(), clientRequest.url().string());
 
126
        releaseResources();
 
127
        return false;
 
128
    }
 
129
    
 
130
    // https://bugs.webkit.org/show_bug.cgi?id=26391
 
131
    // The various plug-in implementations call directly to ResourceLoader::load() instead of piping requests
 
132
    // through FrameLoader. As a result, they miss the FrameLoader::addExtraFieldsToRequest() step which sets
 
133
    // up the 1st party for cookies URL. Until plug-in implementations can be reigned in to pipe through that
 
134
    // method, we need to make sure there is always a 1st party for cookies set.
 
135
    if (clientRequest.firstPartyForCookies().isNull()) {
 
136
        if (Document* document = m_frame->document())
 
137
            clientRequest.setFirstPartyForCookies(document->firstPartyForCookies());
 
138
    }
 
139
 
 
140
    willSendRequest(clientRequest, ResourceResponse());
 
141
    if (clientRequest.isNull()) {
 
142
        cancel();
 
143
        return false;
 
144
    }
 
145
 
 
146
    m_originalRequest = m_request = clientRequest;
 
147
    return true;
 
148
}
 
149
 
 
150
void ResourceLoader::start()
 
151
{
 
152
    ASSERT(!m_handle);
 
153
    ASSERT(!m_request.isNull());
 
154
    ASSERT(m_deferredRequest.isNull());
 
155
 
 
156
#if ENABLE(WEB_ARCHIVE) || ENABLE(MHTML)
 
157
    if (m_documentLoader->scheduleArchiveLoad(this, m_request, m_request.url()))
 
158
        return;
 
159
#endif
 
160
 
 
161
    if (m_documentLoader->applicationCacheHost()->maybeLoadResource(this, m_request, m_request.url()))
 
162
        return;
 
163
 
 
164
    if (m_defersLoading) {
 
165
        m_deferredRequest = m_request;
 
166
        return;
 
167
    }
 
168
 
 
169
    if (!m_reachedTerminalState)
 
170
        m_handle = ResourceHandle::create(m_frame->loader()->networkingContext(), m_request, this, m_defersLoading, m_options.sniffContent == SniffContent);
 
171
}
 
172
 
 
173
void ResourceLoader::setDefersLoading(bool defers)
 
174
{
 
175
    m_defersLoading = defers;
 
176
    if (m_handle)
 
177
        m_handle->setDefersLoading(defers);
 
178
    if (!defers && !m_deferredRequest.isNull()) {
 
179
        m_request = m_deferredRequest;
 
180
        m_deferredRequest = ResourceRequest();
 
181
        start();
 
182
    }
 
183
}
 
184
 
 
185
FrameLoader* ResourceLoader::frameLoader() const
 
186
{
 
187
    if (!m_frame)
 
188
        return 0;
 
189
    return m_frame->loader();
 
190
}
 
191
 
 
192
void ResourceLoader::setShouldBufferData(DataBufferingPolicy shouldBufferData)
 
193
 
194
    m_options.shouldBufferData = shouldBufferData; 
 
195
 
 
196
    // Reset any already buffered data
 
197
    if (!shouldBufferData)
 
198
        m_resourceData = 0;
 
199
}
 
200
    
 
201
 
 
202
void ResourceLoader::addData(const char* data, int length, bool allAtOnce)
 
203
{
 
204
    if (m_options.shouldBufferData == DoNotBufferData)
 
205
        return;
 
206
 
 
207
    if (allAtOnce) {
 
208
        m_resourceData = ResourceBuffer::create(data, length);
 
209
        return;
 
210
    }
 
211
        
 
212
    if (!m_resourceData)
 
213
        m_resourceData = ResourceBuffer::create(data, length);
 
214
    else
 
215
        m_resourceData->append(data, length);
 
216
}
 
217
 
 
218
void ResourceLoader::clearResourceData()
 
219
{
 
220
    if (m_resourceData)
 
221
        m_resourceData->clear();
 
222
}
 
223
 
 
224
bool ResourceLoader::isSubresourceLoader()
 
225
{
 
226
    return false;
 
227
}
 
228
 
 
229
void ResourceLoader::willSendRequest(ResourceRequest& request, const ResourceResponse& redirectResponse)
 
230
{
 
231
    // Protect this in this delegate method since the additional processing can do
 
232
    // anything including possibly derefing this; one example of this is Radar 3266216.
 
233
    RefPtr<ResourceLoader> protector(this);
 
234
 
 
235
    ASSERT(!m_reachedTerminalState);
 
236
 
 
237
    if (m_options.sendLoadCallbacks == SendCallbacks) {
 
238
        if (!m_identifier) {
 
239
            m_identifier = m_frame->page()->progress()->createUniqueIdentifier();
 
240
            frameLoader()->notifier()->assignIdentifierToInitialRequest(m_identifier, documentLoader(), request);
 
241
        }
 
242
 
 
243
        frameLoader()->notifier()->willSendRequest(this, request, redirectResponse);
 
244
    }
 
245
 
 
246
    if (!redirectResponse.isNull()) {
 
247
#if USE(PLATFORM_STRATEGIES)
 
248
        platformStrategies()->loaderStrategy()->resourceLoadScheduler()->crossOriginRedirectReceived(this, request.url());
 
249
#else
 
250
        resourceLoadScheduler()->crossOriginRedirectReceived(this, request.url());
 
251
#endif
 
252
    }
 
253
    m_request = request;
 
254
}
 
255
 
 
256
void ResourceLoader::didSendData(unsigned long long, unsigned long long)
 
257
{
 
258
}
 
259
 
 
260
void ResourceLoader::didReceiveResponse(const ResourceResponse& r)
 
261
{
 
262
    ASSERT(!m_reachedTerminalState);
 
263
 
 
264
    // Protect this in this delegate method since the additional processing can do
 
265
    // anything including possibly derefing this; one example of this is Radar 3266216.
 
266
    RefPtr<ResourceLoader> protector(this);
 
267
 
 
268
    m_response = r;
 
269
 
 
270
    if (FormData* data = m_request.httpBody())
 
271
        data->removeGeneratedFilesIfNeeded();
 
272
        
 
273
    if (m_options.sendLoadCallbacks == SendCallbacks)
 
274
        frameLoader()->notifier()->didReceiveResponse(this, m_response);
 
275
}
 
276
 
 
277
void ResourceLoader::didReceiveData(const char* data, int length, long long encodedDataLength, bool allAtOnce)
 
278
{
 
279
    // The following assertions are not quite valid here, since a subclass
 
280
    // might override didReceiveData in a way that invalidates them. This
 
281
    // happens with the steps listed in 3266216
 
282
    // ASSERT(con == connection);
 
283
    // ASSERT(!m_reachedTerminalState);
 
284
 
 
285
    // Protect this in this delegate method since the additional processing can do
 
286
    // anything including possibly derefing this; one example of this is Radar 3266216.
 
287
    RefPtr<ResourceLoader> protector(this);
 
288
 
 
289
    addData(data, length, allAtOnce);
 
290
    // FIXME: If we get a resource with more than 2B bytes, this code won't do the right thing.
 
291
    // However, with today's computers and networking speeds, this won't happen in practice.
 
292
    // Could be an issue with a giant local file.
 
293
    if (m_options.sendLoadCallbacks == SendCallbacks && m_frame)
 
294
        frameLoader()->notifier()->didReceiveData(this, data, length, static_cast<int>(encodedDataLength));
 
295
}
 
296
 
 
297
void ResourceLoader::willStopBufferingData(const char* data, int length)
 
298
{
 
299
    if (m_options.shouldBufferData == DoNotBufferData)
 
300
        return;
 
301
 
 
302
    ASSERT(!m_resourceData);
 
303
    m_resourceData = ResourceBuffer::create(data, length);
 
304
}
 
305
 
 
306
void ResourceLoader::didFinishLoading(double finishTime)
 
307
{
 
308
    didFinishLoadingOnePart(finishTime);
 
309
 
 
310
    // If the load has been cancelled by a delegate in response to didFinishLoad(), do not release
 
311
    // the resources a second time, they have been released by cancel.
 
312
    if (m_cancelled)
 
313
        return;
 
314
    releaseResources();
 
315
}
 
316
 
 
317
void ResourceLoader::didFinishLoadingOnePart(double finishTime)
 
318
{
 
319
    // If load has been cancelled after finishing (which could happen with a
 
320
    // JavaScript that changes the window location), do nothing.
 
321
    if (m_cancelled)
 
322
        return;
 
323
    ASSERT(!m_reachedTerminalState);
 
324
 
 
325
    if (m_notifiedLoadComplete)
 
326
        return;
 
327
    m_notifiedLoadComplete = true;
 
328
    if (m_options.sendLoadCallbacks == SendCallbacks)
 
329
        frameLoader()->notifier()->didFinishLoad(this, finishTime);
 
330
}
 
331
 
 
332
void ResourceLoader::didFail(const ResourceError& error)
 
333
{
 
334
    if (m_cancelled)
 
335
        return;
 
336
    ASSERT(!m_reachedTerminalState);
 
337
 
 
338
    // Protect this in this delegate method since the additional processing can do
 
339
    // anything including possibly derefing this; one example of this is Radar 3266216.
 
340
    RefPtr<ResourceLoader> protector(this);
 
341
 
 
342
    if (FormData* data = m_request.httpBody())
 
343
        data->removeGeneratedFilesIfNeeded();
 
344
 
 
345
    if (!m_notifiedLoadComplete) {
 
346
        m_notifiedLoadComplete = true;
 
347
        if (m_options.sendLoadCallbacks == SendCallbacks)
 
348
            frameLoader()->notifier()->didFailToLoad(this, error);
 
349
    }
 
350
 
 
351
    releaseResources();
 
352
}
 
353
 
 
354
void ResourceLoader::cancel()
 
355
{
 
356
    cancel(ResourceError());
 
357
}
 
358
 
 
359
void ResourceLoader::cancel(const ResourceError& error)
 
360
{
 
361
    // If the load has already completed - succeeded, failed, or previously cancelled - do nothing.
 
362
    if (m_reachedTerminalState)
 
363
        return;
 
364
       
 
365
    ResourceError nonNullError = error.isNull() ? cancelledError() : error;
 
366
    
 
367
    // willCancel() and didFailToLoad() both call out to clients that might do 
 
368
    // something causing the last reference to this object to go away.
 
369
    RefPtr<ResourceLoader> protector(this);
 
370
    
 
371
    // If we re-enter cancel() from inside willCancel(), we want to pick up from where we left 
 
372
    // off without re-running willCancel()
 
373
    if (!m_calledWillCancel) {
 
374
        m_calledWillCancel = true;
 
375
        
 
376
        willCancel(nonNullError);
 
377
    }
 
378
 
 
379
    // If we re-enter cancel() from inside didFailToLoad(), we want to pick up from where we 
 
380
    // left off without redoing any of this work.
 
381
    if (!m_cancelled) {
 
382
        m_cancelled = true;
 
383
        
 
384
        if (FormData* data = m_request.httpBody())
 
385
            data->removeGeneratedFilesIfNeeded();
 
386
 
 
387
        if (m_handle)
 
388
            m_handle->clearAuthentication();
 
389
 
 
390
        m_documentLoader->cancelPendingSubstituteLoad(this);
 
391
        if (m_handle) {
 
392
            m_handle->cancel();
 
393
            m_handle = 0;
 
394
        }
 
395
 
 
396
        if (m_options.sendLoadCallbacks == SendCallbacks && m_identifier && !m_notifiedLoadComplete)
 
397
            frameLoader()->notifier()->didFailToLoad(this, nonNullError);
 
398
    }
 
399
 
 
400
    // If cancel() completed from within the call to willCancel() or didFailToLoad(),
 
401
    // we don't want to redo didCancel() or releasesResources().
 
402
    if (m_reachedTerminalState)
 
403
        return;
 
404
 
 
405
    didCancel(nonNullError);
 
406
            
 
407
    releaseResources();
 
408
}
 
409
 
 
410
ResourceError ResourceLoader::cancelledError()
 
411
{
 
412
    return frameLoader()->cancelledError(m_request);
 
413
}
 
414
 
 
415
ResourceError ResourceLoader::blockedError()
 
416
{
 
417
    return frameLoader()->client()->blockedError(m_request);
 
418
}
 
419
 
 
420
ResourceError ResourceLoader::cannotShowURLError()
 
421
{
 
422
    return frameLoader()->client()->cannotShowURLError(m_request);
 
423
}
 
424
 
 
425
void ResourceLoader::willSendRequest(ResourceHandle*, ResourceRequest& request, const ResourceResponse& redirectResponse)
 
426
{
 
427
    if (documentLoader()->applicationCacheHost()->maybeLoadFallbackForRedirect(this, request, redirectResponse))
 
428
        return;
 
429
    willSendRequest(request, redirectResponse);
 
430
}
 
431
 
 
432
void ResourceLoader::didSendData(ResourceHandle*, unsigned long long bytesSent, unsigned long long totalBytesToBeSent)
 
433
{
 
434
    didSendData(bytesSent, totalBytesToBeSent);
 
435
}
 
436
 
 
437
void ResourceLoader::didReceiveResponse(ResourceHandle*, const ResourceResponse& response)
 
438
{
 
439
    if (documentLoader()->applicationCacheHost()->maybeLoadFallbackForResponse(this, response))
 
440
        return;
 
441
    didReceiveResponse(response);
 
442
}
 
443
 
 
444
void ResourceLoader::didReceiveData(ResourceHandle*, const char* data, int length, int encodedDataLength)
 
445
{
 
446
    InspectorInstrumentationCookie cookie = InspectorInstrumentation::willReceiveResourceData(m_frame.get(), identifier(), encodedDataLength);
 
447
    didReceiveData(data, length, encodedDataLength, false);
 
448
    InspectorInstrumentation::didReceiveResourceData(cookie);
 
449
}
 
450
 
 
451
void ResourceLoader::didFinishLoading(ResourceHandle*, double finishTime)
 
452
{
 
453
    didFinishLoading(finishTime);
 
454
}
 
455
 
 
456
void ResourceLoader::didFail(ResourceHandle*, const ResourceError& error)
 
457
{
 
458
    if (documentLoader()->applicationCacheHost()->maybeLoadFallbackForError(this, error))
 
459
        return;
 
460
    didFail(error);
 
461
}
 
462
 
 
463
void ResourceLoader::wasBlocked(ResourceHandle*)
 
464
{
 
465
    didFail(blockedError());
 
466
}
 
467
 
 
468
void ResourceLoader::cannotShowURL(ResourceHandle*)
 
469
{
 
470
    didFail(cannotShowURLError());
 
471
}
 
472
 
 
473
bool ResourceLoader::shouldUseCredentialStorage()
 
474
{
 
475
    if (m_options.allowCredentials == DoNotAllowStoredCredentials)
 
476
        return false;
 
477
    
 
478
    RefPtr<ResourceLoader> protector(this);
 
479
    return frameLoader()->client()->shouldUseCredentialStorage(documentLoader(), identifier());
 
480
}
 
481
 
 
482
void ResourceLoader::didReceiveAuthenticationChallenge(const AuthenticationChallenge& challenge)
 
483
{
 
484
    ASSERT(!handle() || handle()->hasAuthenticationChallenge());
 
485
 
 
486
    // Protect this in this delegate method since the additional processing can do
 
487
    // anything including possibly derefing this; one example of this is Radar 3266216.
 
488
    RefPtr<ResourceLoader> protector(this);
 
489
 
 
490
    if (m_options.allowCredentials == AllowStoredCredentials) {
 
491
        if (m_options.crossOriginCredentialPolicy == AskClientForCrossOriginCredentials || m_frame->document()->securityOrigin()->canRequest(originalRequest().url())) {
 
492
            frameLoader()->notifier()->didReceiveAuthenticationChallenge(this, challenge);
 
493
            return;
 
494
        }
 
495
    }
 
496
    // Only these platforms provide a way to continue without credentials.
 
497
    // If we can't continue with credentials, we need to cancel the load altogether.
 
498
#if PLATFORM(MAC) || USE(CFNETWORK) || USE(CURL) || PLATFORM(GTK) || PLATFORM(EFL)
 
499
    handle()->receivedRequestToContinueWithoutCredential(challenge);
 
500
    ASSERT(!handle()->hasAuthenticationChallenge());
 
501
#else
 
502
    didFail(blockedError());
 
503
#endif
 
504
}
 
505
 
 
506
void ResourceLoader::didCancelAuthenticationChallenge(const AuthenticationChallenge& challenge)
 
507
{
 
508
    // Protect this in this delegate method since the additional processing can do
 
509
    // anything including possibly derefing this; one example of this is Radar 3266216.
 
510
    RefPtr<ResourceLoader> protector(this);
 
511
    frameLoader()->notifier()->didCancelAuthenticationChallenge(this, challenge);
 
512
}
 
513
 
 
514
#if USE(PROTECTION_SPACE_AUTH_CALLBACK)
 
515
bool ResourceLoader::canAuthenticateAgainstProtectionSpace(const ProtectionSpace& protectionSpace)
 
516
{
 
517
    RefPtr<ResourceLoader> protector(this);
 
518
    return frameLoader()->client()->canAuthenticateAgainstProtectionSpace(documentLoader(), identifier(), protectionSpace);
 
519
}
 
520
#endif
 
521
 
 
522
void ResourceLoader::receivedCancellation(const AuthenticationChallenge&)
 
523
{
 
524
    cancel();
 
525
}
 
526
 
 
527
void ResourceLoader::willCacheResponse(ResourceHandle*, CacheStoragePolicy& policy)
 
528
{
 
529
    // <rdar://problem/7249553> - There are reports of crashes with this method being called
 
530
    // with a null m_frame->settings(), which can only happen if the frame doesn't have a page.
 
531
    // Sadly we have no reproducible cases of this.
 
532
    // We think that any frame without a page shouldn't have any loads happening in it, yet
 
533
    // there is at least one code path where that is not true.
 
534
    ASSERT(m_frame->settings());
 
535
    
 
536
    // When in private browsing mode, prevent caching to disk
 
537
    if (policy == StorageAllowed && m_frame->settings() && m_frame->settings()->privateBrowsingEnabled())
 
538
        policy = StorageAllowedInMemoryOnly;    
 
539
}
 
540
 
 
541
#if ENABLE(BLOB)
 
542
AsyncFileStream* ResourceLoader::createAsyncFileStream(FileStreamClient* client)
 
543
{
 
544
    // It is OK to simply return a pointer since AsyncFileStream::create adds an extra ref.
 
545
    return AsyncFileStream::create(m_frame->document()->scriptExecutionContext(), client).get();
 
546
}
 
547
#endif
 
548
 
 
549
void ResourceLoader::reportMemoryUsage(MemoryObjectInfo* memoryObjectInfo) const
 
550
{
 
551
    MemoryClassInfo info(memoryObjectInfo, this, WebCoreMemoryTypes::Loader);
 
552
    info.addMember(m_handle.get());
 
553
    info.addMember(m_frame);
 
554
    info.addMember(m_documentLoader);
 
555
    info.addMember(m_request);
 
556
    info.addMember(m_originalRequest);
 
557
    info.addMember(m_resourceData);
 
558
    info.addMember(m_deferredRequest);
 
559
    info.addMember(m_options);
 
560
}
 
561
 
 
562
#if PLATFORM(MAC)
 
563
void ResourceLoader::setIdentifier(unsigned long identifier)
 
564
{
 
565
    // FIXME (NetworkProcess): This is temporary to allow WebKit to directly set the identifier on a ResourceLoader.
 
566
    // More permanently we'll want the identifier to be piped through ResourceLoader::init/start so
 
567
    // it always has it, especially in willSendRequest.
 
568
    m_identifier = identifier;
 
569
}
 
570
#endif
 
571
 
 
572
}