|
1 /* |
|
2 * Copyright (c) 2006 Nokia Corporation and/or its subsidiary(-ies). |
|
3 * All rights reserved. |
|
4 * This component and the accompanying materials are made available |
|
5 * under the terms of the License "Eclipse Public License v1.0" |
|
6 * which accompanies this distribution, and is available |
|
7 * at the URL "http://www.eclipse.org/legal/epl-v10.html". |
|
8 * |
|
9 * Initial Contributors: |
|
10 * Nokia Corporation - initial contribution. |
|
11 * |
|
12 * Contributors: |
|
13 * |
|
14 * Description: Definition of SynchLoaderClient |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 #ifndef SYNCHLOADERCLIENT_H_ |
|
20 #define SYNCHLOADERCLIENT_H_ |
|
21 |
|
22 #include <e32base.h> |
|
23 |
|
24 #include "Frame.h" |
|
25 #include "ResourceHandle.h" |
|
26 #include "ResourceHandleClient.h" |
|
27 #include "ResourceLoader.h" |
|
28 #include "SubresourceLoaderClient.h" |
|
29 #include <wtf/PassRefPtr.h> |
|
30 |
|
31 namespace WebCore { |
|
32 |
|
33 class SynchResourceHandleClient; |
|
34 |
|
35 class SynchLoader : public ResourceLoader { |
|
36 |
|
37 public: |
|
38 static PassRefPtr<SynchLoader> create(Frame*, const ResourceRequest&, SynchResourceHandleClient*); |
|
39 virtual ~SynchLoader(); |
|
40 |
|
41 virtual bool load(const ResourceRequest&); |
|
42 |
|
43 bool isDone() const { return m_isdone; } |
|
44 |
|
45 virtual void didReceiveResponse(const ResourceResponse&); |
|
46 virtual void didReceiveData(const char*, int, long long lengthReceived, bool allAtOnce); |
|
47 virtual void didFinishLoading(); |
|
48 virtual void didFail(const ResourceError&); |
|
49 virtual void didCancel(const ResourceError&); |
|
50 |
|
51 void removeSubresourceLoader(); |
|
52 |
|
53 private: |
|
54 SynchLoader(Frame*, SynchResourceHandleClient*, bool sendResourceLoadCallbacks, bool shouldContentSniff); |
|
55 |
|
56 private: |
|
57 SynchResourceHandleClient* m_client; |
|
58 bool m_isdone; |
|
59 }; // end class SynchLoader |
|
60 |
|
61 |
|
62 class SynchResourceHandleClient : public Shared<SynchResourceHandleClient>, public ResourceHandleClient { |
|
63 |
|
64 public: |
|
65 static PassRefPtr<SynchResourceHandleClient> create(TRequestStatus&, const ResourceRequest&, Frame*); |
|
66 ~SynchResourceHandleClient(); |
|
67 |
|
68 virtual void didReceiveResponse(ResourceHandle*, const ResourceResponse&); |
|
69 virtual void didReceiveData(ResourceHandle*, const char*, int, int lengthReceived); |
|
70 virtual void didFinishLoading(ResourceHandle*); |
|
71 virtual void didFail(ResourceHandle*, const ResourceError&); |
|
72 |
|
73 void cancel(); |
|
74 void cancel(const ResourceError&); |
|
75 ResourceResponse resourceResponse() const { return m_response; } |
|
76 ResourceError resourceError() const { return m_error; } |
|
77 Vector<char> data() const { return m_data; } |
|
78 ResourceHandle* resourceHandle() const { return m_resourceHandle.get(); } |
|
79 |
|
80 private: |
|
81 SynchResourceHandleClient(TRequestStatus&, const ResourceRequest&, Frame*); |
|
82 |
|
83 RefPtr<SynchLoader> loader() { return m_loader; } |
|
84 |
|
85 void finish(const ResourceError&); |
|
86 |
|
87 private: |
|
88 bool m_finished; |
|
89 ResourceResponse m_response; |
|
90 ResourceError m_error; |
|
91 Vector<char> m_data; |
|
92 RefPtr<SynchLoader> m_loader; |
|
93 RefPtr<ResourceHandle> m_resourceHandle; |
|
94 TRequestStatus* m_status; |
|
95 |
|
96 }; // end class SynchResourceHandleClient |
|
97 |
|
98 } // End namespace WebCore |
|
99 |
|
100 #endif /*SYNCHLOADERCLIENT_H_*/ |