forked from chromium/chromium
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add a base class for objects that want to filter messages on the IO t…
…hread. I'll switch the filters to it in future separate changes. I've also taken out the special case for an initial filter from the IPC classes. The reason it existed was that there was a race condition of some messages not being filtered if a filter is added after construction but before launching the peer process. Taking it out allows us to add more than one filter and makes things a little cleaner. Review URL: http://codereview.chromium.org/5513001 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@68043 0039d316-1c4b-4281-b951-d872f2087c98
- Loading branch information
jam@chromium.org
committed
Dec 2, 2010
1 parent
e669998
commit 4b580bf
Showing
20 changed files
with
186 additions
and
65 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
// Copyright (c) 2010 The Chromium Authors. All rights reserved. | ||
// Use of this source code is governed by a BSD-style license that can be | ||
// found in the LICENSE file. | ||
|
||
#include "chrome/browser/browser_io_message_filter.h" | ||
|
||
#include "base/logging.h" | ||
#include "base/process_util.h" | ||
|
||
BrowserIOMessageFilter::BrowserIOMessageFilter() : channel_(NULL) { | ||
} | ||
|
||
BrowserIOMessageFilter::~BrowserIOMessageFilter() { | ||
} | ||
|
||
void BrowserIOMessageFilter::OnFilterAdded(IPC::Channel* channel) { | ||
channel_ = channel; | ||
} | ||
|
||
void BrowserIOMessageFilter::OnChannelClosing() { | ||
channel_ = NULL; | ||
} | ||
|
||
void BrowserIOMessageFilter::OnChannelConnected(int32 peer_pid) { | ||
if (!base::OpenProcessHandle(peer_pid, &peer_handle_)) { | ||
NOTREACHED(); | ||
} | ||
} | ||
|
||
bool BrowserIOMessageFilter::Send(IPC::Message* msg) { | ||
if (channel_) | ||
return channel_->Send(msg); | ||
|
||
delete msg; | ||
return false; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
// Copyright (c) 2010 The Chromium Authors. All rights reserved. | ||
// Use of this source code is governed by a BSD-style license that can be | ||
// found in the LICENSE file. | ||
|
||
#ifndef CHROME_BROWSER_BROWSER_IO_MESSAGE_FILTER_H_ | ||
#define CHROME_BROWSER_BROWSER_IO_MESSAGE_FILTER_H_ | ||
#pragma once | ||
|
||
#include "base/process.h" | ||
#include "ipc/ipc_channel_proxy.h" | ||
|
||
// Base class for message filters in the browser process that reside on the IO | ||
// thread. | ||
class BrowserIOMessageFilter : public IPC::ChannelProxy::MessageFilter, | ||
public IPC::Message::Sender { | ||
public: | ||
BrowserIOMessageFilter(); | ||
virtual ~BrowserIOMessageFilter(); | ||
|
||
// IPC::ChannelProxy::MessageFilter methods. If you override them, make sure | ||
// to call them as well. | ||
virtual void OnFilterAdded(IPC::Channel* channel); | ||
virtual void OnChannelClosing(); | ||
virtual void OnChannelConnected(int32 peer_pid); | ||
|
||
// IPC::Message::Sender implementation: | ||
virtual bool Send(IPC::Message* msg); | ||
|
||
protected: | ||
base::ProcessHandle peer_handle() { return peer_handle_; } | ||
|
||
private: | ||
IPC::Channel* channel_; | ||
base::ProcessHandle peer_handle_; | ||
}; | ||
|
||
#endif // CHROME_BROWSER_BROWSER_IO_MESSAGE_FILTER_H_ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.