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

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 340 matching lines...) Expand 10 before | Expand all | Expand 10 after
351 void FetchManager::Loader::performHTTPFetch(bool corsFlag, bool corsPreflightFla g) 351 void FetchManager::Loader::performHTTPFetch(bool corsFlag, bool corsPreflightFla g)
352 { 352 {
353 ASSERT(m_request->url().protocolIsInHTTPFamily()); 353 ASSERT(m_request->url().protocolIsInHTTPFamily());
354 // CORS preflight fetch procedure is implemented inside DocumentThreadableLo ader. 354 // CORS preflight fetch procedure is implemented inside DocumentThreadableLo ader.
355 355
356 // "1. Let |HTTPRequest| be a copy of |request|, except that |HTTPRequest|'s 356 // "1. Let |HTTPRequest| be a copy of |request|, except that |HTTPRequest|'s
357 // body is a tee of |request|'s body." 357 // body is a tee of |request|'s body."
358 // We use ResourceRequest class for HTTPRequest. 358 // We use ResourceRequest class for HTTPRequest.
359 // FIXME: Support body. 359 // FIXME: Support body.
360 ResourceRequest request(m_request->url()); 360 ResourceRequest request(m_request->url());
361 request.setRequestContext(WebURLRequest::RequestContextFetch); 361 request.setRequestContext(m_request->context());
362 request.setHTTPMethod(m_request->method()); 362 request.setHTTPMethod(m_request->method());
363 const Vector<OwnPtr<FetchHeaderList::Header>>& list = m_request->headerList( )->list(); 363 const Vector<OwnPtr<FetchHeaderList::Header>>& list = m_request->headerList( )->list();
364 for (size_t i = 0; i < list.size(); ++i) { 364 for (size_t i = 0; i < list.size(); ++i) {
365 request.addHTTPHeaderField(AtomicString(list[i]->first), AtomicString(li st[i]->second)); 365 request.addHTTPHeaderField(AtomicString(list[i]->first), AtomicString(li st[i]->second));
366 } 366 }
367 367
368 if (m_request->method() != "GET" && m_request->method() != "HEAD") { 368 if (m_request->method() != "GET" && m_request->method() != "HEAD") {
369 RefPtr<BlobDataHandle> blobDataHandle = m_request->blobDataHandle(); 369 RefPtr<BlobDataHandle> blobDataHandle = m_request->blobDataHandle();
370 if (blobDataHandle.get()) { 370 if (blobDataHandle.get()) {
371 RefPtr<FormData> httpBody(FormData::create()); 371 RefPtr<FormData> httpBody(FormData::create());
(...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after
459 #if !ENABLE(OILPAN) 459 #if !ENABLE(OILPAN)
460 if (!m_isStopped) 460 if (!m_isStopped)
461 stop(); 461 stop();
462 #endif 462 #endif
463 } 463 }
464 464
465 ScriptPromise FetchManager::fetch(ScriptState* scriptState, FetchRequestData* re quest) 465 ScriptPromise FetchManager::fetch(ScriptState* scriptState, FetchRequestData* re quest)
466 { 466 {
467 RefPtrWillBeRawPtr<ScriptPromiseResolver> resolver = ScriptPromiseResolver:: create(scriptState); 467 RefPtrWillBeRawPtr<ScriptPromiseResolver> resolver = ScriptPromiseResolver:: create(scriptState);
468 ScriptPromise promise = resolver->promise(); 468 ScriptPromise promise = resolver->promise();
469 469
horo 2015/04/07 00:21:25 Please set the context to "fetch". https://fetch.
shiva.jm 2015/04/09 09:16:22 Done.
470 OwnPtrWillBeRawPtr<Loader> ownLoader = Loader::create(m_executionContext, th is, resolver.release(), request); 470 OwnPtrWillBeRawPtr<Loader> ownLoader = Loader::create(m_executionContext, th is, resolver.release(), request);
471 Loader* loader = m_loaders.add(ownLoader.release()).storedValue->get(); 471 Loader* loader = m_loaders.add(ownLoader.release()).storedValue->get();
472 loader->start(); 472 loader->start();
473 return promise; 473 return promise;
474 } 474 }
475 475
476 void FetchManager::stop() 476 void FetchManager::stop()
477 { 477 {
478 ASSERT(!m_isStopped); 478 ASSERT(!m_isStopped);
479 m_isStopped = true; 479 m_isStopped = true;
(...skipping 11 matching lines...) Expand all
491 491
492 DEFINE_TRACE(FetchManager) 492 DEFINE_TRACE(FetchManager)
493 { 493 {
494 #if ENABLE(OILPAN) 494 #if ENABLE(OILPAN)
495 visitor->trace(m_executionContext); 495 visitor->trace(m_executionContext);
496 visitor->trace(m_loaders); 496 visitor->trace(m_loaders);
497 #endif 497 #endif
498 } 498 }
499 499
500 } // namespace blink 500 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698