OLD | NEW |
1 /* | 1 /* |
2 * Copyright (C) 2009, 2012 Google Inc. All rights reserved. | 2 * Copyright (C) 2009, 2012 Google Inc. All rights reserved. |
3 * Copyright (C) 2013, Intel Corporation | 3 * Copyright (C) 2013, Intel Corporation |
4 * | 4 * |
5 * Redistribution and use in source and binary forms, with or without | 5 * Redistribution and use in source and binary forms, with or without |
6 * modification, are permitted provided that the following conditions are | 6 * modification, are permitted provided that the following conditions are |
7 * met: | 7 * met: |
8 * | 8 * |
9 * * Redistributions of source code must retain the above copyright | 9 * * Redistributions of source code must retain the above copyright |
10 * notice, this list of conditions and the following disclaimer. | 10 * notice, this list of conditions and the following disclaimer. |
(...skipping 23 matching lines...) Expand all Loading... |
34 | 34 |
35 #include "core/CoreExport.h" | 35 #include "core/CoreExport.h" |
36 #include "core/fetch/RawResource.h" | 36 #include "core/fetch/RawResource.h" |
37 #include "core/fetch/ResourceOwner.h" | 37 #include "core/fetch/ResourceOwner.h" |
38 #include "core/loader/ThreadableLoader.h" | 38 #include "core/loader/ThreadableLoader.h" |
39 #include "platform/Timer.h" | 39 #include "platform/Timer.h" |
40 #include "platform/heap/Handle.h" | 40 #include "platform/heap/Handle.h" |
41 #include "platform/network/HTTPHeaderMap.h" | 41 #include "platform/network/HTTPHeaderMap.h" |
42 #include "platform/network/ResourceError.h" | 42 #include "platform/network/ResourceError.h" |
43 #include "wtf/Forward.h" | 43 #include "wtf/Forward.h" |
| 44 #include "wtf/OwnPtr.h" |
| 45 #include "wtf/PassOwnPtr.h" |
44 #include "wtf/WeakPtr.h" | 46 #include "wtf/WeakPtr.h" |
45 #include "wtf/text/WTFString.h" | 47 #include "wtf/text/WTFString.h" |
46 #include <memory> | |
47 | 48 |
48 namespace blink { | 49 namespace blink { |
49 | 50 |
50 class Document; | 51 class Document; |
51 class KURL; | 52 class KURL; |
52 class ResourceRequest; | 53 class ResourceRequest; |
53 class SecurityOrigin; | 54 class SecurityOrigin; |
54 class ThreadableLoaderClient; | 55 class ThreadableLoaderClient; |
55 | 56 |
56 class CORE_EXPORT DocumentThreadableLoader final : public ThreadableLoader, priv
ate RawResourceClient { | 57 class CORE_EXPORT DocumentThreadableLoader final : public ThreadableLoader, priv
ate RawResourceClient { |
57 USING_FAST_MALLOC(DocumentThreadableLoader); | 58 USING_FAST_MALLOC(DocumentThreadableLoader); |
58 public: | 59 public: |
59 static void loadResourceSynchronously(Document&, const ResourceRequest&,
ThreadableLoaderClient&, const ThreadableLoaderOptions&, const ResourceLoaderOp
tions&); | 60 static void loadResourceSynchronously(Document&, const ResourceRequest&,
ThreadableLoaderClient&, const ThreadableLoaderOptions&, const ResourceLoaderOp
tions&); |
60 static std::unique_ptr<DocumentThreadableLoader> create(Document&, Threa
dableLoaderClient*, const ThreadableLoaderOptions&, const ResourceLoaderOptions&
); | 61 static PassOwnPtr<DocumentThreadableLoader> create(Document&, Threadable
LoaderClient*, const ThreadableLoaderOptions&, const ResourceLoaderOptions&); |
61 ~DocumentThreadableLoader() override; | 62 ~DocumentThreadableLoader() override; |
62 | 63 |
63 void start(const ResourceRequest&) override; | 64 void start(const ResourceRequest&) override; |
64 | 65 |
65 void overrideTimeout(unsigned long timeout) override; | 66 void overrideTimeout(unsigned long timeout) override; |
66 | 67 |
67 // |this| may be dead after calling this method in async mode. | 68 // |this| may be dead after calling this method in async mode. |
68 void cancel() override; | 69 void cancel() override; |
69 void setDefersLoading(bool); | 70 void setDefersLoading(bool); |
70 | 71 |
(...skipping 11 matching lines...) Expand all Loading... |
82 // | 83 // |
83 // |this| may be dead after calling this method. | 84 // |this| may be dead after calling this method. |
84 void notifyFinished(Resource*) override; | 85 void notifyFinished(Resource*) override; |
85 | 86 |
86 String debugName() const override { return "DocumentThreadableLoader"; } | 87 String debugName() const override { return "DocumentThreadableLoader"; } |
87 | 88 |
88 // RawResourceClient | 89 // RawResourceClient |
89 // | 90 // |
90 // |this| may be dead after calling these methods. | 91 // |this| may be dead after calling these methods. |
91 void dataSent(Resource*, unsigned long long bytesSent, unsigned long lon
g totalBytesToBeSent) override; | 92 void dataSent(Resource*, unsigned long long bytesSent, unsigned long lon
g totalBytesToBeSent) override; |
92 void responseReceived(Resource*, const ResourceResponse&, std::unique_pt
r<WebDataConsumerHandle>) override; | 93 void responseReceived(Resource*, const ResourceResponse&, PassOwnPtr<Web
DataConsumerHandle>) override; |
93 void setSerializedCachedMetadata(Resource*, const char*, size_t) overrid
e; | 94 void setSerializedCachedMetadata(Resource*, const char*, size_t) overrid
e; |
94 void dataReceived(Resource*, const char* data, size_t dataLength) overri
de; | 95 void dataReceived(Resource*, const char* data, size_t dataLength) overri
de; |
95 void redirectReceived(Resource*, ResourceRequest&, const ResourceRespons
e&) override; | 96 void redirectReceived(Resource*, ResourceRequest&, const ResourceRespons
e&) override; |
96 void redirectBlocked() override; | 97 void redirectBlocked() override; |
97 void dataDownloaded(Resource*, int) override; | 98 void dataDownloaded(Resource*, int) override; |
98 void didReceiveResourceTiming(Resource*, const ResourceTimingInfo&) over
ride; | 99 void didReceiveResourceTiming(Resource*, const ResourceTimingInfo&) over
ride; |
99 | 100 |
100 // |this| may be dead after calling this method in async mode. | 101 // |this| may be dead after calling this method in async mode. |
101 void cancelWithError(const ResourceError&); | 102 void cancelWithError(const ResourceError&); |
102 | 103 |
103 // Notify Inspector and log to console about resource response. Use | 104 // Notify Inspector and log to console about resource response. Use |
104 // this method if response is not going to be finished normally. | 105 // this method if response is not going to be finished normally. |
105 void reportResponseReceived(unsigned long identifier, const ResourceResp
onse&); | 106 void reportResponseReceived(unsigned long identifier, const ResourceResp
onse&); |
106 | 107 |
107 // Methods containing code to handle resource fetch results which are | 108 // Methods containing code to handle resource fetch results which are |
108 // common to both sync and async mode. | 109 // common to both sync and async mode. |
109 // | 110 // |
110 // |this| may be dead after calling these method in async mode. | 111 // |this| may be dead after calling these method in async mode. |
111 void handleResponse(unsigned long identifier, const ResourceResponse&, s
td::unique_ptr<WebDataConsumerHandle>); | 112 void handleResponse(unsigned long identifier, const ResourceResponse&, P
assOwnPtr<WebDataConsumerHandle>); |
112 void handleReceivedData(const char* data, size_t dataLength); | 113 void handleReceivedData(const char* data, size_t dataLength); |
113 void handleSuccessfulFinish(unsigned long identifier, double finishTime)
; | 114 void handleSuccessfulFinish(unsigned long identifier, double finishTime)
; |
114 | 115 |
115 // |this| may be dead after calling this method. | 116 // |this| may be dead after calling this method. |
116 void didTimeout(Timer<DocumentThreadableLoader>*); | 117 void didTimeout(Timer<DocumentThreadableLoader>*); |
117 // Calls the appropriate loading method according to policy and data | 118 // Calls the appropriate loading method according to policy and data |
118 // about origin. Only for handling the initial load (including fallback | 119 // about origin. Only for handling the initial load (including fallback |
119 // after consulting ServiceWorker). | 120 // after consulting ServiceWorker). |
120 // | 121 // |
121 // |this| may be dead after calling this method in async mode. | 122 // |this| may be dead after calling this method in async mode. |
(...skipping 101 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
223 int m_corsRedirectLimit; | 224 int m_corsRedirectLimit; |
224 | 225 |
225 WebURLRequest::FetchRedirectMode m_redirectMode; | 226 WebURLRequest::FetchRedirectMode m_redirectMode; |
226 | 227 |
227 WeakPtrFactory<DocumentThreadableLoader> m_weakFactory; | 228 WeakPtrFactory<DocumentThreadableLoader> m_weakFactory; |
228 }; | 229 }; |
229 | 230 |
230 } // namespace blink | 231 } // namespace blink |
231 | 232 |
232 #endif // DocumentThreadableLoader_h | 233 #endif // DocumentThreadableLoader_h |
OLD | NEW |