OLD | NEW |
1 /* | 1 /* |
2 * Copyright (C) 2009 Google Inc. All rights reserved. | 2 * Copyright (C) 2009 Google Inc. All rights reserved. |
3 * | 3 * |
4 * Redistribution and use in source and binary forms, with or without | 4 * Redistribution and use in source and binary forms, with or without |
5 * modification, are permitted provided that the following conditions are | 5 * modification, are permitted provided that the following conditions are |
6 * met: | 6 * met: |
7 * | 7 * |
8 * * Redistributions of source code must retain the above copyright | 8 * * Redistributions of source code must retain the above copyright |
9 * notice, this list of conditions and the following disclaimer. | 9 * notice, this list of conditions and the following disclaimer. |
10 * * Redistributions in binary form must reproduce the above | 10 * * Redistributions in binary form must reproduce the above |
(...skipping 100 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
111 template<> struct CrossThreadCopierBase<false, false, false, ThreadableLoaderOpt
ions> { | 111 template<> struct CrossThreadCopierBase<false, false, false, ThreadableLoaderOpt
ions> { |
112 typedef CrossThreadThreadableLoaderOptionsData Type; | 112 typedef CrossThreadThreadableLoaderOptionsData Type; |
113 static Type copy(const ThreadableLoaderOptions& options) | 113 static Type copy(const ThreadableLoaderOptions& options) |
114 { | 114 { |
115 return CrossThreadThreadableLoaderOptionsData(options); | 115 return CrossThreadThreadableLoaderOptionsData(options); |
116 } | 116 } |
117 }; | 117 }; |
118 | 118 |
119 // Useful for doing loader operations from any thread (not threadsafe, | 119 // Useful for doing loader operations from any thread (not threadsafe, |
120 // just able to run on threads other than the main thread). | 120 // just able to run on threads other than the main thread). |
| 121 // |
| 122 // Arguments common to both loadResourceSynchronously() and create(): |
| 123 // |
| 124 // - ThreadableLoaderOptions argument configures this ThreadableLoader's |
| 125 // behavior. |
| 126 // |
| 127 // - ResourceLoaderOptions argument will be passed to the FetchRequest |
| 128 // that this ThreadableLoader creates. It can be altered e.g. when |
| 129 // redirect happens. |
121 class CORE_EXPORT ThreadableLoader : public RefCounted<ThreadableLoader> { | 130 class CORE_EXPORT ThreadableLoader : public RefCounted<ThreadableLoader> { |
122 WTF_MAKE_NONCOPYABLE(ThreadableLoader); | 131 WTF_MAKE_NONCOPYABLE(ThreadableLoader); |
123 public: | 132 public: |
124 // ThreadableLoaderOptions argument configures this ThreadableLoader's | 133 // ThreadableLoaderClient methods may not destroy the ThreadableLoader |
125 // behavior. | 134 // instance in them. |
| 135 static void loadResourceSynchronously(ExecutionContext&, const ResourceReque
st&, ThreadableLoaderClient&, const ThreadableLoaderOptions&, const ResourceLoad
erOptions&); |
| 136 // Loading completes when one of the following methods are called: |
| 137 // - didFinishLoading() |
| 138 // - didFail() |
| 139 // - didFailAccessControlCheck() |
| 140 // - didFailRedirectCheck() |
| 141 // After any of these methods is called, no ThreadableLoaderClient method |
| 142 // will be called. |
126 // | 143 // |
127 // ResourceLoaderOptions argument will be passed to the FetchRequest | 144 // When ThreadableLoader is destructed, ThreadableLoaderClient methods are |
128 // that this ThreadableLoader creates. It can be altered e.g. when | 145 // NOT called in response to the destruction synchronously or after |
129 // redirect happens. | 146 // destruction. |
130 static void loadResourceSynchronously(ExecutionContext&, const ResourceReque
st&, ThreadableLoaderClient&, const ThreadableLoaderOptions&, const ResourceLoad
erOptions&); | 147 // |
| 148 // When ThreadableLoader::cancel() is called, |
| 149 // ThreadableLoaderClient::didFail() is called with ResourceError with |
| 150 // isCancellation() returning true, if any of didFinishLoading() or |
| 151 // didFail.*() methods have not been called yet. (didFail() may be called |
| 152 // with a ResourceError with isCancellation() returning true also for |
| 153 // cancellation happened inside the loader.) |
| 154 // |
| 155 // ThreadableLoaderClient methods: |
| 156 // - may call cancel() |
| 157 // - can destroy the ThreadableLoader instance in them (by clearing |
| 158 // RefPtr<ThreadableLoader>). |
131 static PassRefPtr<ThreadableLoader> create(ExecutionContext&, ThreadableLoad
erClient*, const ResourceRequest&, const ThreadableLoaderOptions&, const Resourc
eLoaderOptions&); | 159 static PassRefPtr<ThreadableLoader> create(ExecutionContext&, ThreadableLoad
erClient*, const ResourceRequest&, const ThreadableLoaderOptions&, const Resourc
eLoaderOptions&); |
132 | 160 |
133 // A ThreadableLoader may have a timeout specified. It is possible, in some
cases, for | 161 // A ThreadableLoader may have a timeout specified. It is possible, in some
cases, for |
134 // the timeout to be overridden after the request is sent (for example, XMLH
ttpRequests | 162 // the timeout to be overridden after the request is sent (for example, XMLH
ttpRequests |
135 // may override their timeout setting after sending). | 163 // may override their timeout setting after sending). |
136 // | 164 // |
137 // Set a new timeout relative to the time the request started, in millisecon
ds. | 165 // Set a new timeout relative to the time the request started, in millisecon
ds. |
138 virtual void overrideTimeout(unsigned long timeoutMilliseconds) = 0; | 166 virtual void overrideTimeout(unsigned long timeoutMilliseconds) = 0; |
139 | 167 |
140 virtual void cancel() = 0; | 168 virtual void cancel() = 0; |
141 | 169 |
142 virtual ~ThreadableLoader() { } | 170 virtual ~ThreadableLoader() { } |
143 | 171 |
144 protected: | 172 protected: |
145 ThreadableLoader() { } | 173 ThreadableLoader() { } |
146 }; | 174 }; |
147 | 175 |
148 } // namespace blink | 176 } // namespace blink |
149 | 177 |
150 #endif // ThreadableLoader_h | 178 #endif // ThreadableLoader_h |
OLD | NEW |