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

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

Issue 1060033002: Implement Request.context for Fetch API (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Created 5 years, 8 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 "modules/fetch/FetchManager.h" 6 #include "modules/fetch/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"
(...skipping 342 matching lines...) Expand 10 before | Expand all | Expand 10 after
353 void FetchManager::Loader::performHTTPFetch(bool corsFlag, bool corsPreflightFla g) 353 void FetchManager::Loader::performHTTPFetch(bool corsFlag, bool corsPreflightFla g)
354 { 354 {
355 ASSERT(m_request->url().protocolIsInHTTPFamily()); 355 ASSERT(m_request->url().protocolIsInHTTPFamily());
356 // CORS preflight fetch procedure is implemented inside DocumentThreadableLo ader. 356 // CORS preflight fetch procedure is implemented inside DocumentThreadableLo ader.
357 357
358 // "1. Let |HTTPRequest| be a copy of |request|, except that |HTTPRequest|'s 358 // "1. Let |HTTPRequest| be a copy of |request|, except that |HTTPRequest|'s
359 // body is a tee of |request|'s body." 359 // body is a tee of |request|'s body."
360 // We use ResourceRequest class for HTTPRequest. 360 // We use ResourceRequest class for HTTPRequest.
361 // FIXME: Support body. 361 // FIXME: Support body.
362 ResourceRequest request(m_request->url()); 362 ResourceRequest request(m_request->url());
363 request.setRequestContext(WebURLRequest::RequestContextFetch); 363 request.setRequestContext(m_request->context());
364 request.setHTTPMethod(m_request->method()); 364 request.setHTTPMethod(m_request->method());
365 const Vector<OwnPtr<FetchHeaderList::Header>>& list = m_request->headerList( )->list(); 365 const Vector<OwnPtr<FetchHeaderList::Header>>& list = m_request->headerList( )->list();
366 for (size_t i = 0; i < list.size(); ++i) { 366 for (size_t i = 0; i < list.size(); ++i) {
367 request.addHTTPHeaderField(AtomicString(list[i]->first), AtomicString(li st[i]->second)); 367 request.addHTTPHeaderField(AtomicString(list[i]->first), AtomicString(li st[i]->second));
368 } 368 }
369 369
370 if (m_request->method() != "GET" && m_request->method() != "HEAD") { 370 if (m_request->method() != "GET" && m_request->method() != "HEAD") {
371 RefPtr<BlobDataHandle> blobDataHandle = m_request->blobDataHandle(); 371 RefPtr<BlobDataHandle> blobDataHandle = m_request->blobDataHandle();
372 if (blobDataHandle.get()) { 372 if (blobDataHandle.get()) {
373 RefPtr<FormData> httpBody(FormData::create()); 373 RefPtr<FormData> httpBody(FormData::create());
(...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after
462 if (!m_isStopped) 462 if (!m_isStopped)
463 stop(); 463 stop();
464 #endif 464 #endif
465 } 465 }
466 466
467 ScriptPromise FetchManager::fetch(ScriptState* scriptState, FetchRequestData* re quest) 467 ScriptPromise FetchManager::fetch(ScriptState* scriptState, FetchRequestData* re quest)
468 { 468 {
469 RefPtrWillBeRawPtr<ScriptPromiseResolver> resolver = ScriptPromiseResolver:: create(scriptState); 469 RefPtrWillBeRawPtr<ScriptPromiseResolver> resolver = ScriptPromiseResolver:: create(scriptState);
470 ScriptPromise promise = resolver->promise(); 470 ScriptPromise promise = resolver->promise();
471 471
472 request->setContext(WebURLRequest::RequestContextFetch);
473
472 OwnPtrWillBeRawPtr<Loader> ownLoader = Loader::create(m_executionContext, th is, resolver.release(), request); 474 OwnPtrWillBeRawPtr<Loader> ownLoader = Loader::create(m_executionContext, th is, resolver.release(), request);
473 Loader* loader = m_loaders.add(ownLoader.release()).storedValue->get(); 475 Loader* loader = m_loaders.add(ownLoader.release()).storedValue->get();
474 loader->start(); 476 loader->start();
475 return promise; 477 return promise;
476 } 478 }
477 479
478 void FetchManager::stop() 480 void FetchManager::stop()
479 { 481 {
480 ASSERT(!m_isStopped); 482 ASSERT(!m_isStopped);
481 m_isStopped = true; 483 m_isStopped = true;
(...skipping 11 matching lines...) Expand all
493 495
494 DEFINE_TRACE(FetchManager) 496 DEFINE_TRACE(FetchManager)
495 { 497 {
496 #if ENABLE(OILPAN) 498 #if ENABLE(OILPAN)
497 visitor->trace(m_executionContext); 499 visitor->trace(m_executionContext);
498 visitor->trace(m_loaders); 500 visitor->trace(m_loaders);
499 #endif 501 #endif
500 } 502 }
501 503
502 } // namespace blink 504 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698