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

Side by Side Diff: Source/modules/fetch/BodyStreamBuffer.h

Issue 1301523002: [Fetch API] Send request body as a FormData. (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Created 5 years, 4 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 | Annotate | Revision Log
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 #ifndef BodyStreamBuffer_h 5 #ifndef BodyStreamBuffer_h
6 #define BodyStreamBuffer_h 6 #define BodyStreamBuffer_h
7 7
8 #include "core/dom/DOMException.h" 8 #include "core/dom/DOMException.h"
9 #include "core/streams/ReadableByteStream.h" 9 #include "core/streams/ReadableByteStream.h"
10 #include "core/streams/ReadableByteStreamReader.h" 10 #include "core/streams/ReadableByteStreamReader.h"
11 #include "core/streams/UnderlyingSource.h" 11 #include "core/streams/UnderlyingSource.h"
12 #include "modules/ModulesExport.h" 12 #include "modules/ModulesExport.h"
13 #include "modules/fetch/FetchDataConsumerHandle.h" 13 #include "modules/fetch/FetchDataConsumerHandle.h"
14 #include "modules/fetch/FetchDataLoader.h" 14 #include "modules/fetch/FetchDataLoader.h"
15 #include "platform/heap/Handle.h" 15 #include "platform/heap/Handle.h"
16 #include "public/platform/WebDataConsumerHandle.h" 16 #include "public/platform/WebDataConsumerHandle.h"
17 #include "wtf/OwnPtr.h" 17 #include "wtf/OwnPtr.h"
18 #include "wtf/PassOwnPtr.h" 18 #include "wtf/PassOwnPtr.h"
19 19
20 namespace blink { 20 namespace blink {
21 21
22 class ExecutionContext; 22 class ExecutionContext;
23 class FormData;
23 24
24 // A BodyStreamBuffer constructed with a null handle is said to have null body. 25 // A BodyStreamBuffer constructed with a null handle is said to have null body.
25 // One can observe if a buffer has null body by calling |hasBody| function. 26 // One can observe if a buffer has null body by calling |hasBody| function.
26 // |stream| function returns a non-null stream even when the buffer has null 27 // |stream| function returns a non-null stream even when the buffer has null
27 // body. 28 // body.
28 class MODULES_EXPORT BodyStreamBuffer final : public GarbageCollectedFinalized<B odyStreamBuffer>, public UnderlyingSource, public WebDataConsumerHandle::Client { 29 class MODULES_EXPORT BodyStreamBuffer final : public GarbageCollectedFinalized<B odyStreamBuffer>, public UnderlyingSource, public WebDataConsumerHandle::Client {
29 WTF_MAKE_NONCOPYABLE(BodyStreamBuffer); 30 WTF_MAKE_NONCOPYABLE(BodyStreamBuffer);
30 USING_GARBAGE_COLLECTED_MIXIN(BodyStreamBuffer); 31 USING_GARBAGE_COLLECTED_MIXIN(BodyStreamBuffer);
31 public: 32 public:
32 BodyStreamBuffer() : BodyStreamBuffer(nullptr) {} 33 BodyStreamBuffer() : BodyStreamBuffer(nullptr) {}
33 // |handle| can be null, but cannot be locked. 34 // |handle| can be null, but cannot be locked.
34 explicit BodyStreamBuffer(PassOwnPtr<FetchDataConsumerHandle> /* handle */); 35 explicit BodyStreamBuffer(PassOwnPtr<FetchDataConsumerHandle> /* handle */);
35 36
36 ReadableByteStream* stream() { return m_stream; } 37 ReadableByteStream* stream() { return m_stream; }
37 38
38 // Callable only when not locked. 39 // Callable only when not locked.
39 PassRefPtr<BlobDataHandle> drainAsBlobDataHandle(FetchDataConsumerHandle::Re ader::BlobSizePolicy); 40 PassRefPtr<BlobDataHandle> drainAsBlobDataHandle(FetchDataConsumerHandle::Re ader::BlobSizePolicy);
41 PassRefPtr<FormData> drainAsFormData();
40 42
41 // Callable only when not locked. Returns a non-null handle even when 43 // Callable only when not locked. Returns a non-null handle even when
42 // having null body. 44 // having null body.
43 // Note: There is a case that calling |lock| doesn't make the buffer 45 // Note: There is a case that calling |lock| doesn't make the buffer
44 // locked. |unlock| should be called even in such cases when a user finishes 46 // locked. |unlock| should be called even in such cases when a user finishes
45 // to use the returned handle, in order to maintain hasPendingActivity(). 47 // to use the returned handle, in order to maintain hasPendingActivity().
46 PassOwnPtr<FetchDataConsumerHandle> lock(ExecutionContext*); 48 PassOwnPtr<FetchDataConsumerHandle> lock(ExecutionContext*);
47 49
48 // This function will lock |this| object. |client| cannot be null. 50 // This function will lock |this| object. |client| cannot be null.
49 void startLoading(ExecutionContext*, FetchDataLoader*, FetchDataLoader::Clie nt* /* client */); 51 void startLoading(ExecutionContext*, FetchDataLoader*, FetchDataLoader::Clie nt* /* client */);
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after
88 // although we should return true for hasPendingActivity() when someone 90 // although we should return true for hasPendingActivity() when someone
89 // calls |startLoading| but the loding is not yet done. 91 // calls |startLoading| but the loding is not yet done.
90 unsigned m_lockLevel; 92 unsigned m_lockLevel;
91 const bool m_hasBody; 93 const bool m_hasBody;
92 bool m_streamNeedsMore; 94 bool m_streamNeedsMore;
93 }; 95 };
94 96
95 } // namespace blink 97 } // namespace blink
96 98
97 #endif // BodyStreamBuffer_h 99 #endif // BodyStreamBuffer_h
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698