Chromium Code Reviews| OLD | NEW |
|---|---|
| (Empty) | |
| 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 | |
| 3 // found in the LICENSE file. | |
| 4 | |
| 5 #ifndef CONTENT_CHILD_SHARED_MEMORY_DATA_CONSUMER_HANDLE_H_ | |
| 6 #define CONTENT_CHILD_SHARED_MEMORY_DATA_CONSUMER_HANDLE_H_ | |
| 7 | |
| 8 #include "base/memory/ref_counted.h" | |
| 9 #include "base/memory/scoped_ptr.h" | |
| 10 #include "content/common/content_export.h" | |
| 11 #include "content/public/child/request_peer.h" | |
| 12 #include "third_party/WebKit/public/platform/WebDataConsumerHandle.h" | |
| 13 | |
| 14 namespace content { | |
| 15 | |
| 16 // This class is a WebDataConsumerHandle that accepts RequestPeer::ReceivedData. | |
| 17 // TODO(yhirano): Currently this only works on a single thread. Make this class | |
| 18 // work with a multi thread environment. | |
| 19 class CONTENT_EXPORT SharedMemoryDataConsumerHandle final | |
| 20 : public NON_EXPORTED_BASE(blink::WebDataConsumerHandle) { | |
| 21 private: | |
| 22 class Context; | |
|
tyoshino (SeeGerritForStatus)
2015/05/26 08:05:13
any reason to place this not together with the oth
yhirano
2015/05/26 08:19:43
It needs to be declared before Writer.
| |
| 23 | |
| 24 public: | |
| 25 enum BackpressureMode { | |
| 26 kApplyBackpressure, | |
| 27 kDoNotApplyBackpressure, | |
| 28 }; | |
| 29 | |
| 30 class CONTENT_EXPORT Writer final { | |
| 31 public: | |
| 32 Writer(const scoped_refptr<Context>& context, BackpressureMode mode); | |
| 33 ~Writer(); | |
| 34 void AddData(scoped_ptr<RequestPeer::ReceivedData> data); | |
| 35 void Close(); | |
| 36 | |
| 37 private: | |
| 38 scoped_refptr<Context> context_; | |
| 39 BackpressureMode mode_; | |
| 40 | |
| 41 DISALLOW_COPY_AND_ASSIGN(Writer); | |
| 42 }; | |
| 43 | |
| 44 SharedMemoryDataConsumerHandle(BackpressureMode mode, | |
| 45 scoped_ptr<Writer>* writer); | |
| 46 virtual ~SharedMemoryDataConsumerHandle(); | |
| 47 | |
| 48 virtual Result read(void* data, size_t size, Flags flags, size_t* readSize); | |
| 49 virtual Result beginRead(const void** buffer, Flags flags, size_t* available); | |
| 50 virtual Result endRead(size_t readSize); | |
| 51 virtual void registerClient(Client* client); | |
| 52 virtual void unregisterClient(); | |
| 53 | |
| 54 private: | |
| 55 scoped_refptr<Context> context_; | |
| 56 | |
| 57 DISALLOW_COPY_AND_ASSIGN(SharedMemoryDataConsumerHandle); | |
| 58 }; | |
| 59 | |
| 60 } // namespace content | |
| 61 | |
| 62 #endif // CONTENT_CHILD_SHARED_MEMORY_DATA_CONSUMER_HANDLE_H_ | |
| OLD | NEW |