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

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

Issue 1274063003: [Loader] Make ThreadableLoader non-RefCounted and be managed by OwnPtr (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Rebase. Created 4 years, 9 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 18 matching lines...) Expand all
29 */ 29 */
30 30
31 #ifndef ThreadableLoader_h 31 #ifndef ThreadableLoader_h
32 #define ThreadableLoader_h 32 #define ThreadableLoader_h
33 33
34 #include "core/CoreExport.h" 34 #include "core/CoreExport.h"
35 #include "core/fetch/ResourceLoaderOptions.h" 35 #include "core/fetch/ResourceLoaderOptions.h"
36 #include "platform/CrossThreadCopier.h" 36 #include "platform/CrossThreadCopier.h"
37 #include "wtf/Allocator.h" 37 #include "wtf/Allocator.h"
38 #include "wtf/Noncopyable.h" 38 #include "wtf/Noncopyable.h"
39 #include "wtf/PassRefPtr.h" 39 #include "wtf/PassRefPtr.h"
tyoshino (SeeGerritForStatus) 2016/03/03 11:53:38 change to PassOwnPtr
hiroshige 2016/03/08 23:39:25 Done. Also removed RefCounted.h and RefPtr.h.
40 #include "wtf/RefCounted.h" 40 #include "wtf/RefCounted.h"
41 #include "wtf/RefPtr.h" 41 #include "wtf/RefPtr.h"
42 42
43 namespace blink { 43 namespace blink {
44 44
45 class ResourceRequest; 45 class ResourceRequest;
46 class ExecutionContext; 46 class ExecutionContext;
47 class ThreadableLoaderClient; 47 class ThreadableLoaderClient;
48 48
49 enum CrossOriginRequestPolicy { 49 enum CrossOriginRequestPolicy {
(...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after
121 // just able to run on threads other than the main thread). 121 // just able to run on threads other than the main thread).
122 // 122 //
123 // Arguments common to both loadResourceSynchronously() and create(): 123 // Arguments common to both loadResourceSynchronously() and create():
124 // 124 //
125 // - ThreadableLoaderOptions argument configures this ThreadableLoader's 125 // - ThreadableLoaderOptions argument configures this ThreadableLoader's
126 // behavior. 126 // behavior.
127 // 127 //
128 // - ResourceLoaderOptions argument will be passed to the FetchRequest 128 // - ResourceLoaderOptions argument will be passed to the FetchRequest
129 // that this ThreadableLoader creates. It can be altered e.g. when 129 // that this ThreadableLoader creates. It can be altered e.g. when
130 // redirect happens. 130 // redirect happens.
131 class CORE_EXPORT ThreadableLoader : public RefCounted<ThreadableLoader> { 131 class CORE_EXPORT ThreadableLoader {
132 WTF_MAKE_NONCOPYABLE(ThreadableLoader); 132 WTF_MAKE_NONCOPYABLE(ThreadableLoader);
133 public: 133 public:
134 // ThreadableLoaderClient methods may not destroy the ThreadableLoader 134 // ThreadableLoaderClient methods may not destroy the ThreadableLoader
135 // instance in them. 135 // instance in them.
136 static void loadResourceSynchronously(ExecutionContext&, const ResourceReque st&, ThreadableLoaderClient&, const ThreadableLoaderOptions&, const ResourceLoad erOptions&); 136 static void loadResourceSynchronously(ExecutionContext&, const ResourceReque st&, ThreadableLoaderClient&, const ThreadableLoaderOptions&, const ResourceLoad erOptions&);
137 137
138 // This method never returns nullptr. 138 // This method never returns nullptr.
139 // 139 //
140 // This method must always be followed by start() call. 140 // This method must always be followed by start() call.
141 // ThreadableLoaderClient methods are never called before start() call. 141 // ThreadableLoaderClient methods are never called before start() call.
(...skipping 19 matching lines...) Expand all
161 // When ThreadableLoader::cancel() is called, 161 // When ThreadableLoader::cancel() is called,
162 // ThreadableLoaderClient::didFail() is called with a ResourceError 162 // ThreadableLoaderClient::didFail() is called with a ResourceError
163 // with isCancellation() returning true, if any of didFinishLoading() 163 // with isCancellation() returning true, if any of didFinishLoading()
164 // or didFail.*() methods have not been called yet. (didFail() may be 164 // or didFail.*() methods have not been called yet. (didFail() may be
165 // called with a ResourceError with isCancellation() returning true 165 // called with a ResourceError with isCancellation() returning true
166 // also for cancellation happened inside the loader.) 166 // also for cancellation happened inside the loader.)
167 // 167 //
168 // ThreadableLoaderClient methods: 168 // ThreadableLoaderClient methods:
169 // - may call cancel() 169 // - may call cancel()
170 // - can destroy the ThreadableLoader instance in them (by clearing 170 // - can destroy the ThreadableLoader instance in them (by clearing
171 // RefPtr<ThreadableLoader>). 171 // OwnPtr<ThreadableLoader>).
172 static PassRefPtr<ThreadableLoader> create(ExecutionContext&, ThreadableLoad erClient*, const ThreadableLoaderOptions&, const ResourceLoaderOptions&); 172 static PassOwnPtr<ThreadableLoader> create(ExecutionContext&, ThreadableLoad erClient*, const ThreadableLoaderOptions&, const ResourceLoaderOptions&);
173 173
174 // The methods on the ThreadableLoaderClient passed on create() call 174 // The methods on the ThreadableLoaderClient passed on create() call
175 // may be called synchronous to start() call. 175 // may be called synchronous to start() call.
176 virtual void start(const ResourceRequest&) = 0; 176 virtual void start(const ResourceRequest&) = 0;
177 177
178 // A ThreadableLoader may have a timeout specified. It is possible, in some cases, for 178 // A ThreadableLoader may have a timeout specified. It is possible, in some cases, for
179 // the timeout to be overridden after the request is sent (for example, XMLH ttpRequests 179 // the timeout to be overridden after the request is sent (for example, XMLH ttpRequests
180 // may override their timeout setting after sending). 180 // may override their timeout setting after sending).
181 // 181 //
182 // Set a new timeout relative to the time the request started, in millisecon ds. 182 // Set a new timeout relative to the time the request started, in millisecon ds.
183 virtual void overrideTimeout(unsigned long timeoutMilliseconds) = 0; 183 virtual void overrideTimeout(unsigned long timeoutMilliseconds) = 0;
184 184
185 virtual void cancel() = 0; 185 virtual void cancel() = 0;
186 186
187 virtual ~ThreadableLoader() { } 187 virtual ~ThreadableLoader() { }
188 188
189 protected: 189 protected:
190 ThreadableLoader() { } 190 ThreadableLoader() { }
191 }; 191 };
192 192
193 } // namespace blink 193 } // namespace blink
194 194
195 #endif // ThreadableLoader_h 195 #endif // ThreadableLoader_h
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698