| OLD | NEW |
| 1 // Copyright 2015 The Chromium Authors. All rights reserved. | 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 | 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_SHARED_MEMORY_DATA_CONSUMER_HANDLE_H_ | 5 #ifndef CONTENT_CHILD_SHARED_MEMORY_DATA_CONSUMER_HANDLE_H_ |
| 6 #define CONTENT_CHILD_SHARED_MEMORY_DATA_CONSUMER_HANDLE_H_ | 6 #define CONTENT_CHILD_SHARED_MEMORY_DATA_CONSUMER_HANDLE_H_ |
| 7 | 7 |
| 8 #include "base/callback.h" |
| 8 #include "base/memory/ref_counted.h" | 9 #include "base/memory/ref_counted.h" |
| 9 #include "base/memory/scoped_ptr.h" | 10 #include "base/memory/scoped_ptr.h" |
| 10 #include "content/common/content_export.h" | 11 #include "content/common/content_export.h" |
| 11 #include "content/public/child/request_peer.h" | 12 #include "content/public/child/request_peer.h" |
| 12 #include "third_party/WebKit/public/platform/WebDataConsumerHandle.h" | 13 #include "third_party/WebKit/public/platform/WebDataConsumerHandle.h" |
| 13 | 14 |
| 14 namespace content { | 15 namespace content { |
| 15 | 16 |
| 16 // This class is a WebDataConsumerHandle that accepts RequestPeer::ReceivedData. | 17 // This class is a WebDataConsumerHandle that accepts RequestPeer::ReceivedData. |
| 17 class CONTENT_EXPORT SharedMemoryDataConsumerHandle final | 18 class CONTENT_EXPORT SharedMemoryDataConsumerHandle final |
| (...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 50 virtual Result read(void* data, size_t size, Flags flags, size_t* readSize); | 51 virtual Result read(void* data, size_t size, Flags flags, size_t* readSize); |
| 51 virtual Result beginRead(const void** buffer, | 52 virtual Result beginRead(const void** buffer, |
| 52 Flags flags, | 53 Flags flags, |
| 53 size_t* available); | 54 size_t* available); |
| 54 virtual Result endRead(size_t readSize); | 55 virtual Result endRead(size_t readSize); |
| 55 | 56 |
| 56 private: | 57 private: |
| 57 scoped_refptr<Context> context_; | 58 scoped_refptr<Context> context_; |
| 58 | 59 |
| 59 DISALLOW_COPY_AND_ASSIGN(ReaderImpl); | 60 DISALLOW_COPY_AND_ASSIGN(ReaderImpl); |
| 60 }; | 61 }; |
| 61 | 62 |
| 63 // Creates a handle and a writer associated with the handle. The created |
| 64 // writer should be used on the calling thread. |
| 62 SharedMemoryDataConsumerHandle(BackpressureMode mode, | 65 SharedMemoryDataConsumerHandle(BackpressureMode mode, |
| 63 scoped_ptr<Writer>* writer); | 66 scoped_ptr<Writer>* writer); |
| 67 // |on_reader_detached| will be called aynchronously on the calling thread |
| 68 // when the reader (including the handle) is detached (i.e. both the handle |
| 69 // and the reader are destructed). The callback will be reset in the internal |
| 70 // context when the writer is detached, i.e. |Close| or |Fail| is called, |
| 71 // and the callback will never be called. |
| 72 SharedMemoryDataConsumerHandle(BackpressureMode mode, |
| 73 const base::Closure& on_reader_detached, |
| 74 scoped_ptr<Writer>* writer); |
| 64 virtual ~SharedMemoryDataConsumerHandle(); | 75 virtual ~SharedMemoryDataConsumerHandle(); |
| 65 | 76 |
| 66 scoped_ptr<Reader> ObtainReader(Client* client); | 77 scoped_ptr<Reader> ObtainReader(Client* client); |
| 67 | 78 |
| 68 private: | 79 private: |
| 69 virtual ReaderImpl* obtainReaderInternal(Client* client); | 80 virtual ReaderImpl* obtainReaderInternal(Client* client); |
| 70 const char* debugName() const override; | 81 const char* debugName() const override; |
| 71 | 82 |
| 72 scoped_refptr<Context> context_; | 83 scoped_refptr<Context> context_; |
| 73 | 84 |
| 74 DISALLOW_COPY_AND_ASSIGN(SharedMemoryDataConsumerHandle); | 85 DISALLOW_COPY_AND_ASSIGN(SharedMemoryDataConsumerHandle); |
| 75 }; | 86 }; |
| 76 | 87 |
| 77 } // namespace content | 88 } // namespace content |
| 78 | 89 |
| 79 #endif // CONTENT_CHILD_SHARED_MEMORY_DATA_CONSUMER_HANDLE_H_ | 90 #endif // CONTENT_CHILD_SHARED_MEMORY_DATA_CONSUMER_HANDLE_H_ |
| OLD | NEW |