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

Side by Side Diff: ipc/ipc_channel_proxy.cc

Issue 6711024: Example of how to interpose yourself in a message stream. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: '' Created 9 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 | Annotate | Revision Log
« chrome/tools/ipclist/ipcfuzz.cc ('K') | « ipc/ipc_channel_proxy.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 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 "base/memory/ref_counted.h" 5 #include "base/memory/ref_counted.h"
6 #include "base/memory/scoped_ptr.h" 6 #include "base/memory/scoped_ptr.h"
7 #include "base/message_loop.h" 7 #include "base/message_loop.h"
8 #include "ipc/ipc_channel_proxy.h" 8 #include "ipc/ipc_channel_proxy.h"
9 #include "ipc/ipc_logging.h" 9 #include "ipc/ipc_logging.h"
10 #include "ipc/ipc_message_utils.h" 10 #include "ipc/ipc_message_utils.h"
(...skipping 263 matching lines...) Expand 10 before | Expand all | Expand 10 after
274 if (listener_) 274 if (listener_)
275 listener_->OnChannelError(); 275 listener_->OnChannelError();
276 } 276 }
277 277
278 //----------------------------------------------------------------------------- 278 //-----------------------------------------------------------------------------
279 279
280 ChannelProxy::ChannelProxy(const IPC::ChannelHandle& channel_handle, 280 ChannelProxy::ChannelProxy(const IPC::ChannelHandle& channel_handle,
281 Channel::Mode mode, 281 Channel::Mode mode,
282 Channel::Listener* listener, 282 Channel::Listener* listener,
283 MessageLoop* ipc_thread) 283 MessageLoop* ipc_thread)
284 : context_(new Context(listener, ipc_thread)) { 284 : context_(new Context(listener, ipc_thread)),
285 outgoing_message_filter_(NULL) {
285 Init(channel_handle, mode, ipc_thread, true); 286 Init(channel_handle, mode, ipc_thread, true);
286 } 287 }
287 288
288 ChannelProxy::ChannelProxy(const IPC::ChannelHandle& channel_handle, 289 ChannelProxy::ChannelProxy(const IPC::ChannelHandle& channel_handle,
289 Channel::Mode mode, 290 Channel::Mode mode,
290 MessageLoop* ipc_thread, 291 MessageLoop* ipc_thread,
291 Context* context, 292 Context* context,
292 bool create_pipe_now) 293 bool create_pipe_now)
293 : context_(context) { 294 : context_(context),
295 outgoing_message_filter_(NULL) {
294 Init(channel_handle, mode, ipc_thread, create_pipe_now); 296 Init(channel_handle, mode, ipc_thread, create_pipe_now);
295 } 297 }
296 298
297 ChannelProxy::~ChannelProxy() { 299 ChannelProxy::~ChannelProxy() {
298 Close(); 300 Close();
299 } 301 }
300 302
301 void ChannelProxy::Init(const IPC::ChannelHandle& channel_handle, 303 void ChannelProxy::Init(const IPC::ChannelHandle& channel_handle,
302 Channel::Mode mode, MessageLoop* ipc_thread_loop, 304 Channel::Mode mode, MessageLoop* ipc_thread_loop,
303 bool create_pipe_now) { 305 bool create_pipe_now) {
(...skipping 29 matching lines...) Expand all
333 // possible that the channel could be closed while it is receiving messages! 335 // possible that the channel could be closed while it is receiving messages!
334 context_->Clear(); 336 context_->Clear();
335 337
336 if (context_->ipc_message_loop()) { 338 if (context_->ipc_message_loop()) {
337 context_->ipc_message_loop()->PostTask(FROM_HERE, NewRunnableMethod( 339 context_->ipc_message_loop()->PostTask(FROM_HERE, NewRunnableMethod(
338 context_.get(), &Context::OnChannelClosed)); 340 context_.get(), &Context::OnChannelClosed));
339 } 341 }
340 } 342 }
341 343
342 bool ChannelProxy::Send(Message* message) { 344 bool ChannelProxy::Send(Message* message) {
345 if (outgoing_message_filter())
346 message = outgoing_message_filter()->Rewrite(message);
347
343 #ifdef IPC_MESSAGE_LOG_ENABLED 348 #ifdef IPC_MESSAGE_LOG_ENABLED
344 Logging::GetInstance()->OnSendMessage(message, context_->channel_id()); 349 Logging::GetInstance()->OnSendMessage(message, context_->channel_id());
345 #endif 350 #endif
346 351
347 context_->ipc_message_loop()->PostTask(FROM_HERE, 352 context_->ipc_message_loop()->PostTask(FROM_HERE,
348 new SendTask(context_.get(), message)); 353 new SendTask(context_.get(), message));
349 return true; 354 return true;
350 } 355 }
351 356
352 void ChannelProxy::AddFilter(MessageFilter* filter) { 357 void ChannelProxy::AddFilter(MessageFilter* filter) {
(...skipping 27 matching lines...) Expand all
380 Channel *channel = context_.get()->channel_.get(); 385 Channel *channel = context_.get()->channel_.get();
381 // Channel must have been created first. 386 // Channel must have been created first.
382 DCHECK(channel) << context_.get()->channel_id_; 387 DCHECK(channel) << context_.get()->channel_id_;
383 return channel->GetClientEuid(client_euid); 388 return channel->GetClientEuid(client_euid);
384 } 389 }
385 #endif 390 #endif
386 391
387 //----------------------------------------------------------------------------- 392 //-----------------------------------------------------------------------------
388 393
389 } // namespace IPC 394 } // namespace IPC
OLDNEW
« chrome/tools/ipclist/ipcfuzz.cc ('K') | « ipc/ipc_channel_proxy.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698