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

Side by Side Diff: content/renderer/mojo/thread_safe_associated_interface_ptr_provider.h

Issue 2608783003: Fix ThreadSafeAssociatedInterfacePtrProvider raciness. (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 unified diff | Download patch
« no previous file with comments | « no previous file | ipc/ipc_channel_proxy.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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
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 _
OLDNEW
« no previous file with comments | « no previous file | ipc/ipc_channel_proxy.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698