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

Side by Side Diff: third_party/WebKit/Source/modules/fetch/BytesConsumer.h

Issue 2356693002: Remove BytesConsumer::read (Closed)
Patch Set: fix 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 2016 The Chromium Authors. All rights reserved. 1 // Copyright 2016 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 BytesConsumer_h 5 #ifndef BytesConsumer_h
6 #define BytesConsumer_h 6 #define BytesConsumer_h
7 7
8 #include "modules/ModulesExport.h" 8 #include "modules/ModulesExport.h"
9 #include "platform/blob/BlobData.h" 9 #include "platform/blob/BlobData.h"
10 #include "platform/heap/Handle.h" 10 #include "platform/heap/Handle.h"
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after
67 // 67 //
68 // This function is not called when the state change is trigerred by 68 // This function is not called when the state change is trigerred by
69 // public methods called by a user. For example, when a user reads 69 // public methods called by a user. For example, when a user reads
70 // data by |read| and the state changes from waiting to readable, this 70 // data by |read| and the state changes from waiting to readable, this
71 // function will not be called. 71 // function will not be called.
72 virtual void onStateChange() = 0; 72 virtual void onStateChange() = 0;
73 }; 73 };
74 74
75 virtual ~BytesConsumer() {} 75 virtual ~BytesConsumer() {}
76 76
77 // Reads data into |buffer| up to |size| bytes. The actual read size will
78 // be stored in |*readSize|. This function cannot be called when a two-phase
79 // read is in progress.
80 // Returns Ok when readable.
81 // Returns ShouldWait when it's waiting.
82 // Returns Done when closed.
83 // Returns Error when errored.
84 // |buffer| can be null if |size| is 0.
85 // |*readSize| will be set to 0 if not readable.
86 virtual Result read(char* buffer, size_t /* size */, size_t* readSize) WARN_ UNUSED_RESULT;
87
88 // Begins a two-phase read. On success, the function stores a buffer 77 // Begins a two-phase read. On success, the function stores a buffer
89 // that contains the read data of length |*available| into |*buffer|. 78 // that contains the read data of length |*available| into |*buffer|.
90 // Returns Ok when readable. 79 // Returns Ok when readable.
91 // Returns ShouldWait when it's waiting. 80 // Returns ShouldWait when it's waiting.
92 // Returns Done when it's closed. 81 // Returns Done when it's closed.
93 // Returns Error when errored. 82 // Returns Error when errored.
94 // When not readable, the caller don't have to (and must not) call 83 // When not readable, the caller don't have to (and must not) call
95 // endRead, because the read session implicitly ends in that case. 84 // endRead, because the read session implicitly ends in that case.
96 // 85 //
97 // |*buffer| will become invalid when this object becomes unreachable, 86 // |*buffer| will become invalid when this object becomes unreachable,
98 // even if endRead is not called. 87 // even if endRead is not called.
99 // 88 //
100 // |*buffer| will be set to null and |*available| will be set to 0 if not 89 // |*buffer| will be set to null and |*available| will be set to 0 if not
101 // readable. 90 // readable.
102 virtual Result beginRead(const char** buffer, size_t* available) WARN_UNUSED _RESULT = 0; 91 virtual Result beginRead(const char** buffer, size_t* available) WARN_UNUSED _RESULT = 0;
103 92
104 // Ends a two-phase read. 93 // Ends a two-phase read.
105 virtual Result endRead(size_t readSize) WARN_UNUSED_RESULT = 0; 94 virtual Result endRead(size_t readSize) WARN_UNUSED_RESULT = 0;
106 95
107 // Drains the data as a BlobDataHandle. 96 // Drains the data as a BlobDataHandle.
108 // When this function returns a non-null value, the returned blob handle 97 // When this function returns a non-null value, the returned blob handle
109 // contains bytes that would be read through read, beginRead and 98 // contains bytes that would be read through beginRead and
110 // endRead functions without calling this function. In such a case, this 99 // endRead functions without calling this function. In such a case, this
111 // object becomes closed. 100 // object becomes closed.
112 // When this function returns null value, this function does nothing. 101 // When this function returns null value, this function does nothing.
113 // When |policy| is DisallowBlobWithInvalidSize, this function doesn't 102 // When |policy| is DisallowBlobWithInvalidSize, this function doesn't
114 // return a non-null blob handle with unspecified size. 103 // return a non-null blob handle with unspecified size.
115 // The type of the returned blob handle may not be meaningful. 104 // The type of the returned blob handle may not be meaningful.
116 virtual PassRefPtr<BlobDataHandle> drainAsBlobDataHandle(BlobSizePolicy = Bl obSizePolicy::DisallowBlobWithInvalidSize) { return nullptr; } 105 virtual PassRefPtr<BlobDataHandle> drainAsBlobDataHandle(BlobSizePolicy = Bl obSizePolicy::DisallowBlobWithInvalidSize) { return nullptr; }
117 106
118 // Drains the data as an EncodedFormData. 107 // Drains the data as an EncodedFormData.
119 // When this function returns a non-null value, the returned form data 108 // When this function returns a non-null value, the returned form data
120 // contains bytes that would be read through read, beginRead and 109 // contains bytes that would be read through beginRead and
121 // endRead functions without calling this function. In such a case, this 110 // endRead functions without calling this function. In such a case, this
122 // object becomes closed. 111 // object becomes closed.
123 // When this function returns null value, this function does nothing. 112 // When this function returns null value, this function does nothing.
124 // This function returns a non-null form data when the handle is made 113 // This function returns a non-null form data when the handle is made
125 // from an EncodedFormData-convertible value. 114 // from an EncodedFormData-convertible value.
126 virtual PassRefPtr<EncodedFormData> drainAsFormData() { return nullptr; } 115 virtual PassRefPtr<EncodedFormData> drainAsFormData() { return nullptr; }
127 116
128 // Sets a client. This can be called only when no client is set. When 117 // Sets a client. This can be called only when no client is set. When
129 // this object is already closed or errored, this function does nothing. 118 // this object is already closed or errored, this function does nothing.
130 virtual void setClient(Client*) = 0; 119 virtual void setClient(Client*) = 0;
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after
178 return PublicState::Errored; 167 return PublicState::Errored;
179 } 168 }
180 NOTREACHED(); 169 NOTREACHED();
181 return PublicState::ReadableOrWaiting; 170 return PublicState::ReadableOrWaiting;
182 } 171 }
183 }; 172 };
184 173
185 } // namespace blink 174 } // namespace blink
186 175
187 #endif // BytesConsumer_h 176 #endif // BytesConsumer_h
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698