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

Side by Side Diff: mojo/public/cpp/bindings/associated_interface_ptr.h

Issue 2772983002: Make sure channel-associated interface pointers are always safe to call. (Closed)
Patch Set: . Created 3 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
1 // Copyright 2015 The Chromium Authors. All rights reserved. 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 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_ASSOCIATED_INTERFACE_PTR_H_ 5 #ifndef MOJO_PUBLIC_CPP_BINDINGS_ASSOCIATED_INTERFACE_PTR_H_
6 #define MOJO_PUBLIC_CPP_BINDINGS_ASSOCIATED_INTERFACE_PTR_H_ 6 #define MOJO_PUBLIC_CPP_BINDINGS_ASSOCIATED_INTERFACE_PTR_H_
7 7
8 #include <stdint.h> 8 #include <stdint.h>
9 9
10 #include <string> 10 #include <string>
11 #include <utility> 11 #include <utility>
12 12
13 #include "base/callback.h" 13 #include "base/callback.h"
14 #include "base/logging.h" 14 #include "base/logging.h"
15 #include "base/macros.h" 15 #include "base/macros.h"
16 #include "base/memory/ref_counted.h" 16 #include "base/memory/ref_counted.h"
17 #include "base/single_thread_task_runner.h" 17 #include "base/single_thread_task_runner.h"
18 #include "base/threading/thread_task_runner_handle.h" 18 #include "base/threading/thread_task_runner_handle.h"
19 #include "mojo/public/cpp/bindings/associated_interface_ptr_info.h" 19 #include "mojo/public/cpp/bindings/associated_interface_ptr_info.h"
20 #include "mojo/public/cpp/bindings/associated_interface_request.h" 20 #include "mojo/public/cpp/bindings/associated_interface_request.h"
21 #include "mojo/public/cpp/bindings/bindings_export.h"
21 #include "mojo/public/cpp/bindings/connection_error_callback.h" 22 #include "mojo/public/cpp/bindings/connection_error_callback.h"
22 #include "mojo/public/cpp/bindings/lib/associated_interface_ptr_state.h" 23 #include "mojo/public/cpp/bindings/lib/associated_interface_ptr_state.h"
23 #include "mojo/public/cpp/bindings/lib/multiplex_router.h" 24 #include "mojo/public/cpp/bindings/lib/multiplex_router.h"
24 #include "mojo/public/cpp/system/message_pipe.h" 25 #include "mojo/public/cpp/system/message_pipe.h"
25 26
26 namespace mojo { 27 namespace mojo {
27 28
28 // Represents the client side of an associated interface. It is similar to 29 // Represents the client side of an associated interface. It is similar to
29 // InterfacePtr, except that it doesn't own a message pipe handle. 30 // InterfacePtr, except that it doesn't own a message pipe handle.
30 template <typename Interface> 31 template <typename Interface>
(...skipping 232 matching lines...) Expand 10 before | Expand all | Expand 10 after
263 endpoint0 = router0->CreateLocalEndpointHandle(id); 264 endpoint0 = router0->CreateLocalEndpointHandle(id);
264 265
265 ptr->Bind(AssociatedInterfacePtrInfo<Interface>(std::move(endpoint0), 266 ptr->Bind(AssociatedInterfacePtrInfo<Interface>(std::move(endpoint0),
266 Interface::Version_)); 267 Interface::Version_));
267 268
268 AssociatedInterfaceRequest<Interface> request; 269 AssociatedInterfaceRequest<Interface> request;
269 request.Bind(std::move(endpoint1)); 270 request.Bind(std::move(endpoint1));
270 return request; 271 return request;
271 } 272 }
272 273
274 // |handle| is supposed to be the request of an associated interface. This
275 // method associates the interface with a dedicated, disconnected message pipe.
276 // That way, the corresponding associated interface pointer of |handle| can
277 // safely make calls (although those calls are silently dropped).
278 MOJO_CPP_BINDINGS_EXPORT void GetIsolatedInterface(
279 ScopedInterfaceEndpointHandle handle);
280
273 } // namespace mojo 281 } // namespace mojo
274 282
275 #endif // MOJO_PUBLIC_CPP_BINDINGS_ASSOCIATED_INTERFACE_PTR_H_ 283 #endif // MOJO_PUBLIC_CPP_BINDINGS_ASSOCIATED_INTERFACE_PTR_H_
OLDNEW
« no previous file with comments | « mojo/public/cpp/bindings/BUILD.gn ('k') | mojo/public/cpp/bindings/lib/associated_interface_ptr.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698