1 // Copyright 2014 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_WEB_DATA_CONSUMER_HANDLE_IMPL_H_
6 #define CONTENT_CHILD_WEB_DATA_CONSUMER_HANDLE_IMPL_H_
8 #include "base/memory/scoped_ptr.h"
9 #include "content/common/content_export.h"
10 #include "mojo/message_pump/handle_watcher.h"
11 #include "third_party/WebKit/public/platform/WebDataConsumerHandle.h"
12 #include "third_party/mojo/src/mojo/public/cpp/system/data_pipe.h"
16 class CONTENT_EXPORT WebDataConsumerHandleImpl final
17 : public NON_EXPORTED_BASE(blink::WebDataConsumerHandle
) {
18 typedef mojo::ScopedDataPipeConsumerHandle Handle
;
22 class CONTENT_EXPORT ReaderImpl final
: public NON_EXPORTED_BASE(Reader
) {
24 ReaderImpl(scoped_refptr
<Context
> context
, Client
* client
);
25 virtual ~ReaderImpl();
26 virtual Result
read(void* data
, size_t size
, Flags flags
, size_t* readSize
);
27 virtual Result
beginRead(const void** buffer
,
30 virtual Result
endRead(size_t readSize
);
33 Result
HandleReadResult(MojoResult
);
35 void OnHandleGotReadable(MojoResult
);
37 scoped_refptr
<Context
> context_
;
38 mojo::common::HandleWatcher handle_watcher_
;
41 scoped_ptr
<Reader
> ObtainReader(Client
* client
);
43 explicit WebDataConsumerHandleImpl(Handle handle
);
44 virtual ~WebDataConsumerHandleImpl();
47 virtual ReaderImpl
* obtainReaderInternal(Client
* client
);
48 const char* debugName() const override
;
50 scoped_refptr
<Context
> context_
;
53 } // namespace content
55 #endif // CONTENT_CHILD_WEB_DATA_CONSUMER_HANDLE_IMPL_H_