| 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 113 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 124 // behavior. | 124 // behavior. |
| 125 // | 125 // |
| 126 // - ResourceLoaderOptions argument will be passed to the FetchRequest | 126 // - ResourceLoaderOptions argument will be passed to the FetchRequest |
| 127 // that this ThreadableLoader creates. It can be altered e.g. when | 127 // that this ThreadableLoader creates. It can be altered e.g. when |
| 128 // redirect happens. | 128 // redirect happens. |
| 129 class CORE_EXPORT ThreadableLoader | 129 class CORE_EXPORT ThreadableLoader |
| 130 : public GarbageCollectedFinalized<ThreadableLoader> { | 130 : public GarbageCollectedFinalized<ThreadableLoader> { |
| 131 WTF_MAKE_NONCOPYABLE(ThreadableLoader); | 131 WTF_MAKE_NONCOPYABLE(ThreadableLoader); |
| 132 | 132 |
| 133 public: | 133 public: |
| 134 // ThreadableLoaderClient methods may not destroy the ThreadableLoader | |
| 135 // instance in them. | |
| 136 static void loadResourceSynchronously(ExecutionContext&, | 134 static void loadResourceSynchronously(ExecutionContext&, |
| 137 const ResourceRequest&, | 135 const ResourceRequest&, |
| 138 ThreadableLoaderClient&, | 136 ThreadableLoaderClient&, |
| 139 const ThreadableLoaderOptions&, | 137 const ThreadableLoaderOptions&, |
| 140 const ResourceLoaderOptions&); | 138 const ResourceLoaderOptions&); |
| 141 | 139 |
| 142 // This method never returns nullptr. | 140 // This method never returns nullptr. |
| 143 // | 141 // |
| 144 // This method must always be followed by start() call. | 142 // This method must always be followed by start() call. |
| 145 // ThreadableLoaderClient methods are never called before start() call. | 143 // ThreadableLoaderClient methods are never called before start() call. |
| (...skipping 16 matching lines...) Expand all Loading... |
| 162 // client gets invalid. Also, a user must guarantee that the loading | 160 // client gets invalid. Also, a user must guarantee that the loading |
| 163 // completes before the ThreadableLoader is destructed. | 161 // completes before the ThreadableLoader is destructed. |
| 164 // | 162 // |
| 165 // When ThreadableLoader::cancel() is called, | 163 // When ThreadableLoader::cancel() is called, |
| 166 // ThreadableLoaderClient::didFail() is called with a ResourceError | 164 // ThreadableLoaderClient::didFail() is called with a ResourceError |
| 167 // with isCancellation() returning true, if any of didFinishLoading() | 165 // with isCancellation() returning true, if any of didFinishLoading() |
| 168 // or didFail.*() methods have not been called yet. (didFail() may be | 166 // or didFail.*() methods have not been called yet. (didFail() may be |
| 169 // called with a ResourceError with isCancellation() returning true | 167 // called with a ResourceError with isCancellation() returning true |
| 170 // also for cancellation happened inside the loader.) | 168 // also for cancellation happened inside the loader.) |
| 171 // | 169 // |
| 172 // ThreadableLoaderClient methods: | 170 // ThreadableLoaderClient methods may call cancel(). |
| 173 // - may call cancel() | |
| 174 // - can destroy the ThreadableLoader instance in them (by clearing | |
| 175 // std::unique_ptr<ThreadableLoader>). | |
| 176 static ThreadableLoader* create(ExecutionContext&, | 171 static ThreadableLoader* create(ExecutionContext&, |
| 177 ThreadableLoaderClient*, | 172 ThreadableLoaderClient*, |
| 178 const ThreadableLoaderOptions&, | 173 const ThreadableLoaderOptions&, |
| 179 const ResourceLoaderOptions&); | 174 const ResourceLoaderOptions&); |
| 180 | 175 |
| 181 // The methods on the ThreadableLoaderClient passed on create() call | 176 // The methods on the ThreadableLoaderClient passed on create() call |
| 182 // may be called synchronous to start() call. | 177 // may be called synchronous to start() call. |
| 183 virtual void start(const ResourceRequest&) = 0; | 178 virtual void start(const ResourceRequest&) = 0; |
| 184 | 179 |
| 185 // A ThreadableLoader may have a timeout specified. It is possible, in some | 180 // A ThreadableLoader may have a timeout specified. It is possible, in some |
| (...skipping 10 matching lines...) Expand all Loading... |
| 196 | 191 |
| 197 DEFINE_INLINE_VIRTUAL_TRACE() {} | 192 DEFINE_INLINE_VIRTUAL_TRACE() {} |
| 198 | 193 |
| 199 protected: | 194 protected: |
| 200 ThreadableLoader() {} | 195 ThreadableLoader() {} |
| 201 }; | 196 }; |
| 202 | 197 |
| 203 } // namespace blink | 198 } // namespace blink |
| 204 | 199 |
| 205 #endif // ThreadableLoader_h | 200 #endif // ThreadableLoader_h |
| OLD | NEW |