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

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

Issue 1176243004: Add FetchDataConsumerHandle and utility functions/classes (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Build break fix. Created 5 years, 6 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
« no previous file with comments | « Source/modules/fetch/DataConsumerHandleUtilTest.cpp ('k') | Source/modules/modules.gypi » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(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 "platform/blob/BlobData.h"
9 #include "public/platform/WebDataConsumerHandle.h"
10 #include "wtf/Forward.h"
11 #include "wtf/PassRefPtr.h"
12
13 namespace blink {
14
15 // This is an interface class that adds Reader's blobDataHandle() to
16 // WebDataConsumerHandle.
17 // This class works not very well with Oilpan: As this class is not garbage
18 // collected while many clients or related objects may be, it is very easy
19 // to create a reference cycle. When an client is garbage collected, making
20 // the client own the handle is the right way.
21 class FetchDataConsumerHandle : public WebDataConsumerHandle {
22 public:
23 class Reader : public WebDataConsumerHandle::Reader {
24 public:
25 // Drains the data as a BlobDataHandle.
26 // If this function returns non-null BlobDataHandle:
27 // - The bytes that will be read from the returned BlobDataHandle
28 // must be idential to the bytes that would be read through
29 // WebDataConsumerHandle::Reader APIs without calling this function.
30 // - Subsequent calls to read() / beginRead() returns |Done|.
31 // - The returned blob handle has a valid size (i.e. != kuint64max).
32 // This function can return |nullptr|, and in such cases this
33 // functions is no-op.
34 // This function returns |nullptr| when called during two-phase read.
35 virtual PassRefPtr<BlobDataHandle> drainAsBlobDataHandle() { return null ptr; }
36 };
37
38 // TODO(yhirano): obtainReader() is currently non-virtual override, and
39 // will be changed into virtual override when we can use scoped_ptr /
40 // unique_ptr in both Blink and Chromium.
41 PassOwnPtr<Reader> obtainReader(Client* client) { return adoptPtr(obtainRead erInternal(client)); }
42
43 private:
44 Reader* obtainReaderInternal(Client*) override = 0;
45 };
46
47 } // namespace blink
48
49 #endif // FetchDataConsumerHandle_h
OLDNEW
« no previous file with comments | « Source/modules/fetch/DataConsumerHandleUtilTest.cpp ('k') | Source/modules/modules.gypi » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698