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.
5 #ifndef CONTENT_CHILD_SHARED_MEMORY_DATA_CONSUMER_HANDLE_H_
6 #define CONTENT_CHILD_SHARED_MEMORY_DATA_CONSUMER_HANDLE_H_
8 #include "base/memory/ref_counted.h"
9 #include "base/memory/scoped_ptr.h"
10 #include "content/common/content_export.h"
11 #include "content/public/child/request_peer.h"
12 #include "third_party/WebKit/public/platform/WebDataConsumerHandle.h"
16 // This class is a WebDataConsumerHandle that accepts RequestPeer::ReceivedData.
17 class CONTENT_EXPORT SharedMemoryDataConsumerHandle final
18 : public NON_EXPORTED_BASE(blink::WebDataConsumerHandle
) {
23 enum BackpressureMode
{
25 kDoNotApplyBackpressure
,
28 class CONTENT_EXPORT Writer final
{
30 Writer(const scoped_refptr
<Context
>& context
, BackpressureMode mode
);
32 void AddData(scoped_ptr
<RequestPeer::ReceivedData
> data
);
36 scoped_refptr
<Context
> context_
;
37 BackpressureMode mode_
;
39 DISALLOW_COPY_AND_ASSIGN(Writer
);
42 SharedMemoryDataConsumerHandle(BackpressureMode mode
,
43 scoped_ptr
<Writer
>* writer
);
44 virtual ~SharedMemoryDataConsumerHandle();
46 virtual Result
read(void* data
, size_t size
, Flags flags
, size_t* readSize
);
47 virtual Result
beginRead(const void** buffer
, Flags flags
, size_t* available
);
48 virtual Result
endRead(size_t readSize
);
49 virtual void registerClient(Client
* client
);
50 virtual void unregisterClient();
53 scoped_refptr
<Context
> context_
;
55 DISALLOW_COPY_AND_ASSIGN(SharedMemoryDataConsumerHandle
);
58 } // namespace content
60 #endif // CONTENT_CHILD_SHARED_MEMORY_DATA_CONSUMER_HANDLE_H_