| 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/memory/ref_counted.h" | 8 #include "base/memory/ref_counted.h" |
| 9 #include "base/memory/scoped_ptr.h" | 9 #include "base/memory/scoped_ptr.h" |
| 10 #include "content/common/content_export.h" | 10 #include "content/common/content_export.h" |
| (...skipping 11 matching lines...) Expand all Loading... |
| 22 public: | 22 public: |
| 23 enum BackpressureMode { | 23 enum BackpressureMode { |
| 24 kApplyBackpressure, | 24 kApplyBackpressure, |
| 25 kDoNotApplyBackpressure, | 25 kDoNotApplyBackpressure, |
| 26 }; | 26 }; |
| 27 | 27 |
| 28 class CONTENT_EXPORT Writer final { | 28 class CONTENT_EXPORT Writer final { |
| 29 public: | 29 public: |
| 30 Writer(const scoped_refptr<Context>& context, BackpressureMode mode); | 30 Writer(const scoped_refptr<Context>& context, BackpressureMode mode); |
| 31 ~Writer(); | 31 ~Writer(); |
| 32 // Note: Writer assumes |AddData| is not called in a client's didGetReadable |
| 33 // callback. There isn't such assumption for |Close| and |Fail|. |
| 32 void AddData(scoped_ptr<RequestPeer::ReceivedData> data); | 34 void AddData(scoped_ptr<RequestPeer::ReceivedData> data); |
| 33 void Close(); | 35 void Close(); |
| 36 // TODO(yhirano): Consider providing error code. |
| 37 void Fail(); |
| 34 | 38 |
| 35 private: | 39 private: |
| 36 scoped_refptr<Context> context_; | 40 scoped_refptr<Context> context_; |
| 37 BackpressureMode mode_; | 41 BackpressureMode mode_; |
| 38 | 42 |
| 39 DISALLOW_COPY_AND_ASSIGN(Writer); | 43 DISALLOW_COPY_AND_ASSIGN(Writer); |
| 40 }; | 44 }; |
| 41 | 45 |
| 42 class ReaderImpl final : public Reader { | 46 class ReaderImpl final : public Reader { |
| 43 public: | 47 public: |
| (...skipping 10 matching lines...) Expand all Loading... |
| 54 | 58 |
| 55 DISALLOW_COPY_AND_ASSIGN(ReaderImpl); | 59 DISALLOW_COPY_AND_ASSIGN(ReaderImpl); |
| 56 }; | 60 }; |
| 57 | 61 |
| 58 SharedMemoryDataConsumerHandle(BackpressureMode mode, | 62 SharedMemoryDataConsumerHandle(BackpressureMode mode, |
| 59 scoped_ptr<Writer>* writer); | 63 scoped_ptr<Writer>* writer); |
| 60 virtual ~SharedMemoryDataConsumerHandle(); | 64 virtual ~SharedMemoryDataConsumerHandle(); |
| 61 | 65 |
| 62 scoped_ptr<Reader> ObtainReader(Client* client); | 66 scoped_ptr<Reader> ObtainReader(Client* client); |
| 63 | 67 |
| 64 virtual Result read(void* data, size_t size, Flags flags, size_t* readSize); | |
| 65 virtual Result beginRead(const void** buffer, Flags flags, size_t* available); | |
| 66 virtual Result endRead(size_t readSize); | |
| 67 virtual void registerClient(Client* client); | |
| 68 virtual void unregisterClient(); | |
| 69 | |
| 70 private: | 68 private: |
| 71 virtual ReaderImpl* obtainReaderInternal(Client* client); | 69 virtual ReaderImpl* obtainReaderInternal(Client* client); |
| 72 const char* debugName() const override; | 70 const char* debugName() const override; |
| 73 void LockImplicitly(); | |
| 74 void UnlockImplicitly(); | |
| 75 | 71 |
| 76 scoped_refptr<Context> context_; | 72 scoped_refptr<Context> context_; |
| 77 // This is an implicitly acquired reader for deprecated APIs. | |
| 78 scoped_ptr<Reader> reader_; | |
| 79 | 73 |
| 80 DISALLOW_COPY_AND_ASSIGN(SharedMemoryDataConsumerHandle); | 74 DISALLOW_COPY_AND_ASSIGN(SharedMemoryDataConsumerHandle); |
| 81 }; | 75 }; |
| 82 | 76 |
| 83 } // namespace content | 77 } // namespace content |
| 84 | 78 |
| 85 #endif // CONTENT_CHILD_SHARED_MEMORY_DATA_CONSUMER_HANDLE_H_ | 79 #endif // CONTENT_CHILD_SHARED_MEMORY_DATA_CONSUMER_HANDLE_H_ |
| OLD | NEW |