| OLD | NEW |
| 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" | |
| 9 #include "bindings/core/v8/ScriptPromiseResolver.h" | 8 #include "bindings/core/v8/ScriptPromiseResolver.h" |
| 10 #include "bindings/core/v8/ScriptState.h" | 9 #include "bindings/core/v8/ScriptState.h" |
| 11 #include "bindings/core/v8/V8ThrowException.h" | 10 #include "bindings/core/v8/V8ThrowException.h" |
| 12 #include "core/dom/ExceptionCode.h" | 11 #include "core/dom/ExceptionCode.h" |
| 13 #include "core/fileapi/Blob.h" | 12 #include "core/fileapi/Blob.h" |
| 14 #include "core/loader/ThreadableLoader.h" | 13 #include "core/loader/ThreadableLoader.h" |
| 15 #include "core/loader/ThreadableLoaderClient.h" | 14 #include "core/loader/ThreadableLoaderClient.h" |
| 16 #include "core/xml/XMLHttpRequest.h" | 15 #include "core/xml/XMLHttpRequest.h" |
| 17 #include "modules/serviceworkers/Response.h" | 16 #include "modules/serviceworkers/Response.h" |
| 18 #include "modules/serviceworkers/ResponseInit.h" | 17 #include "modules/serviceworkers/ResponseInit.h" |
| (...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 79 // FIXME: Set the ContentType correctly. | 78 // FIXME: Set the ContentType correctly. |
| 80 } | 79 } |
| 81 ResponseInit responseInit; | 80 ResponseInit responseInit; |
| 82 // FIXME: We may have to filter the status when we support CORS. | 81 // FIXME: We may have to filter the status when we support CORS. |
| 83 // http://fetch.spec.whatwg.org/#concept-filtered-response-opaque | 82 // http://fetch.spec.whatwg.org/#concept-filtered-response-opaque |
| 84 responseInit.status = m_response.httpStatusCode(); | 83 responseInit.status = m_response.httpStatusCode(); |
| 85 responseInit.statusText = m_response.httpStatusText(); | 84 responseInit.statusText = m_response.httpStatusText(); |
| 86 // FIXME: fill options. | 85 // FIXME: fill options. |
| 87 RefPtrWillBeRawPtr<Blob> blob = Blob::create(BlobDataHandle::create(blobData
.release(), m_downloadedBlobLength)); | 86 RefPtrWillBeRawPtr<Blob> blob = Blob::create(BlobDataHandle::create(blobData
.release(), m_downloadedBlobLength)); |
| 88 // FIXME: Handle response status correctly. | 87 // FIXME: Handle response status correctly. |
| 89 NonThrowableExceptionState exceptionState; | 88 m_resolver->resolve(Response::create(blob.get(), responseInit)); |
| 90 m_resolver->resolve(Response::create(blob.get(), responseInit, exceptionStat
e)); | |
| 91 notifyFinished(); | 89 notifyFinished(); |
| 92 } | 90 } |
| 93 | 91 |
| 94 void FetchManager::Loader::didFail(const ResourceError& error) | 92 void FetchManager::Loader::didFail(const ResourceError& error) |
| 95 { | 93 { |
| 96 failed(); | 94 failed(); |
| 97 } | 95 } |
| 98 | 96 |
| 99 void FetchManager::Loader::didFailAccessControlCheck(const ResourceError& error) | 97 void FetchManager::Loader::didFailAccessControlCheck(const ResourceError& error) |
| 100 { | 98 { |
| (...skipping 89 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 190 } | 188 } |
| 191 | 189 |
| 192 bool FetchManager::isUsefulMethod(const String& method) | 190 bool FetchManager::isUsefulMethod(const String& method) |
| 193 { | 191 { |
| 194 // "A useful method is a method that is not a forbidden method." | 192 // "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`." | 193 // "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); | 194 return XMLHttpRequest::isAllowedHTTPMethod(method); |
| 197 } | 195 } |
| 198 | 196 |
| 199 } // namespace WebCore | 197 } // namespace WebCore |
| OLD | NEW |