18e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project/*
28e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project    Copyright (C) 1998 Lars Knoll (knoll@mpi-hd.mpg.de)
38e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project    Copyright (C) 2001 Dirk Mueller <mueller@kde.org>
48e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project    Copyright (C) 2004, 2006, 2007, 2008 Apple Inc. All rights reserved.
58e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project
68e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project    This library is free software; you can redistribute it and/or
78e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project    modify it under the terms of the GNU Library General Public
88e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project    License as published by the Free Software Foundation; either
98e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project    version 2 of the License, or (at your option) any later version.
108e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project
118e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project    This library is distributed in the hope that it will be useful,
128e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project    but WITHOUT ANY WARRANTY; without even the implied warranty of
138e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
148e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project    Library General Public License for more details.
158e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project
168e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project    You should have received a copy of the GNU Library General Public License
178e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project    along with this library; see the file COPYING.LIB.  If not, write to
188e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project    the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
198e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project    Boston, MA 02110-1301, USA.
208e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project*/
218e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project
22f05b935882198ccf7d81675736e3aeb089c5113aBen Murdoch#ifndef CachedResourceRequest_h
23f05b935882198ccf7d81675736e3aeb089c5113aBen Murdoch#define CachedResourceRequest_h
248e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project
25d0825bca7fe65beaee391d30da42e937db621564Steve Block#include "FrameLoaderTypes.h"
266b70adc33054f8aee8c54d0f460458a9df11b8a5Russell Brenner#include "SubresourceLoader.h"
278e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project#include "SubresourceLoaderClient.h"
288e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project#include <wtf/HashMap.h>
298e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project#include <wtf/Noncopyable.h>
306b70adc33054f8aee8c54d0f460458a9df11b8a5Russell Brenner#include <wtf/RefPtr.h>
318e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project
328e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Projectnamespace WebCore {
338e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project
348e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project    class CachedResource;
355abb8606fa57c3ebfc8b3c3dbc3fa4a25d2ae306Iain Merrick    class CachedResourceLoader;
368e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project    class Request;
378e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project
38f05b935882198ccf7d81675736e3aeb089c5113aBen Murdoch    class CachedResourceRequest : public RefCounted<CachedResourceRequest>, private SubresourceLoaderClient {
398e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project    public:
40f05b935882198ccf7d81675736e3aeb089c5113aBen Murdoch        static PassRefPtr<CachedResourceRequest> load(CachedResourceLoader*, CachedResource*, bool incremental, SecurityCheckPolicy, bool sendResourceLoadCallbacks);
41f05b935882198ccf7d81675736e3aeb089c5113aBen Murdoch        ~CachedResourceRequest();
42f05b935882198ccf7d81675736e3aeb089c5113aBen Murdoch        void didFail(bool cancelled = false);
438e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project
44f05b935882198ccf7d81675736e3aeb089c5113aBen Murdoch        CachedResourceLoader* cachedResourceLoader() const { return m_cachedResourceLoader; }
455f1ab04193ad0130ca8204aadaceae083aca9881Feng Qian
468e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project    private:
47f05b935882198ccf7d81675736e3aeb089c5113aBen Murdoch        CachedResourceRequest(CachedResourceLoader*, CachedResource*, bool incremental);
486b70adc33054f8aee8c54d0f460458a9df11b8a5Russell Brenner        virtual void willSendRequest(SubresourceLoader*, ResourceRequest&, const ResourceResponse&);
496b70adc33054f8aee8c54d0f460458a9df11b8a5Russell Brenner        virtual void didReceiveResponse(SubresourceLoader*, const ResourceResponse&);
506b70adc33054f8aee8c54d0f460458a9df11b8a5Russell Brenner        virtual void didReceiveData(SubresourceLoader*, const char*, int);
516b70adc33054f8aee8c54d0f460458a9df11b8a5Russell Brenner        virtual void didReceiveCachedMetadata(SubresourceLoader*, const char*, int);
5281bc750723a18f21cd17d1b173cd2a4dda9cea6eBen Murdoch        virtual void didFinishLoading(SubresourceLoader*, double);
536b70adc33054f8aee8c54d0f460458a9df11b8a5Russell Brenner        virtual void didFail(SubresourceLoader*, const ResourceError&);
54f05b935882198ccf7d81675736e3aeb089c5113aBen Murdoch
55f05b935882198ccf7d81675736e3aeb089c5113aBen Murdoch        RefPtr<SubresourceLoader> m_loader;
56f05b935882198ccf7d81675736e3aeb089c5113aBen Murdoch        CachedResourceLoader* m_cachedResourceLoader;
57f05b935882198ccf7d81675736e3aeb089c5113aBen Murdoch        CachedResource* m_resource;
58f05b935882198ccf7d81675736e3aeb089c5113aBen Murdoch        bool m_incremental;
59f05b935882198ccf7d81675736e3aeb089c5113aBen Murdoch        bool m_multipart;
60f05b935882198ccf7d81675736e3aeb089c5113aBen Murdoch        bool m_finishing;
618e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project    };
628e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project
638e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project}
648e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project
658e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project#endif
66