Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 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 CONTENT_RENDERER_MOJO_THREAD_SAFE_ASSOCIATED_INTERFACE_PTR_PROVIDER_H_ | 5 #ifndef CONTENT_RENDERER_MOJO_THREAD_SAFE_ASSOCIATED_INTERFACE_PTR_PROVIDER_H_ |
| 6 #define CONTENT_RENDERER_MOJO_THREAD_SAFE_ASSOCIATED_INTERFACE_PTR_PROVIDER_H_ | 6 #define CONTENT_RENDERER_MOJO_THREAD_SAFE_ASSOCIATED_INTERFACE_PTR_PROVIDER_H_ |
| 7 | 7 |
| 8 #include "base/bind.h" | 8 #include "base/bind.h" |
| 9 #include "base/macros.h" | 9 #include "base/macros.h" |
| 10 #include "base/memory/ref_counted.h" | 10 #include "base/memory/ref_counted.h" |
| (...skipping 11 matching lines...) Expand all Loading... | |
| 22 // Note that this does not take ownership of |channel_proxy|. It's the | 22 // Note that this does not take ownership of |channel_proxy|. It's the |
| 23 // caller responsibility to ensure |channel_proxy| outlives this object. | 23 // caller responsibility to ensure |channel_proxy| outlives this object. |
| 24 explicit ThreadSafeAssociatedInterfacePtrProvider( | 24 explicit ThreadSafeAssociatedInterfacePtrProvider( |
| 25 IPC::ChannelProxy* channel_proxy) | 25 IPC::ChannelProxy* channel_proxy) |
| 26 : channel_proxy_(channel_proxy) {} | 26 : channel_proxy_(channel_proxy) {} |
| 27 | 27 |
| 28 template <typename Interface> | 28 template <typename Interface> |
| 29 scoped_refptr<mojo::ThreadSafeAssociatedInterfacePtr<Interface>> | 29 scoped_refptr<mojo::ThreadSafeAssociatedInterfacePtr<Interface>> |
| 30 CreateInterfacePtr() { | 30 CreateInterfacePtr() { |
| 31 scoped_refptr<mojo::ThreadSafeAssociatedInterfacePtr<Interface>> ptr = | 31 scoped_refptr<mojo::ThreadSafeAssociatedInterfacePtr<Interface>> ptr = |
| 32 mojo::ThreadSafeAssociatedInterfacePtr<Interface>::CreateUnbound(); | 32 mojo::ThreadSafeAssociatedInterfacePtr<Interface>::CreateUnbound( |
| 33 channel_proxy_->ipc_task_runner()); | |
| 33 channel_proxy_->RetrieveAssociatedInterfaceOnIOThread<Interface>(base::Bind( | 34 channel_proxy_->RetrieveAssociatedInterfaceOnIOThread<Interface>(base::Bind( |
|
leonhsl(Using Gerrit)
2016/12/30 06:53:15
I'm not sure I fully understand,, would you please
Jay Civelli
2017/01/03 16:40:56
I am not sure I fully understand the question.
The
leonhsl(Using Gerrit)
2017/01/04 03:35:03
So I suppose the following scenario maybe is not a
| |
| 34 &ThreadSafeAssociatedInterfacePtrProvider::BindInterfacePtr<Interface>, | 35 &ThreadSafeAssociatedInterfacePtrProvider::BindInterfacePtr<Interface>, |
| 35 ptr)); | 36 ptr)); |
| 36 return ptr; | 37 return ptr; |
| 37 } | 38 } |
| 38 | 39 |
| 39 private: | 40 private: |
| 40 template <typename Interface> | 41 template <typename Interface> |
| 41 static void BindInterfacePtr( | 42 static void BindInterfacePtr( |
| 42 const scoped_refptr<mojo::ThreadSafeAssociatedInterfacePtr<Interface>>& | 43 const scoped_refptr<mojo::ThreadSafeAssociatedInterfacePtr<Interface>>& |
| 43 ptr, | 44 ptr, |
| 44 mojo::AssociatedInterfacePtr<Interface> interface_ptr) { | 45 mojo::AssociatedInterfacePtr<Interface> interface_ptr) { |
| 45 bool success = ptr->Bind(std::move(interface_ptr)); | 46 bool success = ptr->Bind(std::move(interface_ptr)); |
| 46 DCHECK(success); | 47 DCHECK(success); |
| 47 } | 48 } |
| 48 | 49 |
| 49 IPC::ChannelProxy* channel_proxy_; | 50 IPC::ChannelProxy* channel_proxy_; |
| 50 | 51 |
| 51 DISALLOW_COPY_AND_ASSIGN(ThreadSafeAssociatedInterfacePtrProvider); | 52 DISALLOW_COPY_AND_ASSIGN(ThreadSafeAssociatedInterfacePtrProvider); |
| 52 }; | 53 }; |
| 53 | 54 |
| 54 } // namespace content | 55 } // namespace content |
| 55 | 56 |
| 56 #endif // CONTENT_RENDERER_MOJO_THREAD_SAFE_ASSOCIATED_INTERFACE_PTR_PROVIDER_H _ | 57 #endif // CONTENT_RENDERER_MOJO_THREAD_SAFE_ASSOCIATED_INTERFACE_PTR_PROVIDER_H _ |
| OLD | NEW |