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

Unified Diff: ipc/ipc_channel_proxy.h

Issue 2668153003: Mojo C++ Bindings: Eliminate unbound ThreadSafeInterfacePtr (Closed)
Patch Set: Created 3 years, 11 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « content/renderer/render_thread_impl.cc ('k') | mojo/public/cpp/bindings/associated_interface_ptr.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: ipc/ipc_channel_proxy.h
diff --git a/ipc/ipc_channel_proxy.h b/ipc/ipc_channel_proxy.h
index bda83bb18854299b58c977b6a5a349e76cf4e15b..a64de871f7a9cbbd33adcf9921c1f724724b3390 100644
--- a/ipc/ipc_channel_proxy.h
+++ b/ipc/ipc_channel_proxy.h
@@ -22,8 +22,10 @@
#include "ipc/ipc_listener.h"
#include "ipc/ipc_sender.h"
#include "mojo/public/cpp/bindings/associated_group.h"
+#include "mojo/public/cpp/bindings/associated_interface_ptr.h"
#include "mojo/public/cpp/bindings/associated_interface_request.h"
#include "mojo/public/cpp/bindings/scoped_interface_endpoint_handle.h"
+#include "mojo/public/cpp/bindings/thread_safe_interface_ptr.h"
namespace base {
class SingleThreadTaskRunner;
@@ -209,17 +211,22 @@ class IPC_EXPORT ChannelProxy : public Sender, public base::NonThreadSafe {
}
#endif
+ // Creates a ThreadSafeAssociatedInterfacePtr for |Interface|. This object
+ // may be used to send messages on the interface from any thread and those
+ // messages will remain ordered with respect to other messages sent on the
+ // same thread over other ThreadSafeAssociatedInterfacePtrs associated with
+ // the same Channel.
template <typename Interface>
- using AssociatedInterfaceRetrievedCallback =
- base::Callback<void(mojo::AssociatedInterfacePtr<Interface>)>;
- // Creates an AssociatedInterfacePtr to |Interface| on the IO thread and
- // passes it to |callback|, also invoked on the IO thread.
- template <typename Interface>
- void RetrieveAssociatedInterfaceOnIOThread(
- const AssociatedInterfaceRetrievedCallback<Interface>& callback) {
- context_->ipc_task_runner()->PostTask(
- FROM_HERE, base::Bind(&Context::RetrieveAssociatedInterface<Interface>,
- context_, callback));
+ void GetThreadSafeRemoteAssociatedInterface(
yzshen1 2017/02/01 18:57:55 I guess the change I proposed is orthogonal: I am
+ scoped_refptr<mojo::ThreadSafeAssociatedInterfacePtr<Interface>>*
+ out_ptr) {
+ DCHECK(GetAssociatedGroup());
+ mojo::AssociatedInterfacePtr<Interface> ptr;
+ mojo::AssociatedInterfaceRequest<Interface> request =
+ mojo::MakeRequest(&ptr, GetAssociatedGroup());
+ *out_ptr = mojo::ThreadSafeAssociatedInterfacePtr<Interface>::Create(
+ ptr.PassInterface(), ipc_task_runner());
+ GetGenericRemoteAssociatedInterface(Interface::Name_, request.PassHandle());
}
base::SingleThreadTaskRunner* ipc_task_runner() const {
@@ -299,14 +306,6 @@ class IPC_EXPORT ChannelProxy : public Sender, public base::NonThreadSafe {
void OnSendMessage(std::unique_ptr<Message> message_ptr);
void OnAddFilter();
void OnRemoveFilter(MessageFilter* filter);
- template <typename Interface>
- void RetrieveAssociatedInterface(
- const AssociatedInterfaceRetrievedCallback<Interface>& callback) {
- mojo::AssociatedInterfacePtr<Interface> interface_ptr;
- channel_->GetAssociatedInterfaceSupport()->GetRemoteAssociatedInterface(
- &interface_ptr);
- callback.Run(std::move(interface_ptr));
- }
// Methods called on the listener thread.
void AddFilter(MessageFilter* filter);
« no previous file with comments | « content/renderer/render_thread_impl.cc ('k') | mojo/public/cpp/bindings/associated_interface_ptr.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698