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

Side by Side Diff: Source/modules/serviceworkers/FetchManager.cpp

Issue 379113002: Move fetch-related predicates to core/fetch. (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: rebase Created 6 years, 5 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 // Copyright 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "config.h" 5 #include "config.h"
6 #include "FetchManager.h" 6 #include "FetchManager.h"
7 7
8 #include "bindings/core/v8/ExceptionState.h" 8 #include "bindings/core/v8/ExceptionState.h"
9 #include "bindings/core/v8/ScriptPromiseResolver.h" 9 #include "bindings/core/v8/ScriptPromiseResolver.h"
10 #include "bindings/core/v8/ScriptState.h" 10 #include "bindings/core/v8/ScriptState.h"
11 #include "bindings/core/v8/V8ThrowException.h" 11 #include "bindings/core/v8/V8ThrowException.h"
12 #include "core/dom/ExceptionCode.h" 12 #include "core/dom/ExceptionCode.h"
13 #include "core/fetch/CrossOriginAccessControl.h"
13 #include "core/fileapi/Blob.h" 14 #include "core/fileapi/Blob.h"
14 #include "core/loader/ThreadableLoader.h" 15 #include "core/loader/ThreadableLoader.h"
15 #include "core/loader/ThreadableLoaderClient.h" 16 #include "core/loader/ThreadableLoaderClient.h"
16 #include "core/xml/XMLHttpRequest.h"
17 #include "modules/serviceworkers/Response.h" 17 #include "modules/serviceworkers/Response.h"
18 #include "modules/serviceworkers/ResponseInit.h" 18 #include "modules/serviceworkers/ResponseInit.h"
19 #include "platform/network/ResourceRequest.h" 19 #include "platform/network/ResourceRequest.h"
20 #include "wtf/HashSet.h" 20 #include "wtf/HashSet.h"
21 21
22 namespace WebCore { 22 namespace WebCore {
23 23
24 class FetchManager::Loader : public ThreadableLoaderClient { 24 class FetchManager::Loader : public ThreadableLoaderClient {
25 public: 25 public:
26 Loader(ExecutionContext*, FetchManager*, PassRefPtr<ScriptPromiseResolver>, PassOwnPtr<ResourceRequest>); 26 Loader(ExecutionContext*, FetchManager*, PassRefPtr<ScriptPromiseResolver>, PassOwnPtr<ResourceRequest>);
(...skipping 143 matching lines...) Expand 10 before | Expand all | Expand 10 after
170 OwnPtr<Loader> loader(adoptPtr(new Loader(m_executionContext, this, resolver .release(), request))); 170 OwnPtr<Loader> loader(adoptPtr(new Loader(m_executionContext, this, resolver .release(), request)));
171 (*m_loaders.add(loader.release()).storedValue)->start(); 171 (*m_loaders.add(loader.release()).storedValue)->start();
172 return promise; 172 return promise;
173 } 173 }
174 174
175 void FetchManager::onLoaderFinished(Loader* loader) 175 void FetchManager::onLoaderFinished(Loader* loader)
176 { 176 {
177 m_loaders.remove(loader); 177 m_loaders.remove(loader);
178 } 178 }
179 179
180 bool FetchManager::isSimpleMethod(const String& method)
181 {
182 // "A simple method is a method that is `GET`, `HEAD`, or `POST`."
183 return isOnAccessControlSimpleRequestMethodWhitelist(method);
184 }
185
186 bool FetchManager::isForbiddenMethod(const String& method)
187 {
188 // "A forbidden method is a method that is a byte case-insensitive match for one of `CONNECT`, `TRACE`, and `TRACK`."
189 return !XMLHttpRequest::isAllowedHTTPMethod(method);
190 }
191
192 bool FetchManager::isUsefulMethod(const String& method)
193 {
194 // "A useful method is a method that is not a forbidden method."
195 // "A forbidden method is a method that is a byte case-insensitive match for one of `CONNECT`, `TRACE`, and `TRACK`."
196 return XMLHttpRequest::isAllowedHTTPMethod(method);
197 }
198
199 } // namespace WebCore 180 } // namespace WebCore
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698