| OLD | NEW |
| (Empty) | |
| 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 |
| 3 // found in the LICENSE file. |
| 4 |
| 5 #ifndef FetchDataConsumerHandle_h |
| 6 #define FetchDataConsumerHandle_h |
| 7 |
| 8 #include "public/platform/WebDataConsumerHandle.h" |
| 9 #include "wtf/Forward.h" |
| 10 #include "wtf/PassRefPtr.h" |
| 11 |
| 12 namespace blink { |
| 13 |
| 14 class BlobDataHandle; |
| 15 |
| 16 // This is an interface class that adds Reader's blobDataHandle() to |
| 17 // WebDataConsumerHandle. |
| 18 // 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 // to create a reference cycle. When an client is garbage collected, making |
| 21 // the client own the handle is the right way. |
| 22 class FetchDataConsumerHandle : public WebDataConsumerHandle { |
| 23 public: |
| 24 class Reader : public WebDataConsumerHandle::Reader { |
| 25 public: |
| 26 // Returns a blob handle representing the body data. This function can |
| 27 // returns null when the object doesn't have such a handle. Calling |
| 28 // this function drains the body data. |
| 29 // This function is defined for performance. If this function returns a |
| 30 // non-null handle, the bytes that will be read from the handle must be |
| 31 // idential to the bytes that will be read |
| 32 // through WebDataConsumerHandle APIs without calling this function. |
| 33 virtual PassRefPtr<BlobDataHandle> blobDataHandle() = 0; |
| 34 }; |
| 35 |
| 36 // TODO(yhirano): obtainReader() is currently non-virtual override, and |
| 37 // will be changed into virtual override when we can use scoped_ptr / |
| 38 // unique_ptr in both Blink and Chromium. |
| 39 PassOwnPtr<Reader> obtainReader(Client* client) { return adoptPtr(obtainRead
erInternal(client)); } |
| 40 |
| 41 private: |
| 42 Reader* obtainReaderInternal(Client*) override = 0; |
| 43 }; |
| 44 |
| 45 } // namespace blink |
| 46 |
| 47 #endif // FetchDataConsumerHandle_h |
| OLD | NEW |