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

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

Issue 954643002: Update mojo sdk to rev 3d23dae011859a2aae49f1d1adde705c8e85d819 (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: use run_renderer_in_process() Created 5 years, 9 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 // Base class/interface for classes that "implement" |DataPipe| for various
24 // situations (local versus remote). The methods, other than the constructor,
25 // |set_owner()|, and the destructor, are always protected by |DataPipe|'s
26 // |lock_|.
27 class MOJO_SYSTEM_IMPL_EXPORT DataPipeImpl {
28 public:
29 virtual ~DataPipeImpl() {}
30
31 // This is only called by |DataPipe| during its construction.
32 void set_owner(DataPipe* owner) { owner_ = owner; }
33
34 virtual void ProducerClose() = 0;
35 // |num_bytes.Get()| will be a nonzero multiple of |element_num_bytes()|.
36 virtual MojoResult ProducerWriteData(UserPointer<const void> elements,
37 UserPointer<uint32_t> num_bytes,
38 uint32_t max_num_bytes_to_write,
39 uint32_t min_num_bytes_to_write) = 0;
40 virtual MojoResult ProducerBeginWriteData(
41 UserPointer<void*> buffer,
42 UserPointer<uint32_t> buffer_num_bytes,
43 uint32_t min_num_bytes_to_write) = 0;
44 virtual MojoResult ProducerEndWriteData(uint32_t num_bytes_written) = 0;
45 // Note: A producer should not be writable during a two-phase write.
46 virtual HandleSignalsState ProducerGetHandleSignalsState() const = 0;
47 virtual void ProducerStartSerialize(Channel* channel,
48 size_t* max_size,
49 size_t* max_platform_handles) = 0;
50 virtual bool ProducerEndSerialize(
51 Channel* channel,
52 void* destination,
53 size_t* actual_size,
54 embedder::PlatformHandleVector* platform_handles) = 0;
55
56 virtual void ConsumerClose() = 0;
57 // |num_bytes.Get()| will be a nonzero multiple of |element_num_bytes()|.
58 virtual MojoResult ConsumerReadData(UserPointer<void> elements,
59 UserPointer<uint32_t> num_bytes,
60 uint32_t max_num_bytes_to_read,
61 uint32_t min_num_bytes_to_read,
62 bool peek) = 0;
63 virtual MojoResult ConsumerDiscardData(UserPointer<uint32_t> num_bytes,
64 uint32_t max_num_bytes_to_discard,
65 uint32_t min_num_bytes_to_discard) = 0;
66 // |num_bytes.Get()| will be a nonzero multiple of |element_num_bytes()|.
67 virtual MojoResult ConsumerQueryData(UserPointer<uint32_t> num_bytes) = 0;
68 virtual MojoResult ConsumerBeginReadData(
69 UserPointer<const void*> buffer,
70 UserPointer<uint32_t> buffer_num_bytes,
71 uint32_t min_num_bytes_to_read) = 0;
72 virtual MojoResult ConsumerEndReadData(uint32_t num_bytes_read) = 0;
73 // Note: A consumer should not be writable during a two-phase read.
74 virtual HandleSignalsState ConsumerGetHandleSignalsState() const = 0;
75 virtual void ConsumerStartSerialize(Channel* channel,
76 size_t* max_size,
77 size_t* max_platform_handles) = 0;
78 virtual bool ConsumerEndSerialize(
79 Channel* channel,
80 void* destination,
81 size_t* actual_size,
82 embedder::PlatformHandleVector* platform_handles) = 0;
83
84 protected:
85 DataPipeImpl() : owner_() {}
86
87 DataPipe* owner() const { return owner_; }
88
89 bool may_discard() const { return owner_->may_discard(); }
90 size_t element_num_bytes() const { return owner_->element_num_bytes(); }
91 size_t capacity_num_bytes() const { return owner_->capacity_num_bytes(); }
92 bool producer_open() const { return owner_->producer_open_no_lock(); }
93 bool consumer_open() const { return owner_->consumer_open_no_lock(); }
94 uint32_t producer_two_phase_max_num_bytes_written() const {
95 return owner_->producer_two_phase_max_num_bytes_written_no_lock();
96 }
97 uint32_t consumer_two_phase_max_num_bytes_read() const {
98 return owner_->consumer_two_phase_max_num_bytes_read_no_lock();
99 }
100 void set_producer_two_phase_max_num_bytes_written(uint32_t num_bytes) {
101 owner_->set_producer_two_phase_max_num_bytes_written_no_lock(num_bytes);
102 }
103 void set_consumer_two_phase_max_num_bytes_read(uint32_t num_bytes) {
104 owner_->set_consumer_two_phase_max_num_bytes_read_no_lock(num_bytes);
105 }
106 bool producer_in_two_phase_write() const {
107 return owner_->producer_in_two_phase_write_no_lock();
108 }
109 bool consumer_in_two_phase_read() const {
110 return owner_->consumer_in_two_phase_read_no_lock();
111 }
112
113 private:
114 DataPipe* owner_;
115
116 DISALLOW_COPY_AND_ASSIGN(DataPipeImpl);
117 };
118
119 } // namespace system
120 } // namespace mojo
121
122 #endif // MOJO_EDK_SYSTEM_DATA_PIPE_IMPL_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698