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

Side by Side Diff: content/child/npapi/np_channel_base.cc

Issue 1142063003: content/child: Remove use of MessageLoopProxy and deprecated MessageLoop APIs (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Build fix. Created 5 years, 7 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 | « content/child/npapi/np_channel_base.h ('k') | content/child/npapi/plugin_instance.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 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 #include "content/child/npapi/np_channel_base.h" 5 #include "content/child/npapi/np_channel_base.h"
6 6
7 #include "base/auto_reset.h" 7 #include "base/auto_reset.h"
8 #include "base/containers/hash_tables.h" 8 #include "base/containers/hash_tables.h"
9 #include "base/files/scoped_file.h" 9 #include "base/files/scoped_file.h"
10 #include "base/lazy_instance.h" 10 #include "base/lazy_instance.h"
11 #include "base/single_thread_task_runner.h"
11 #include "base/strings/string_number_conversions.h" 12 #include "base/strings/string_number_conversions.h"
12 #include "base/threading/thread_local.h" 13 #include "base/threading/thread_local.h"
13 #include "ipc/ipc_sync_message.h" 14 #include "ipc/ipc_sync_message.h"
14 15
15 #if defined(OS_POSIX) 16 #if defined(OS_POSIX)
16 #include "base/files/file_util.h" 17 #include "base/files/file_util.h"
17 #include "ipc/ipc_channel_posix.h" 18 #include "ipc/ipc_channel_posix.h"
18 #endif 19 #endif
19 20
20 namespace content { 21 namespace content {
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after
55 56
56 #endif // OS_ANDROID 57 #endif // OS_ANDROID
57 58
58 ChannelMap* GetChannelMap() { 59 ChannelMap* GetChannelMap() {
59 return &GetChannelGlobals()->channel_map; 60 return &GetChannelGlobals()->channel_map;
60 } 61 }
61 62
62 } // namespace 63 } // namespace
63 64
64 NPChannelBase* NPChannelBase::GetChannel( 65 NPChannelBase* NPChannelBase::GetChannel(
65 const IPC::ChannelHandle& channel_handle, IPC::Channel::Mode mode, 66 const IPC::ChannelHandle& channel_handle,
66 ChannelFactory factory, base::MessageLoopProxy* ipc_message_loop, 67 IPC::Channel::Mode mode,
67 bool create_pipe_now, base::WaitableEvent* shutdown_event) { 68 ChannelFactory factory,
69 base::SingleThreadTaskRunner* ipc_task_runner,
70 bool create_pipe_now,
71 base::WaitableEvent* shutdown_event) {
68 #if defined(OS_POSIX) 72 #if defined(OS_POSIX)
69 // On POSIX the channel_handle conveys an FD (socket) which is duped by the 73 // On POSIX the channel_handle conveys an FD (socket) which is duped by the
70 // kernel during the IPC message exchange (via the SCM_RIGHTS mechanism). 74 // kernel during the IPC message exchange (via the SCM_RIGHTS mechanism).
71 // Ensure we do not leak this FD. 75 // Ensure we do not leak this FD.
72 base::ScopedFD fd(channel_handle.socket.auto_close ? 76 base::ScopedFD fd(channel_handle.socket.auto_close ?
73 channel_handle.socket.fd : -1); 77 channel_handle.socket.fd : -1);
74 #endif 78 #endif
75 79
76 scoped_refptr<NPChannelBase> channel; 80 scoped_refptr<NPChannelBase> channel;
77 std::string channel_key = channel_handle.name; 81 std::string channel_key = channel_handle.name;
78 ChannelMap::const_iterator iter = GetChannelMap()->find(channel_key); 82 ChannelMap::const_iterator iter = GetChannelMap()->find(channel_key);
79 if (iter == GetChannelMap()->end()) { 83 if (iter == GetChannelMap()->end()) {
80 channel = factory(); 84 channel = factory();
81 } else { 85 } else {
82 channel = iter->second; 86 channel = iter->second;
83 } 87 }
84 88
85 DCHECK(channel.get() != NULL); 89 DCHECK(channel.get() != NULL);
86 90
87 if (!channel->channel_valid()) { 91 if (!channel->channel_valid()) {
88 channel->channel_handle_ = channel_handle; 92 channel->channel_handle_ = channel_handle;
89 #if defined(OS_POSIX) 93 #if defined(OS_POSIX)
90 ignore_result(fd.release()); 94 ignore_result(fd.release());
91 #endif 95 #endif
92 if (mode & IPC::Channel::MODE_SERVER_FLAG) { 96 if (mode & IPC::Channel::MODE_SERVER_FLAG) {
93 channel->channel_handle_.name = 97 channel->channel_handle_.name =
94 IPC::Channel::GenerateVerifiedChannelID(channel_key); 98 IPC::Channel::GenerateVerifiedChannelID(channel_key);
95 } 99 }
96 channel->mode_ = mode; 100 channel->mode_ = mode;
97 if (channel->Init(ipc_message_loop, create_pipe_now, shutdown_event)) { 101 if (channel->Init(ipc_task_runner, create_pipe_now, shutdown_event)) {
98 (*GetChannelMap())[channel_key] = channel; 102 (*GetChannelMap())[channel_key] = channel;
99 } else { 103 } else {
100 channel = NULL; 104 channel = NULL;
101 } 105 }
102 } 106 }
103 107
104 return channel.get(); 108 return channel.get();
105 } 109 }
106 110
107 void NPChannelBase::Broadcast(IPC::Message* message) { 111 void NPChannelBase::Broadcast(IPC::Message* message) {
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after
161 DLOG(WARNING) << "Invalid route id passed in:" << route_id; 165 DLOG(WARNING) << "Invalid route id passed in:" << route_id;
162 return NULL; 166 return NULL;
163 } 167 }
164 return iter->second; 168 return iter->second;
165 } 169 }
166 170
167 base::WaitableEvent* NPChannelBase::GetModalDialogEvent(int render_view_id) { 171 base::WaitableEvent* NPChannelBase::GetModalDialogEvent(int render_view_id) {
168 return NULL; 172 return NULL;
169 } 173 }
170 174
171 bool NPChannelBase::Init(base::MessageLoopProxy* ipc_message_loop, 175 bool NPChannelBase::Init(base::SingleThreadTaskRunner* ipc_task_runner,
172 bool create_pipe_now, 176 bool create_pipe_now,
173 base::WaitableEvent* shutdown_event) { 177 base::WaitableEvent* shutdown_event) {
174 #if defined(OS_POSIX) 178 #if defined(OS_POSIX)
175 // Attempting to initialize with an invalid channel handle. 179 // Attempting to initialize with an invalid channel handle.
176 // See http://crbug.com/97285 for details. 180 // See http://crbug.com/97285 for details.
177 if (mode_ == IPC::Channel::MODE_CLIENT && -1 == channel_handle_.socket.fd) 181 if (mode_ == IPC::Channel::MODE_CLIENT && -1 == channel_handle_.socket.fd)
178 return false; 182 return false;
179 #endif 183 #endif
180 184
181 channel_ = IPC::SyncChannel::Create( 185 channel_ =
182 channel_handle_, mode_, this, ipc_message_loop, create_pipe_now, 186 IPC::SyncChannel::Create(channel_handle_, mode_, this, ipc_task_runner,
183 shutdown_event); 187 create_pipe_now, shutdown_event);
184 188
185 #if defined(OS_POSIX) 189 #if defined(OS_POSIX)
186 // Check the validity of fd for bug investigation. Remove after fixed. 190 // Check the validity of fd for bug investigation. Remove after fixed.
187 // See crbug.com/97285 for details. 191 // See crbug.com/97285 for details.
188 if (mode_ == IPC::Channel::MODE_SERVER) 192 if (mode_ == IPC::Channel::MODE_SERVER)
189 CHECK_NE(-1, channel_->GetClientFileDescriptor()); 193 CHECK_NE(-1, channel_->GetClientFileDescriptor());
190 #endif 194 #endif
191 195
192 channel_valid_ = true; 196 channel_valid_ = true;
193 return true; 197 return true;
(...skipping 183 matching lines...) Expand 10 before | Expand all | Expand 10 after
377 RouteToOwnerMap::iterator iter = route_to_owner_.find(route_id); 381 RouteToOwnerMap::iterator iter = route_to_owner_.find(route_id);
378 return iter != route_to_owner_.end() ? iter->second : default_owner_; 382 return iter != route_to_owner_.end() ? iter->second : default_owner_;
379 } 383 }
380 384
381 int NPChannelBase::GetExistingRouteForNPObjectOwner(NPP owner) { 385 int NPChannelBase::GetExistingRouteForNPObjectOwner(NPP owner) {
382 OwnerToRouteMap::iterator iter = owner_to_route_.find(owner); 386 OwnerToRouteMap::iterator iter = owner_to_route_.find(owner);
383 return iter != owner_to_route_.end() ? iter->second : MSG_ROUTING_NONE; 387 return iter != owner_to_route_.end() ? iter->second : MSG_ROUTING_NONE;
384 } 388 }
385 389
386 } // namespace content 390 } // namespace content
OLDNEW
« no previous file with comments | « content/child/npapi/np_channel_base.h ('k') | content/child/npapi/plugin_instance.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698