Chromium Code Reviews| OLD | NEW |
|---|---|
| (Empty) | |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | |
|
bbudge
2013/12/31 00:51:53
s/2012/2013
Peng
2013/12/31 23:33:54
Done.
| |
| 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 PPAPI_SHARED_IMPL_IO_STREAM_SHAERD_H_ | |
|
bbudge
2013/12/31 00:51:53
s/SHAERD_H/SHARED_H
Peng
2013/12/31 23:33:54
Done.
| |
| 6 #define PPAPI_SHARED_IMPL_IO_STREAM_SHAERD_H_ | |
| 7 | |
| 8 #include "base/basictypes.h" | |
| 9 #include "base/memory/scoped_ptr.h" | |
| 10 #include "base/memory/shared_memory.h" | |
| 11 #include "base/memory/weak_ptr.h" | |
|
bbudge
2013/12/31 00:51:53
I don't think this is needed.
Peng
2013/12/31 23:33:54
Done.
| |
| 12 #include "ppapi/shared_impl/circular_buffer.h" | |
| 13 #include "ppapi/shared_impl/ppapi_shared_export.h" | |
| 14 | |
| 15 namespace ppapi { | |
| 16 | |
| 17 class CircularBuffer; | |
| 18 | |
| 19 class PPAPI_SHARED_EXPORT IOStreamShared { | |
| 20 public: | |
| 21 int32_t Write(const void* buffer, uint32_t size); | |
| 22 | |
| 23 int32_t WriteAll(const void* buffer, uint32_t size); | |
| 24 | |
| 25 int32_t Read(void* buffer, uint32_t size); | |
| 26 | |
| 27 int32_t ReadAll(void* buffer, uint32_t size); | |
| 28 | |
| 29 int32_t Lock(void** buffer, uint32_t size); | |
| 30 | |
| 31 int32_t Relock(void* buffer, uint32_t size); | |
| 32 | |
| 33 int32_t Unlock(void* buffer); | |
| 34 | |
| 35 uint32_t remaining() const; | |
| 36 | |
| 37 bool input() { return input_; } | |
|
bbudge
2013/12/31 00:51:53
I think it would be clearer to call this is_input(
Peng
2013/12/31 23:33:54
Done.
| |
| 38 | |
| 39 const scoped_ptr<base::SharedMemory>& shared_memory() const { | |
|
bbudge
2013/12/31 00:51:53
It seems dangerous to return a ref to our scoped_p
Peng
2013/12/31 23:33:54
Done.
| |
| 40 return shm_; | |
| 41 } | |
| 42 | |
| 43 protected: | |
| 44 IOStreamShared(bool input); | |
| 45 | |
| 46 virtual ~IOStreamShared(); | |
| 47 | |
| 48 // Set the underlying shared memory. | |
| 49 int32_t SetBuffer(scoped_ptr<base::SharedMemory> shm, uint32_t size); | |
| 50 | |
| 51 // Subclass uses this function to move the limit position of the | |
| 52 // |circular_buffer_|. | |
| 53 void MoveLimit(uint32_t offset); | |
| 54 | |
| 55 // Subclass may overridden this function to receive notification when | |
| 56 // more buffer is available. | |
| 57 virtual void OnMoreBufferAvailable(); | |
| 58 | |
| 59 private: | |
| 60 // Move limit position at the another peer of an IOStream pair. | |
| 61 // Subclass should send IPC message to the another peer to move the limit | |
| 62 // position. | |
| 63 virtual void MovePeerLimit(uint32_t offset) = 0; | |
| 64 | |
| 65 // True if it is an input peer of an IO stream, otherwise it is an output peer | |
| 66 // of an IO stream. | |
| 67 bool input_; | |
| 68 | |
| 69 // Shared memory. | |
| 70 scoped_ptr<base::SharedMemory> shm_; | |
| 71 | |
| 72 // A new shared memory will be used to replace the existing |shm_|. | |
| 73 scoped_ptr<base::SharedMemory> shm_new_; | |
| 74 | |
| 75 // Circular buffer | |
| 76 scoped_ptr<CircularBuffer> circular_buffer_; | |
| 77 | |
| 78 scoped_ptr<CircularBuffer> circular_buffer_new_; | |
|
bbudge
2013/12/31 00:51:53
I think you could get away with just having one Ci
Peng
2013/12/31 23:33:54
I use two circular_buffers because when a new shar
bbudge
2014/01/02 18:51:43
I'm suggesting that when SetBuffer is called, but
| |
| 79 | |
| 80 DISALLOW_COPY_AND_ASSIGN(IOStreamShared); | |
| 81 }; | |
| 82 | |
| 83 } // namespace ppapi | |
| 84 | |
| 85 #endif // PPAPI_SHARED_IMPL_IO_STREAM_SHAERD_H_ | |
| OLD | NEW |