summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--chrome/nacl/nacl_ipc_adapter.cc25
-rw-r--r--chrome/nacl/nacl_ipc_adapter.h6
-rw-r--r--chrome/nacl/nacl_listener.cc2
-rw-r--r--chrome/nacl/nacl_listener.h2
4 files changed, 20 insertions, 15 deletions
diff --git a/chrome/nacl/nacl_ipc_adapter.cc b/chrome/nacl/nacl_ipc_adapter.cc
index 8f13c57..cf5ae2f 100644
--- a/chrome/nacl/nacl_ipc_adapter.cc
+++ b/chrome/nacl/nacl_ipc_adapter.cc
@@ -57,6 +57,9 @@ class NaClIPCAdapter::RewrittenMessage
int Read(char* dest_buffer, int dest_buffer_size);
private:
+ friend class base::RefCounted<RewrittenMessage>;
+ ~RewrittenMessage() {}
+
scoped_array<char> data_;
int data_len_;
@@ -126,9 +129,6 @@ NaClIPCAdapter::NaClIPCAdapter(scoped_ptr<IPC::Channel> channel,
io_thread_data_.channel_ = channel.Pass();
}
-NaClIPCAdapter::~NaClIPCAdapter() {
-}
-
// Note that this message is controlled by the untrusted code. So we should be
// skeptical of anything it contains and quick to give up if anything is fishy.
int NaClIPCAdapter::Send(const char* input_data, size_t input_data_len) {
@@ -255,6 +255,9 @@ void NaClIPCAdapter::OnChannelError() {
CloseChannel();
}
+NaClIPCAdapter::~NaClIPCAdapter() {
+}
+
int NaClIPCAdapter::LockedReceive(char* output_buffer, int output_buffer_size) {
lock_.AssertAcquired();
@@ -316,14 +319,6 @@ bool NaClIPCAdapter::SendCompleteMessage(const char* buffer,
return true;
}
-void NaClIPCAdapter::CloseChannelOnIOThread() {
- io_thread_data_.channel_->Close();
-}
-
-void NaClIPCAdapter::SendMessageOnIOThread(scoped_ptr<IPC::Message> message) {
- io_thread_data_.channel_->Send(message.release());
-}
-
void NaClIPCAdapter::ClearToBeSent() {
lock_.AssertAcquired();
@@ -331,3 +326,11 @@ void NaClIPCAdapter::ClearToBeSent() {
std::string empty;
locked_data_.to_be_sent_.swap(empty);
}
+
+void NaClIPCAdapter::CloseChannelOnIOThread() {
+ io_thread_data_.channel_->Close();
+}
+
+void NaClIPCAdapter::SendMessageOnIOThread(scoped_ptr<IPC::Message> message) {
+ io_thread_data_.channel_->Send(message.release());
+}
diff --git a/chrome/nacl/nacl_ipc_adapter.h b/chrome/nacl/nacl_ipc_adapter.h
index f8e8733..e28c042 100644
--- a/chrome/nacl/nacl_ipc_adapter.h
+++ b/chrome/nacl/nacl_ipc_adapter.h
@@ -59,8 +59,6 @@ class NaClIPCAdapter : public base::RefCountedThreadSafe<NaClIPCAdapter>,
// purposes. This function will take ownership of the given channel.
NaClIPCAdapter(scoped_ptr<IPC::Channel> channel, base::TaskRunner* runner);
- virtual ~NaClIPCAdapter();
-
// Implementation of sendmsg. Returns the number of bytes written or -1 on
// failure.
int Send(const char* input_data, size_t input_data_len);
@@ -79,6 +77,8 @@ class NaClIPCAdapter : public base::RefCountedThreadSafe<NaClIPCAdapter>,
virtual void OnChannelError() OVERRIDE;
private:
+ friend class base::RefCountedThreadSafe<NaClIPCAdapter>;
+
class RewrittenMessage;
// This is the data that must only be accessed inside the lock. This struct
@@ -112,6 +112,8 @@ class NaClIPCAdapter : public base::RefCountedThreadSafe<NaClIPCAdapter>,
scoped_ptr<IPC::Channel> channel_;
};
+ virtual ~NaClIPCAdapter();
+
// Reads up to the given amount of data. Returns 0 if nothing is waiting.
int LockedReceive(char* output_buffer, int output_buffer_size);
diff --git a/chrome/nacl/nacl_listener.cc b/chrome/nacl/nacl_listener.cc
index a00a237..d6e081d 100644
--- a/chrome/nacl/nacl_listener.cc
+++ b/chrome/nacl/nacl_listener.cc
@@ -157,7 +157,7 @@ void NaClListener::Listen() {
switches::kProcessChannelID);
channel_.reset(new IPC::SyncChannel(this, io_thread_.message_loop_proxy(),
&shutdown_event_));
- filter_.reset(new IPC::SyncMessageFilter(&shutdown_event_));
+ filter_ = new IPC::SyncMessageFilter(&shutdown_event_);
channel_->AddFilter(filter_.get());
channel_->Init(channel_name, IPC::Channel::MODE_CLIENT, true);
main_loop_ = MessageLoop::current();
diff --git a/chrome/nacl/nacl_listener.h b/chrome/nacl/nacl_listener.h
index d601e33..cb4817f 100644
--- a/chrome/nacl/nacl_listener.h
+++ b/chrome/nacl/nacl_listener.h
@@ -39,7 +39,7 @@ class NaClListener : public IPC::Channel::Listener {
scoped_ptr<IPC::SyncChannel> channel_;
// A filter that allows other threads to use the channel.
- scoped_ptr<IPC::SyncMessageFilter> filter_;
+ scoped_refptr<IPC::SyncMessageFilter> filter_;
base::WaitableEvent shutdown_event_;
base::Thread io_thread_;