Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(502)

Unified Diff: ppapi/shared_impl/io_stream_shared.h

Issue 119853003: [PPAPI] Implement an IOStreamResource for data transmission between plugin and renderer. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Update Created 7 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
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..9362270cd0f1f84713b16891b03f3eb6514fac04
--- /dev/null
+++ b/ppapi/shared_impl/io_stream_shared.h
@@ -0,0 +1,85 @@
+// 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.
+// 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_SHAERD_H_
bbudge 2013/12/31 00:51:53 s/SHAERD_H/SHARED_H
Peng 2013/12/31 23:33:54 Done.
+#define PPAPI_SHARED_IMPL_IO_STREAM_SHAERD_H_
+
+#include "base/basictypes.h"
+#include "base/memory/scoped_ptr.h"
+#include "base/memory/shared_memory.h"
+#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.
+#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 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.
+
+ 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.
+ return shm_;
+ }
+
+ protected:
+ IOStreamShared(bool 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 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_;
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
+
+ DISALLOW_COPY_AND_ASSIGN(IOStreamShared);
+};
+
+} // namespace ppapi
+
+#endif // PPAPI_SHARED_IMPL_IO_STREAM_SHAERD_H_

Powered by Google App Engine
This is Rietveld 408576698