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

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"
11 #include "base/memory/weak_ptr.h" 11 #include "base/memory/weak_ptr.h"
12 #include "base/single_thread_task_runner.h" 12 #include "base/single_thread_task_runner.h"
13 #include "base/threading/thread_checker.h" 13 #include "base/threading/thread_checker.h"
14 #include "mojo/public/cpp/bindings/callback.h" 14 #include "mojo/public/cpp/bindings/callback.h"
15 #include "mojo/public/cpp/bindings/error.h"
15 #include "mojo/public/cpp/bindings/lib/sync_handle_watcher.h" 16 #include "mojo/public/cpp/bindings/lib/sync_handle_watcher.h"
16 #include "mojo/public/cpp/bindings/message.h" 17 #include "mojo/public/cpp/bindings/message.h"
17 #include "mojo/public/cpp/system/core.h" 18 #include "mojo/public/cpp/system/core.h"
18 #include "mojo/public/cpp/system/watcher.h" 19 #include "mojo/public/cpp/system/watcher.h"
19 20
20 namespace base { 21 namespace base {
21 class Lock; 22 class Lock;
22 } 23 }
23 24
24 namespace mojo { 25 namespace mojo {
(...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after
92 // Enters the error state. The upper layer may do this for unrecoverable 93 // 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 94 // issues such as invalid messages are received. If a connection error handler
94 // has been set, it will be called asynchronously. 95 // has been set, it will be called asynchronously.
95 // 96 //
96 // It is a no-op if the connector is already in the error state or there isn't 97 // 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 98 // 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 99 // 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 100 // 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 101 // 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. 102 // creates a new message pipe, closes one end and binds to the other.
102 void RaiseError(); 103 void RaiseError(Error error);
103 104
104 // Is the connector bound to a MessagePipe handle? 105 // Is the connector bound to a MessagePipe handle?
105 bool is_valid() const { 106 bool is_valid() const {
106 DCHECK(thread_checker_.CalledOnValidThread()); 107 DCHECK(thread_checker_.CalledOnValidThread());
107 return message_pipe_.is_valid(); 108 return message_pipe_.is_valid();
108 } 109 }
109 110
110 // Waits for the next message on the pipe, blocking until one arrives, 111 // 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 112 // |deadline| elapses, or an error happens. Returns |true| if a message has
112 // been delivered, |false| otherwise. 113 // been delivered, |false| otherwise.
113 bool WaitForIncomingMessage(MojoDeadline deadline); 114 bool WaitForIncomingMessage(MojoDeadline deadline);
114 115
115 // See Binding for details of pause/resume. 116 // See Binding for details of pause/resume.
116 void PauseIncomingMethodCallProcessing(); 117 void PauseIncomingMethodCallProcessing();
117 void ResumeIncomingMethodCallProcessing(); 118 void ResumeIncomingMethodCallProcessing();
118 119
119 // MessageReceiver implementation: 120 // MessageReceiver implementation:
120 bool Accept(Message* message) override; 121 bool Accept(Message* message, Error* error) override;
121 122
122 MessagePipeHandle handle() const { 123 MessagePipeHandle handle() const {
123 DCHECK(thread_checker_.CalledOnValidThread()); 124 DCHECK(thread_checker_.CalledOnValidThread());
124 return message_pipe_.get(); 125 return message_pipe_.get();
125 } 126 }
126 127
127 // Allows |message_pipe_| to be watched while others perform sync handle 128 // Allows |message_pipe_| to be watched while others perform sync handle
128 // watching on the same thread. Please see comments of 129 // watching on the same thread. Please see comments of
129 // SyncHandleWatcher::AllowWokenUpBySyncWatchOnSameThread(). 130 // SyncHandleWatcher::AllowWokenUpBySyncWatchOnSameThread().
130 void AllowWokenUpBySyncWatchOnSameThread(); 131 void AllowWokenUpBySyncWatchOnSameThread();
(...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after
204 base::WeakPtr<Connector> weak_self_; 205 base::WeakPtr<Connector> weak_self_;
205 base::WeakPtrFactory<Connector> weak_factory_; 206 base::WeakPtrFactory<Connector> weak_factory_;
206 207
207 DISALLOW_COPY_AND_ASSIGN(Connector); 208 DISALLOW_COPY_AND_ASSIGN(Connector);
208 }; 209 };
209 210
210 } // namespace internal 211 } // namespace internal
211 } // namespace mojo 212 } // namespace mojo
212 213
213 #endif // MOJO_PUBLIC_CPP_BINDINGS_LIB_CONNECTOR_H_ 214 #endif // MOJO_PUBLIC_CPP_BINDINGS_LIB_CONNECTOR_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698