| OLD | NEW |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 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 | 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 CONTENT_CHILD_WEB_DATA_CONSUMER_HANDLE_IMPL_H_ | 5 #ifndef CONTENT_CHILD_WEB_DATA_CONSUMER_HANDLE_IMPL_H_ |
| 6 #define CONTENT_CHILD_WEB_DATA_CONSUMER_HANDLE_IMPL_H_ | 6 #define CONTENT_CHILD_WEB_DATA_CONSUMER_HANDLE_IMPL_H_ |
| 7 | 7 |
| 8 #include <stddef.h> | 8 #include <stddef.h> |
| 9 | 9 |
| 10 #include <memory> | 10 #include <memory> |
| 11 | 11 |
| 12 #include "base/memory/ref_counted.h" |
| 12 #include "content/common/content_export.h" | 13 #include "content/common/content_export.h" |
| 13 #include "mojo/public/cpp/system/data_pipe.h" | 14 #include "mojo/public/cpp/system/data_pipe.h" |
| 14 #include "mojo/public/cpp/system/watcher.h" | 15 #include "mojo/public/cpp/system/watcher.h" |
| 15 #include "third_party/WebKit/public/platform/WebDataConsumerHandle.h" | 16 #include "third_party/WebKit/public/platform/WebDataConsumerHandle.h" |
| 16 | 17 |
| 18 namespace base { |
| 19 class SingleThreadTaskRunner; |
| 20 } |
| 21 |
| 17 namespace content { | 22 namespace content { |
| 18 | 23 |
| 19 class CONTENT_EXPORT WebDataConsumerHandleImpl final | 24 class CONTENT_EXPORT WebDataConsumerHandleImpl final |
| 20 : public NON_EXPORTED_BASE(blink::WebDataConsumerHandle) { | 25 : public NON_EXPORTED_BASE(blink::WebDataConsumerHandle) { |
| 21 typedef mojo::ScopedDataPipeConsumerHandle Handle; | 26 typedef mojo::ScopedDataPipeConsumerHandle Handle; |
| 22 class Context; | 27 class Context; |
| 23 | 28 |
| 24 public: | 29 public: |
| 25 class CONTENT_EXPORT ReaderImpl final : public NON_EXPORTED_BASE(Reader) { | 30 class CONTENT_EXPORT ReaderImpl final : public NON_EXPORTED_BASE(Reader) { |
| 26 public: | 31 public: |
| 27 ReaderImpl(scoped_refptr<Context> context, Client* client); | 32 ReaderImpl(scoped_refptr<Context> context, Client* client, |
| 33 scoped_refptr<base::SingleThreadTaskRunner> task_runner); |
| 28 ~ReaderImpl() override; | 34 ~ReaderImpl() override; |
| 29 Result read(void* data, | 35 Result read(void* data, |
| 30 size_t size, | 36 size_t size, |
| 31 Flags flags, | 37 Flags flags, |
| 32 size_t* readSize) override; | 38 size_t* readSize) override; |
| 33 Result beginRead(const void** buffer, | 39 Result beginRead(const void** buffer, |
| 34 Flags flags, | 40 Flags flags, |
| 35 size_t* available) override; | 41 size_t* available) override; |
| 36 Result endRead(size_t readSize) override; | 42 Result endRead(size_t readSize) override; |
| 37 | 43 |
| 38 private: | 44 private: |
| 39 Result HandleReadResult(MojoResult); | 45 Result HandleReadResult(MojoResult); |
| 40 void StartWatching(); | 46 void StartWatching(); |
| 41 void OnHandleGotReadable(MojoResult); | 47 void OnHandleGotReadable(MojoResult); |
| 42 | 48 |
| 43 scoped_refptr<Context> context_; | 49 scoped_refptr<Context> context_; |
| 44 mojo::Watcher handle_watcher_; | 50 mojo::Watcher handle_watcher_; |
| 45 Client* client_; | 51 Client* client_; |
| 46 }; | 52 }; |
| 47 std::unique_ptr<Reader> obtainReader(Client* client) override; | 53 std::unique_ptr<Reader> obtainReader( |
| 54 Client* client, |
| 55 std::unique_ptr<blink::WebTaskRunner> readerTaskRunner) override; |
| 48 | 56 |
| 49 explicit WebDataConsumerHandleImpl(Handle handle); | 57 explicit WebDataConsumerHandleImpl(Handle handle); |
| 50 ~WebDataConsumerHandleImpl() override; | 58 ~WebDataConsumerHandleImpl() override; |
| 51 | 59 |
| 52 private: | 60 private: |
| 53 const char* debugName() const override; | 61 const char* debugName() const override; |
| 54 | 62 |
| 55 scoped_refptr<Context> context_; | 63 scoped_refptr<Context> context_; |
| 56 }; | 64 }; |
| 57 | 65 |
| 58 } // namespace content | 66 } // namespace content |
| 59 | 67 |
| 60 #endif // CONTENT_CHILD_WEB_DATA_CONSUMER_HANDLE_IMPL_H_ | 68 #endif // CONTENT_CHILD_WEB_DATA_CONSUMER_HANDLE_IMPL_H_ |
| OLD | NEW |