Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1120)

Side by Side Diff: third_party/WebKit/Source/core/loader/ThreadableLoader.h

Issue 1264453002: Split the constructor of ThreadableLoader into two methods (ctor and start()) (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Removed pipes around non-variables in a comment Created 4 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 115 matching lines...) Expand 10 before | Expand all | Expand 10 after
126 // 126 //
127 // - ResourceLoaderOptions argument will be passed to the FetchRequest 127 // - ResourceLoaderOptions argument will be passed to the FetchRequest
128 // that this ThreadableLoader creates. It can be altered e.g. when 128 // that this ThreadableLoader creates. It can be altered e.g. when
129 // redirect happens. 129 // redirect happens.
130 class CORE_EXPORT ThreadableLoader : public RefCounted<ThreadableLoader> { 130 class CORE_EXPORT ThreadableLoader : public RefCounted<ThreadableLoader> {
131 WTF_MAKE_NONCOPYABLE(ThreadableLoader); 131 WTF_MAKE_NONCOPYABLE(ThreadableLoader);
132 public: 132 public:
133 // ThreadableLoaderClient methods may not destroy the ThreadableLoader 133 // ThreadableLoaderClient methods may not destroy the ThreadableLoader
134 // instance in them. 134 // instance in them.
135 static void loadResourceSynchronously(ExecutionContext&, const ResourceReque st&, ThreadableLoaderClient&, const ThreadableLoaderOptions&, const ResourceLoad erOptions&); 135 static void loadResourceSynchronously(ExecutionContext&, const ResourceReque st&, ThreadableLoaderClient&, const ThreadableLoaderOptions&, const ResourceLoad erOptions&);
136
137 // This method never returns nullptr.
138 //
139 // This method must always be followed by start() call.
140 // ThreadableLoaderClient methods are never called before start() call.
141 //
142 // The async loading feature is separated into the create() method and
143 // and the start() method in order to:
144 // - reduce work done in a constructor
145 // - not to ask the users to handle failures in the constructor and other
146 // async failures separately
147 //
136 // Loading completes when one of the following methods are called: 148 // Loading completes when one of the following methods are called:
137 // - didFinishLoading() 149 // - didFinishLoading()
138 // - didFail() 150 // - didFail()
139 // - didFailAccessControlCheck() 151 // - didFailAccessControlCheck()
140 // - didFailRedirectCheck() 152 // - didFailRedirectCheck()
141 // After any of these methods is called, no ThreadableLoaderClient method 153 // After any of these methods is called, the loader won't call any of the
142 // will be called. 154 // ThreadableLoaderClient methods.
143 // 155 //
144 // When ThreadableLoader is destructed, ThreadableLoaderClient methods are 156 // When a ThreadableLoader is destructed, any of the
145 // NOT called in response to the destruction synchronously or after 157 // ThreadableLoaderClient methods is NOT called in response to the
146 // destruction. 158 // destruction either synchronously or after destruction.
147 // 159 //
148 // When ThreadableLoader::cancel() is called, 160 // When ThreadableLoader::cancel() is called,
149 // ThreadableLoaderClient::didFail() is called with ResourceError with 161 // ThreadableLoaderClient::didFail() is called with a ResourceError
150 // isCancellation() returning true, if any of didFinishLoading() or 162 // with isCancellation() returning true, if any of didFinishLoading()
151 // didFail.*() methods have not been called yet. (didFail() may be called 163 // or didFail.*() methods have not been called yet. (didFail() may be
152 // with a ResourceError with isCancellation() returning true also for 164 // called with a ResourceError with isCancellation() returning true
153 // cancellation happened inside the loader.) 165 // also for cancellation happened inside the loader.)
154 // 166 //
155 // ThreadableLoaderClient methods: 167 // ThreadableLoaderClient methods:
156 // - may call cancel() 168 // - may call cancel()
157 // - can destroy the ThreadableLoader instance in them (by clearing 169 // - can destroy the ThreadableLoader instance in them (by clearing
158 // RefPtr<ThreadableLoader>). 170 // RefPtr<ThreadableLoader>).
159 static PassRefPtr<ThreadableLoader> create(ExecutionContext&, ThreadableLoad erClient*, const ResourceRequest&, const ThreadableLoaderOptions&, const Resourc eLoaderOptions&); 171 static PassRefPtr<ThreadableLoader> create(ExecutionContext&, ThreadableLoad erClient*, const ThreadableLoaderOptions&, const ResourceLoaderOptions&);
172
173 // The methods on the ThreadableLoaderClient passed on create() call
174 // may be called synchronous to start() call.
175 virtual void start(const ResourceRequest&) = 0;
160 176
161 // A ThreadableLoader may have a timeout specified. It is possible, in some cases, for 177 // A ThreadableLoader may have a timeout specified. It is possible, in some cases, for
162 // the timeout to be overridden after the request is sent (for example, XMLH ttpRequests 178 // the timeout to be overridden after the request is sent (for example, XMLH ttpRequests
163 // may override their timeout setting after sending). 179 // may override their timeout setting after sending).
164 // 180 //
165 // Set a new timeout relative to the time the request started, in millisecon ds. 181 // Set a new timeout relative to the time the request started, in millisecon ds.
166 virtual void overrideTimeout(unsigned long timeoutMilliseconds) = 0; 182 virtual void overrideTimeout(unsigned long timeoutMilliseconds) = 0;
167 183
168 virtual void cancel() = 0; 184 virtual void cancel() = 0;
169 185
170 virtual ~ThreadableLoader() { } 186 virtual ~ThreadableLoader() { }
171 187
172 protected: 188 protected:
173 ThreadableLoader() { } 189 ThreadableLoader() { }
174 }; 190 };
175 191
176 } // namespace blink 192 } // namespace blink
177 193
178 #endif // ThreadableLoader_h 194 #endif // ThreadableLoader_h
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698