OLD | NEW |
---|---|
1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 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 FetchDataConsumerHandle_h | 5 #ifndef FetchDataConsumerHandle_h |
6 #define FetchDataConsumerHandle_h | 6 #define FetchDataConsumerHandle_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/network/FormData.h" | |
10 #include "public/platform/WebDataConsumerHandle.h" | 11 #include "public/platform/WebDataConsumerHandle.h" |
11 #include "wtf/Forward.h" | 12 #include "wtf/Forward.h" |
12 #include "wtf/PassRefPtr.h" | 13 #include "wtf/PassRefPtr.h" |
13 | 14 |
14 namespace blink { | 15 namespace blink { |
15 | 16 |
16 // This is an interface class that adds Reader's blobDataHandle() to | 17 // This is an interface class that adds Reader's blobDataHandle() to |
17 // WebDataConsumerHandle. | 18 // WebDataConsumerHandle. |
18 // This class works not very well with Oilpan: As this class is not garbage | 19 // This class works not very well with Oilpan: As this class is not garbage |
19 // collected while many clients or related objects may be, it is very easy | 20 // collected while many clients or related objects may be, it is very easy |
(...skipping 13 matching lines...) Expand all Loading... | |
33 // Drains the data as a BlobDataHandle. | 34 // Drains the data as a BlobDataHandle. |
34 // If this function returns non-null BlobDataHandle: | 35 // If this function returns non-null BlobDataHandle: |
35 // - The bytes that will be read from the returned BlobDataHandle | 36 // - The bytes that will be read from the returned BlobDataHandle |
36 // must be idential to the bytes that would be read through | 37 // must be idential to the bytes that would be read through |
37 // WebDataConsumerHandle::Reader APIs without calling this function. | 38 // WebDataConsumerHandle::Reader APIs without calling this function. |
38 // - Subsequent calls to read() / beginRead() return |Done|. | 39 // - Subsequent calls to read() / beginRead() return |Done|. |
39 // This function can return |nullptr|, and in such cases this | 40 // This function can return |nullptr|, and in such cases this |
40 // function is no-op. | 41 // function is no-op. |
41 // This function returns |nullptr| when called during two-phase read. | 42 // This function returns |nullptr| when called during two-phase read. |
42 virtual PassRefPtr<BlobDataHandle> drainAsBlobDataHandle(BlobSizePolicy = DisallowBlobWithInvalidSize) { return nullptr; } | 43 virtual PassRefPtr<BlobDataHandle> drainAsBlobDataHandle(BlobSizePolicy = DisallowBlobWithInvalidSize) { return nullptr; } |
44 | |
45 // Drains the data as a FormData. | |
46 // This function returns a non-null form data when | |
47 // - The handle is made from a FormData-convertible type, | |
48 // - The reader is running on a suitable thread | |
hiroshige
2015/08/10 13:27:03
nit: append ", and" at the end of line?
yhirano
2015/08/11 06:08:43
Done.
| |
49 // - No data is read yet. | |
50 // After that read() / beginRead() will return |Done|. | |
51 // Otherwise this function does nothing and returns null. | |
52 // This function returns |nullptr| when called during two-phase read. | |
53 virtual PassRefPtr<FormData> drainAsFormData() { return nullptr; } | |
43 }; | 54 }; |
44 | 55 |
45 // TODO(yhirano): obtainReader() is currently non-virtual override, and | 56 // TODO(yhirano): obtainReader() is currently non-virtual override, and |
46 // will be changed into virtual override when we can use scoped_ptr / | 57 // will be changed into virtual override when we can use scoped_ptr / |
47 // unique_ptr in both Blink and Chromium. | 58 // unique_ptr in both Blink and Chromium. |
48 PassOwnPtr<Reader> obtainReader(Client* client) { return adoptPtr(obtainRead erInternal(client)); } | 59 PassOwnPtr<Reader> obtainReader(Client* client) { return adoptPtr(obtainRead erInternal(client)); } |
49 | 60 |
50 private: | 61 private: |
51 Reader* obtainReaderInternal(Client*) override = 0; | 62 Reader* obtainReaderInternal(Client*) override = 0; |
52 }; | 63 }; |
53 | 64 |
54 } // namespace blink | 65 } // namespace blink |
55 | 66 |
56 #endif // FetchDataConsumerHandle_h | 67 #endif // FetchDataConsumerHandle_h |
OLD | NEW |