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

Side by Side 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 6 years, 11 months 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 unified diff | Download patch
OLDNEW
(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 {
19 public:
20 int32_t Write(const void* buffer, uint32_t size);
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() { return is_input_; }
37
38 const base::SharedMemory* shared_memory() const {
39 return shm_.get();
40 }
41
42 protected:
43 IOStreamShared(bool is_input);
44
45 virtual ~IOStreamShared();
46
47 // Set the underlying shared memory.
48 int32_t SetBuffer(scoped_ptr<base::SharedMemory> shm, uint32_t size);
49
50 // Subclass uses this function to move the limit position of the
51 // |circular_buffer_|.
52 void MoveLimit(uint32_t offset);
53
54 // Subclass may overridden this function to receive notification when
55 // more buffer is available.
56 virtual void OnMoreBufferAvailable();
57
58 private:
59 // Move limit position at the another peer of an IOStream pair.
60 // Subclass should send IPC message to the another peer to move the limit
61 // position.
62 virtual void MovePeerLimit(uint32_t offset) = 0;
63
64 // True if it is an input peer of an IO stream, otherwise it is an output peer
65 // of an IO stream.
66 bool is_input_;
67
68 // Shared memory.
69 scoped_ptr<base::SharedMemory> shm_;
70
71 // A new shared memory will be used to replace the existing |shm_|.
72 scoped_ptr<base::SharedMemory> shm_new_;
73
74 // Circular buffer
75 scoped_ptr<CircularBuffer> circular_buffer_;
76
77 scoped_ptr<CircularBuffer> circular_buffer_new_;
78
79 DISALLOW_COPY_AND_ASSIGN(IOStreamShared);
80 };
81
82 } // namespace ppapi
83
84 #endif // PPAPI_SHARED_IMPL_IO_STREAM_SHARED_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698