Chromium Code Reviews| OLD | NEW |
|---|---|
| (Empty) | |
| 1 // Copyright (c) 2014 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 PPAPI_SHARED_IMPL_IO_STREAM_SHARED_H_ | |
| 6 #define PPAPI_SHARED_IMPL_IO_STREAM_SHARED_H_ | |
| 7 | |
| 8 #include "base/basictypes.h" | |
| 9 #include "base/memory/scoped_ptr.h" | |
| 10 #include "base/memory/shared_memory.h" | |
| 11 #include "ppapi/shared_impl/circular_buffer.h" | |
| 12 #include "ppapi/shared_impl/ppapi_shared_export.h" | |
| 13 | |
| 14 namespace ppapi { | |
| 15 | |
| 16 class CircularBuffer; | |
| 17 | |
| 18 class PPAPI_SHARED_EXPORT IOStreamShared { | |
|
dmichael (off chromium)
2014/01/03 18:05:29
Would it make sense at all to not have this as a b
yzshen1
2014/01/03 21:51:41
I like the idea of making it "part of" a resource.
| |
| 19 public: | |
| 20 int32_t Write(const void* buffer, uint32_t size); | |
|
yzshen1
2014/01/03 21:51:41
The int32_t and uint32_t mismatch is a little bit
| |
| 21 | |
| 22 int32_t WriteAll(const void* buffer, uint32_t size); | |
| 23 | |
| 24 int32_t Read(void* buffer, uint32_t size); | |
| 25 | |
| 26 int32_t ReadAll(void* buffer, uint32_t size); | |
| 27 | |
| 28 int32_t Lock(void** buffer, uint32_t size); | |
| 29 | |
| 30 int32_t Relock(void* buffer, uint32_t size); | |
| 31 | |
| 32 int32_t Unlock(void* buffer); | |
| 33 | |
| 34 uint32_t remaining() const; | |
| 35 | |
| 36 bool is_input() const { return is_input_; } | |
| 37 | |
| 38 const base::SharedMemory* shared_memory() const { | |
| 39 return shm_.get(); | |
| 40 } | |
| 41 | |
| 42 protected: | |
| 43 IOStreamShared(bool is_input); | |
|
dmichael (off chromium)
2014/01/03 18:05:29
nit: explicit
| |
| 44 | |
| 45 virtual ~IOStreamShared(); | |
| 46 | |
| 47 // Set the underlying shared memory buffer. If IOStreamShared has a buffer | |
|
yzshen1
2014/01/03 21:51:41
Set*s*
| |
| 48 // set by |SetBUffer()|, the old buffer will be replaced. | |
|
yzshen1
2014/01/03 21:51:41
SetB*u*ffer
| |
| 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 | |
|
dmichael (off chromium)
2014/01/03 18:05:29
overridden->override?
| |
| 56 // more buffer is available. | |
| 57 virtual void OnMoreBufferAvailable(); | |
| 58 | |
| 59 private: | |
| 60 // Move limit position at the another peer of an IOStream pair. | |
|
dmichael (off chromium)
2014/01/03 18:05:29
I can't parse this sentence. Maybe you meant "at t
| |
| 61 // Subclass should send IPC message to the another peer to move the limit | |
|
dmichael (off chromium)
2014/01/03 18:05:29
^^ here, too
| |
| 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. | |
|
dmichael (off chromium)
2014/01/03 18:05:29
What does input mean here? For reading?
Also, the
| |
| 67 bool is_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_; | |
|
dmichael (off chromium)
2014/01/03 18:05:29
This feels awkward to have the real shmem/circular
yzshen1
2014/01/03 21:51:41
+1!
I understand you did this for changing buffer
| |
| 79 | |
| 80 DISALLOW_COPY_AND_ASSIGN(IOStreamShared); | |
| 81 }; | |
| 82 | |
| 83 } // namespace ppapi | |
| 84 | |
| 85 #endif // PPAPI_SHARED_IMPL_IO_STREAM_SHARED_H_ | |
| OLD | NEW |