Chromium Code Reviews| 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: We assume |AddData| is not called in a client's didGetReadable | |
|
kinuko
2015/06/22 06:39:27
nit: this comment is a bit ambiguous, who's 'we' a
yhirano
2015/06/22 07:08:13
Fixed: Writer assumes that / A caller should ensur
| |
| 33 // callback. There isn't such assumption for |Close| and |Error|. | |
| 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 Error(); | |
|
kinuko
2015/06/22 06:39:27
nit: it's subjective but 'error' sounds more like
yhirano
2015/06/22 07:08:13
Done.
| |
| 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 void LockImplicitly(); | |
| 73 void UnlockImplicitly(); | |
| 74 | 70 |
| 75 scoped_refptr<Context> context_; | 71 scoped_refptr<Context> context_; |
| 76 // This is an implicitly acquired reader for deprecated APIs. | |
| 77 scoped_ptr<Reader> reader_; | |
| 78 | 72 |
| 79 DISALLOW_COPY_AND_ASSIGN(SharedMemoryDataConsumerHandle); | 73 DISALLOW_COPY_AND_ASSIGN(SharedMemoryDataConsumerHandle); |
| 80 }; | 74 }; |
| 81 | 75 |
| 82 } // namespace content | 76 } // namespace content |
| 83 | 77 |
| 84 #endif // CONTENT_CHILD_SHARED_MEMORY_DATA_CONSUMER_HANDLE_H_ | 78 #endif // CONTENT_CHILD_SHARED_MEMORY_DATA_CONSUMER_HANDLE_H_ |
| OLD | NEW |