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 "modules/fetch/Response.h" | 5 #include "modules/fetch/Response.h" |
6 | 6 |
7 #include "bindings/core/v8/Dictionary.h" | 7 #include "bindings/core/v8/Dictionary.h" |
8 #include "bindings/core/v8/ExceptionState.h" | 8 #include "bindings/core/v8/ExceptionState.h" |
9 #include "bindings/core/v8/ScriptState.h" | 9 #include "bindings/core/v8/ScriptState.h" |
10 #include "bindings/core/v8/V8ArrayBuffer.h" | 10 #include "bindings/core/v8/V8ArrayBuffer.h" |
(...skipping 26 matching lines...) Expand all Loading... |
37 | 37 |
38 FetchResponseData* createFetchResponseDataFromWebResponse( | 38 FetchResponseData* createFetchResponseDataFromWebResponse( |
39 ScriptState* scriptState, | 39 ScriptState* scriptState, |
40 const WebServiceWorkerResponse& webResponse) { | 40 const WebServiceWorkerResponse& webResponse) { |
41 FetchResponseData* response = nullptr; | 41 FetchResponseData* response = nullptr; |
42 if (webResponse.status() > 0) | 42 if (webResponse.status() > 0) |
43 response = FetchResponseData::create(); | 43 response = FetchResponseData::create(); |
44 else | 44 else |
45 response = FetchResponseData::createNetworkErrorResponse(); | 45 response = FetchResponseData::createNetworkErrorResponse(); |
46 | 46 |
47 response->setURL(webResponse.url()); | 47 const WebVector<WebURL>& webURLList = webResponse.urlList(); |
| 48 Vector<KURL> urlList(webURLList.size()); |
| 49 std::transform(webURLList.begin(), webURLList.end(), urlList.begin(), |
| 50 [](const WebURL& url) { return url; }); |
| 51 response->setURLList(urlList); |
48 response->setStatus(webResponse.status()); | 52 response->setStatus(webResponse.status()); |
49 response->setStatusMessage(webResponse.statusText()); | 53 response->setStatusMessage(webResponse.statusText()); |
50 response->setResponseTime(webResponse.responseTime()); | 54 response->setResponseTime(webResponse.responseTime()); |
51 response->setCacheStorageCacheName(webResponse.cacheStorageCacheName()); | 55 response->setCacheStorageCacheName(webResponse.cacheStorageCacheName()); |
52 | 56 |
53 for (HTTPHeaderMap::const_iterator i = webResponse.headers().begin(), | 57 for (HTTPHeaderMap::const_iterator i = webResponse.headers().begin(), |
54 end = webResponse.headers().end(); | 58 end = webResponse.headers().end(); |
55 i != end; ++i) { | 59 i != end; ++i) { |
56 response->headerList()->append(i->key, i->value); | 60 response->headerList()->append(i->key, i->value); |
57 } | 61 } |
(...skipping 285 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
343 return "opaqueredirect"; | 347 return "opaqueredirect"; |
344 } | 348 } |
345 ASSERT_NOT_REACHED(); | 349 ASSERT_NOT_REACHED(); |
346 return ""; | 350 return ""; |
347 } | 351 } |
348 | 352 |
349 String Response::url() const { | 353 String Response::url() const { |
350 // "The url attribute's getter must return the empty string if response's | 354 // "The url attribute's getter must return the empty string if response's |
351 // url is null and response's url, serialized with the exclude fragment | 355 // url is null and response's url, serialized with the exclude fragment |
352 // flag set, otherwise." | 356 // flag set, otherwise." |
353 if (!m_response->url().hasFragmentIdentifier()) | 357 const KURL* responseURL = m_response->url(); |
354 return m_response->url(); | 358 if (!responseURL) |
355 KURL url(m_response->url()); | 359 return emptyString(); |
| 360 if (!responseURL->hasFragmentIdentifier()) |
| 361 return *responseURL; |
| 362 KURL url(*responseURL); |
356 url.removeFragmentIdentifier(); | 363 url.removeFragmentIdentifier(); |
357 return url; | 364 return url; |
358 } | 365 } |
359 | 366 |
360 unsigned short Response::status() const { | 367 unsigned short Response::status() const { |
361 // "The status attribute's getter must return response's status." | 368 // "The status attribute's getter must return response's status." |
362 return m_response->status(); | 369 return m_response->status(); |
363 } | 370 } |
364 | 371 |
365 bool Response::ok() const { | 372 bool Response::ok() const { |
(...skipping 94 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
460 V8HiddenValue::internalBodyBuffer(scriptState->isolate()), bodyBuffer); | 467 V8HiddenValue::internalBodyBuffer(scriptState->isolate()), bodyBuffer); |
461 } | 468 } |
462 | 469 |
463 DEFINE_TRACE(Response) { | 470 DEFINE_TRACE(Response) { |
464 Body::trace(visitor); | 471 Body::trace(visitor); |
465 visitor->trace(m_response); | 472 visitor->trace(m_response); |
466 visitor->trace(m_headers); | 473 visitor->trace(m_headers); |
467 } | 474 } |
468 | 475 |
469 } // namespace blink | 476 } // namespace blink |
OLD | NEW |