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

Side by Side Diff: mojo/public/cpp/bindings/lib/connector.h

Issue 2064903002: Mojo: Report bindings validation errors via MojoNotifyBadMessage (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: . Created 4 years, 6 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
1 // Copyright 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #ifndef MOJO_PUBLIC_CPP_BINDINGS_LIB_CONNECTOR_H_ 5 #ifndef MOJO_PUBLIC_CPP_BINDINGS_LIB_CONNECTOR_H_
6 #define MOJO_PUBLIC_CPP_BINDINGS_LIB_CONNECTOR_H_ 6 #define MOJO_PUBLIC_CPP_BINDINGS_LIB_CONNECTOR_H_
7 7
8 #include <memory> 8 #include <memory>
9 9
10 #include "base/memory/ref_counted.h" 10 #include "base/memory/ref_counted.h"
(...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after
92 // Enters the error state. The upper layer may do this for unrecoverable 92 // Enters the error state. The upper layer may do this for unrecoverable
93 // issues such as invalid messages are received. If a connection error handler 93 // issues such as invalid messages are received. If a connection error handler
94 // has been set, it will be called asynchronously. 94 // has been set, it will be called asynchronously.
95 // 95 //
96 // It is a no-op if the connector is already in the error state or there isn't 96 // It is a no-op if the connector is already in the error state or there isn't
97 // a bound message pipe. Otherwise, it closes the message pipe, which notifies 97 // a bound message pipe. Otherwise, it closes the message pipe, which notifies
98 // the other end and also prevents potential danger (say, the caller raises 98 // the other end and also prevents potential danger (say, the caller raises
99 // an error because it believes the other end is malicious). In order to 99 // an error because it believes the other end is malicious). In order to
100 // appear to the user that the connector still binds to a message pipe, it 100 // appear to the user that the connector still binds to a message pipe, it
101 // creates a new message pipe, closes one end and binds to the other. 101 // creates a new message pipe, closes one end and binds to the other.
102 void RaiseError(); 102 void RaiseError(Result error);
103 103
104 // Is the connector bound to a MessagePipe handle? 104 // Is the connector bound to a MessagePipe handle?
105 bool is_valid() const { 105 bool is_valid() const {
106 DCHECK(thread_checker_.CalledOnValidThread()); 106 DCHECK(thread_checker_.CalledOnValidThread());
107 return message_pipe_.is_valid(); 107 return message_pipe_.is_valid();
108 } 108 }
109 109
110 // Waits for the next message on the pipe, blocking until one arrives, 110 // Waits for the next message on the pipe, blocking until one arrives,
111 // |deadline| elapses, or an error happens. Returns |true| if a message has 111 // |deadline| elapses, or an error happens. Returns |true| if a message has
112 // been delivered, |false| otherwise. 112 // been delivered, |false| otherwise.
113 bool WaitForIncomingMessage(MojoDeadline deadline); 113 bool WaitForIncomingMessage(MojoDeadline deadline);
114 114
115 // See Binding for details of pause/resume. 115 // See Binding for details of pause/resume.
116 void PauseIncomingMethodCallProcessing(); 116 void PauseIncomingMethodCallProcessing();
117 void ResumeIncomingMethodCallProcessing(); 117 void ResumeIncomingMethodCallProcessing();
118 118
119 // MessageReceiver implementation: 119 // MessageReceiver implementation:
120 bool Accept(Message* message) override; 120 Result Accept(Message* message) override;
121 121
122 MessagePipeHandle handle() const { 122 MessagePipeHandle handle() const {
123 DCHECK(thread_checker_.CalledOnValidThread()); 123 DCHECK(thread_checker_.CalledOnValidThread());
124 return message_pipe_.get(); 124 return message_pipe_.get();
125 } 125 }
126 126
127 // Allows |message_pipe_| to be watched while others perform sync handle 127 // Allows |message_pipe_| to be watched while others perform sync handle
128 // watching on the same thread. Please see comments of 128 // watching on the same thread. Please see comments of
129 // SyncHandleWatcher::AllowWokenUpBySyncWatchOnSameThread(). 129 // SyncHandleWatcher::AllowWokenUpBySyncWatchOnSameThread().
130 void AllowWokenUpBySyncWatchOnSameThread(); 130 void AllowWokenUpBySyncWatchOnSameThread();
(...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after
204 base::WeakPtr<Connector> weak_self_; 204 base::WeakPtr<Connector> weak_self_;
205 base::WeakPtrFactory<Connector> weak_factory_; 205 base::WeakPtrFactory<Connector> weak_factory_;
206 206
207 DISALLOW_COPY_AND_ASSIGN(Connector); 207 DISALLOW_COPY_AND_ASSIGN(Connector);
208 }; 208 };
209 209
210 } // namespace internal 210 } // namespace internal
211 } // namespace mojo 211 } // namespace mojo
212 212
213 #endif // MOJO_PUBLIC_CPP_BINDINGS_LIB_CONNECTOR_H_ 213 #endif // MOJO_PUBLIC_CPP_BINDINGS_LIB_CONNECTOR_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698