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

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

Issue 1262593004: Prevent ThreadableLoaderClient methods from being called after failure notification (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Created 5 years, 3 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 100 matching lines...) Expand 10 before | Expand all | Expand 10 after
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 may call cancel() or can destroy the
156 // ThreadableLoader instance in them (by clearing
157 // RefPtr<ThreadableLoader>).
131 static PassRefPtr<ThreadableLoader> create(ExecutionContext&, ThreadableLoad erClient*, const ResourceRequest&, const ThreadableLoaderOptions&, const Resourc eLoaderOptions&); 158 static PassRefPtr<ThreadableLoader> create(ExecutionContext&, ThreadableLoad erClient*, const ResourceRequest&, const ThreadableLoaderOptions&, const Resourc eLoaderOptions&);
132 159
133 // A ThreadableLoader may have a timeout specified. It is possible, in some cases, for 160 // 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 161 // the timeout to be overridden after the request is sent (for example, XMLH ttpRequests
135 // may override their timeout setting after sending). 162 // may override their timeout setting after sending).
136 // 163 //
137 // Set a new timeout relative to the time the request started, in millisecon ds. 164 // Set a new timeout relative to the time the request started, in millisecon ds.
138 virtual void overrideTimeout(unsigned long timeoutMilliseconds) = 0; 165 virtual void overrideTimeout(unsigned long timeoutMilliseconds) = 0;
139 166
140 virtual void cancel() = 0; 167 virtual void cancel() = 0;
141 168
142 virtual ~ThreadableLoader() { } 169 virtual ~ThreadableLoader() { }
143 170
144 protected: 171 protected:
145 ThreadableLoader() { } 172 ThreadableLoader() { }
146 }; 173 };
147 174
148 } // namespace blink 175 } // namespace blink
149 176
150 #endif // ThreadableLoader_h 177 #endif // ThreadableLoader_h
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698