| Index: ppapi/shared_impl/io_stream_shared.h
|
| diff --git a/ppapi/shared_impl/io_stream_shared.h b/ppapi/shared_impl/io_stream_shared.h
|
| new file mode 100644
|
| index 0000000000000000000000000000000000000000..8b98e2cd6b28507765debc77c4932841b6a94ca8
|
| --- /dev/null
|
| +++ b/ppapi/shared_impl/io_stream_shared.h
|
| @@ -0,0 +1,84 @@
|
| +// Copyright (c) 2014 The Chromium Authors. All rights reserved.
|
| +// Use of this source code is governed by a BSD-style license that can be
|
| +// found in the LICENSE file.
|
| +
|
| +#ifndef PPAPI_SHARED_IMPL_IO_STREAM_SHARED_H_
|
| +#define PPAPI_SHARED_IMPL_IO_STREAM_SHARED_H_
|
| +
|
| +#include "base/basictypes.h"
|
| +#include "base/memory/scoped_ptr.h"
|
| +#include "base/memory/shared_memory.h"
|
| +#include "ppapi/shared_impl/circular_buffer.h"
|
| +#include "ppapi/shared_impl/ppapi_shared_export.h"
|
| +
|
| +namespace ppapi {
|
| +
|
| +class CircularBuffer;
|
| +
|
| +class PPAPI_SHARED_EXPORT IOStreamShared {
|
| + public:
|
| + int32_t Write(const void* buffer, uint32_t size);
|
| +
|
| + int32_t WriteAll(const void* buffer, uint32_t size);
|
| +
|
| + int32_t Read(void* buffer, uint32_t size);
|
| +
|
| + int32_t ReadAll(void* buffer, uint32_t size);
|
| +
|
| + int32_t Lock(void** buffer, uint32_t size);
|
| +
|
| + int32_t Relock(void* buffer, uint32_t size);
|
| +
|
| + int32_t Unlock(void* buffer);
|
| +
|
| + uint32_t remaining() const;
|
| +
|
| + bool is_input() { return is_input_; }
|
| +
|
| + const base::SharedMemory* shared_memory() const {
|
| + return shm_.get();
|
| + }
|
| +
|
| + protected:
|
| + IOStreamShared(bool is_input);
|
| +
|
| + virtual ~IOStreamShared();
|
| +
|
| + // Set the underlying shared memory.
|
| + int32_t SetBuffer(scoped_ptr<base::SharedMemory> shm, uint32_t size);
|
| +
|
| + // Subclass uses this function to move the limit position of the
|
| + // |circular_buffer_|.
|
| + void MoveLimit(uint32_t offset);
|
| +
|
| + // Subclass may overridden this function to receive notification when
|
| + // more buffer is available.
|
| + virtual void OnMoreBufferAvailable();
|
| +
|
| + private:
|
| + // Move limit position at the another peer of an IOStream pair.
|
| + // Subclass should send IPC message to the another peer to move the limit
|
| + // position.
|
| + virtual void MovePeerLimit(uint32_t offset) = 0;
|
| +
|
| + // True if it is an input peer of an IO stream, otherwise it is an output peer
|
| + // of an IO stream.
|
| + bool is_input_;
|
| +
|
| + // Shared memory.
|
| + scoped_ptr<base::SharedMemory> shm_;
|
| +
|
| + // A new shared memory will be used to replace the existing |shm_|.
|
| + scoped_ptr<base::SharedMemory> shm_new_;
|
| +
|
| + // Circular buffer
|
| + scoped_ptr<CircularBuffer> circular_buffer_;
|
| +
|
| + scoped_ptr<CircularBuffer> circular_buffer_new_;
|
| +
|
| + DISALLOW_COPY_AND_ASSIGN(IOStreamShared);
|
| +};
|
| +
|
| +} // namespace ppapi
|
| +
|
| +#endif // PPAPI_SHARED_IMPL_IO_STREAM_SHARED_H_
|
|
|