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

Side by Side Diff: mojo/edk/system/data_pipe_impl.h

Issue 926553006: Make DataPipe own an impl. (Closed) Base URL: https://github.com/domokit/mojo.git@local_data_pipe_impl_1
Patch Set: rebased Created 5 years, 10 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 2015 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 MOJO_EDK_SYSTEM_DATA_PIPE_IMPL_H_
6 #define MOJO_EDK_SYSTEM_DATA_PIPE_IMPL_H_
7
8 #include <stdint.h>
9
10 #include "base/macros.h"
11 #include "mojo/edk/embedder/platform_handle_vector.h"
12 #include "mojo/edk/system/data_pipe.h"
13 #include "mojo/edk/system/handle_signals_state.h"
14 #include "mojo/edk/system/memory.h"
15 #include "mojo/edk/system/system_impl_export.h"
16 #include "mojo/public/c/system/types.h"
17
18 namespace mojo {
19 namespace system {
20
21 class Channel;
22
23 class MOJO_SYSTEM_IMPL_EXPORT DataPipeImpl {
yzshen1 2015/02/19 18:27:11 Does it make sense to have comment talk about how
viettrungluu 2015/02/19 19:08:46 Done.
24 public:
25 virtual ~DataPipeImpl() {}
26
27 void set_owner(DataPipe* owner) { owner_ = owner; }
28
29 virtual void ProducerClose() = 0;
30 // |num_bytes.Get()| will be a nonzero multiple of |element_num_bytes_|.
yzshen1 2015/02/19 18:27:11 nit: there isn't a |element_num_bytes_| defined in
viettrungluu 2015/02/19 19:08:46 Done (elsewhere too, obviously).
31 virtual MojoResult ProducerWriteData(UserPointer<const void> elements,
32 UserPointer<uint32_t> num_bytes,
33 uint32_t max_num_bytes_to_write,
34 uint32_t min_num_bytes_to_write) = 0;
35 virtual MojoResult ProducerBeginWriteData(
36 UserPointer<void*> buffer,
37 UserPointer<uint32_t> buffer_num_bytes,
38 uint32_t min_num_bytes_to_write) = 0;
39 virtual MojoResult ProducerEndWriteData(uint32_t num_bytes_written) = 0;
40 // Note: A producer should not be writable during a two-phase write.
41 virtual HandleSignalsState ProducerGetHandleSignalsState() const = 0;
42 virtual void ProducerStartSerialize(Channel* channel,
43 size_t* max_size,
44 size_t* max_platform_handles) = 0;
45 virtual bool ProducerEndSerialize(
46 Channel* channel,
47 void* destination,
48 size_t* actual_size,
49 embedder::PlatformHandleVector* platform_handles) = 0;
50
51 virtual void ConsumerClose() = 0;
52 // |*num_bytes| will be a nonzero multiple of |element_num_bytes_|.
53 virtual MojoResult ConsumerReadData(UserPointer<void> elements,
54 UserPointer<uint32_t> num_bytes,
55 uint32_t max_num_bytes_to_read,
56 uint32_t min_num_bytes_to_read,
57 bool peek) = 0;
58 virtual MojoResult ConsumerDiscardData(UserPointer<uint32_t> num_bytes,
59 uint32_t max_num_bytes_to_discard,
60 uint32_t min_num_bytes_to_discard) = 0;
61 // |*num_bytes| will be a nonzero multiple of |element_num_bytes_|.
62 virtual MojoResult ConsumerQueryData(UserPointer<uint32_t> num_bytes) = 0;
63 virtual MojoResult ConsumerBeginReadData(
64 UserPointer<const void*> buffer,
65 UserPointer<uint32_t> buffer_num_bytes,
66 uint32_t min_num_bytes_to_read) = 0;
67 virtual MojoResult ConsumerEndReadData(uint32_t num_bytes_read) = 0;
68 // Note: A consumer should not be writable during a two-phase read.
69 virtual HandleSignalsState ConsumerGetHandleSignalsState() const = 0;
70 virtual void ConsumerStartSerialize(Channel* channel,
71 size_t* max_size,
72 size_t* max_platform_handles) = 0;
73 virtual bool ConsumerEndSerialize(
74 Channel* channel,
75 void* destination,
76 size_t* actual_size,
77 embedder::PlatformHandleVector* platform_handles) = 0;
78
79 protected:
80 DataPipeImpl() : owner_() {}
81
82 DataPipe* owner() const { return owner_; }
83
84 bool may_discard() const { return owner_->may_discard(); }
85 size_t element_num_bytes() const { return owner_->element_num_bytes(); }
86 size_t capacity_num_bytes() const { return owner_->capacity_num_bytes(); }
87 bool producer_open() const { return owner_->producer_open_no_lock(); }
88 bool consumer_open() const { return owner_->consumer_open_no_lock(); }
89 uint32_t producer_two_phase_max_num_bytes_written() const {
90 return owner_->producer_two_phase_max_num_bytes_written_no_lock();
91 }
92 uint32_t consumer_two_phase_max_num_bytes_read() const {
93 return owner_->consumer_two_phase_max_num_bytes_read_no_lock();
94 }
95 void set_producer_two_phase_max_num_bytes_written(uint32_t num_bytes) {
96 owner_->set_producer_two_phase_max_num_bytes_written_no_lock(num_bytes);
97 }
98 void set_consumer_two_phase_max_num_bytes_read(uint32_t num_bytes) {
99 owner_->set_consumer_two_phase_max_num_bytes_read_no_lock(num_bytes);
100 }
101 bool producer_in_two_phase_write() const {
102 return owner_->producer_in_two_phase_write_no_lock();
103 }
104 bool consumer_in_two_phase_read() const {
105 return owner_->consumer_in_two_phase_read_no_lock();
106 }
107
108 private:
109 DataPipe* owner_;
110
111 DISALLOW_COPY_AND_ASSIGN(DataPipeImpl);
112 };
113
114 } // namespace system
115 } // namespace mojo
116
117 #endif // MOJO_EDK_SYSTEM_DATA_PIPE_IMPL_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698