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

Side by Side Diff: third_party/WebKit/Source/modules/fetch/Request.cpp

Issue 2292763002: [Fetch API] Implement Request.formData and Response.formData. (Closed)
Patch Set: Created 4 years, 3 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 "modules/fetch/Request.h" 5 #include "modules/fetch/Request.h"
6 6
7 #include "bindings/core/v8/Dictionary.h" 7 #include "bindings/core/v8/Dictionary.h"
8 #include "core/dom/Document.h" 8 #include "core/dom/Document.h"
9 #include "core/dom/ExecutionContext.h" 9 #include "core/dom/ExecutionContext.h"
10 #include "core/fetch/FetchUtils.h" 10 #include "core/fetch/FetchUtils.h"
(...skipping 653 matching lines...) Expand 10 before | Expand all | Expand 10 after
664 for (size_t i = 0, size = headerList->size(); i < size; ++i) { 664 for (size_t i = 0, size = headerList->size(); i < size; ++i) {
665 const FetchHeaderList::Header& header = headerList->entry(i); 665 const FetchHeaderList::Header& header = headerList->entry(i);
666 webRequest.appendHeader(header.first, header.second); 666 webRequest.appendHeader(header.first, header.second);
667 } 667 }
668 668
669 webRequest.setReferrer(m_request->referrerString(), static_cast<WebReferrerP olicy>(m_request->getReferrerPolicy())); 669 webRequest.setReferrer(m_request->referrerString(), static_cast<WebReferrerP olicy>(m_request->getReferrerPolicy()));
670 // FIXME: How can we set isReload properly? What is the correct place to loa d it in to the Request object? We should investigate the right way 670 // FIXME: How can we set isReload properly? What is the correct place to loa d it in to the Request object? We should investigate the right way
671 // to plumb this information in to here. 671 // to plumb this information in to here.
672 } 672 }
673 673
674 String Request::contentType() const
675 {
676 String result;
677 m_request->headerList()->get(HTTPNames::Content_Type, result);
678 return result;
679 }
680
674 String Request::mimeType() const 681 String Request::mimeType() const
675 { 682 {
676 return m_request->mimeType(); 683 return m_request->mimeType();
677 } 684 }
678 685
679 void Request::refreshBody(ScriptState* scriptState) 686 void Request::refreshBody(ScriptState* scriptState)
680 { 687 {
681 v8::Local<v8::Value> bodyBuffer = toV8(this->bodyBuffer(), scriptState); 688 v8::Local<v8::Value> bodyBuffer = toV8(this->bodyBuffer(), scriptState);
682 v8::Local<v8::Value> request = toV8(this, scriptState); 689 v8::Local<v8::Value> request = toV8(this, scriptState);
683 if (request.IsEmpty()) { 690 if (request.IsEmpty()) {
684 // |toV8| can return an empty handle when the worker is terminating. 691 // |toV8| can return an empty handle when the worker is terminating.
685 // We don't want the renderer to crash in such cases. 692 // We don't want the renderer to crash in such cases.
686 // TODO(yhirano): Delete this block after the graceful shutdown 693 // TODO(yhirano): Delete this block after the graceful shutdown
687 // mechanism is introduced. 694 // mechanism is introduced.
688 return; 695 return;
689 } 696 }
690 DCHECK(request->IsObject()); 697 DCHECK(request->IsObject());
691 V8HiddenValue::setHiddenValue(scriptState, request.As<v8::Object>(), V8Hidde nValue::internalBodyBuffer(scriptState->isolate()), bodyBuffer); 698 V8HiddenValue::setHiddenValue(scriptState, request.As<v8::Object>(), V8Hidde nValue::internalBodyBuffer(scriptState->isolate()), bodyBuffer);
692 } 699 }
693 700
694 DEFINE_TRACE(Request) 701 DEFINE_TRACE(Request)
695 { 702 {
696 Body::trace(visitor); 703 Body::trace(visitor);
697 visitor->trace(m_request); 704 visitor->trace(m_request);
698 visitor->trace(m_headers); 705 visitor->trace(m_headers);
699 } 706 }
700 707
701 } // namespace blink 708 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698