diff options
-rw-r--r-- | chrome/common/child_process.cc | 4 | ||||
-rw-r--r-- | chrome/common/child_thread.cc | 6 | ||||
-rw-r--r-- | chrome/common/child_thread.h | 5 | ||||
-rw-r--r-- | chrome/renderer/mock_render_thread.h | 5 | ||||
-rw-r--r-- | chrome/renderer/render_thread.h | 7 | ||||
-rw-r--r-- | chrome/renderer/render_widget.cc | 83 | ||||
-rw-r--r-- | chrome/renderer/render_widget.h | 3 |
7 files changed, 9 insertions, 104 deletions
diff --git a/chrome/common/child_process.cc b/chrome/common/child_process.cc index 65c2622..934583a 100644 --- a/chrome/common/child_process.cc +++ b/chrome/common/child_process.cc @@ -32,10 +32,6 @@ ChildProcess::~ChildProcess() { if (child_thread_.get()) child_thread_->Stop(); - // Make sure the child thread goes away first before setting child_process_ to - // NULL since it can use it. - child_thread_.reset(); - child_process_ = NULL; } diff --git a/chrome/common/child_thread.cc b/chrome/common/child_thread.cc index a37310d62..d1a9893 100644 --- a/chrome/common/child_thread.cc +++ b/chrome/common/child_thread.cc @@ -14,7 +14,6 @@ ChildThread::ChildThread(Thread::Options options) : Thread("Chrome_ChildThread"), owner_loop_(MessageLoop::current()), - in_send_(0), options_(options) { DCHECK(owner_loop_); channel_name_ = CommandLine::ForCurrentProcess()->GetSwitchValue( @@ -47,10 +46,7 @@ bool ChildThread::Send(IPC::Message* msg) { return false; } - in_send_++; - bool rv = channel_->Send(msg); - in_send_--; - return rv; + return channel_->Send(msg); } void ChildThread::AddRoute(int32 routing_id, IPC::Channel::Listener* listener) { diff --git a/chrome/common/child_thread.h b/chrome/common/child_thread.h index ac835cc..5b13ab7 100644 --- a/chrome/common/child_thread.h +++ b/chrome/common/child_thread.h @@ -44,9 +44,6 @@ class ChildThread : public IPC::Channel::Listener, IPC::SyncChannel* channel() { return channel_.get(); } - // Indicates if ChildThread::Send() is on the call stack. - virtual bool InSend() const { return in_send_ != 0; } - // Thread implementation. virtual void Init(); virtual void CleanUp(); @@ -66,8 +63,6 @@ class ChildThread : public IPC::Channel::Listener, // functionality to the consumers of the ChildThread. MessageRouter router_; - int in_send_; - Thread::Options options_; DISALLOW_EVIL_CONSTRUCTORS(ChildThread); diff --git a/chrome/renderer/mock_render_thread.h b/chrome/renderer/mock_render_thread.h index 4ed785f..fb47a15 100644 --- a/chrome/renderer/mock_render_thread.h +++ b/chrome/renderer/mock_render_thread.h @@ -22,11 +22,6 @@ class MockRenderThread : public RenderThreadBase { // Provides access to the messages that have been received by this thread. IPC::TestSink& sink() { return sink_; } - // Called by the Widget. Not used in the test. - virtual bool InSend() const { - return false; - } - // Called by the Widget. The routing_id must match the routing id assigned // to the Widget in reply to ViewHostMsg_CreateWidget message. virtual void AddRoute(int32 routing_id, IPC::Channel::Listener* listener); diff --git a/chrome/renderer/render_thread.h b/chrome/renderer/render_thread.h index a3bd534..54043ca 100644 --- a/chrome/renderer/render_thread.h +++ b/chrome/renderer/render_thread.h @@ -31,9 +31,6 @@ class RenderThreadBase { virtual bool Send(IPC::Message* msg) = 0; - // True if currently sending a message. - virtual bool InSend() const = 0; - // Called to add or remove a listener for a particular message routing ID. // These methods normally get delegated to a MessageRouter. virtual void AddRoute(int32 routing_id, IPC::Channel::Listener* listener) = 0; @@ -70,10 +67,6 @@ class RenderThread : public RenderThreadBase, return ChildThread::Send(msg); } - virtual bool InSend() const { - return ChildThread::InSend(); - } - virtual void AddRoute(int32 routing_id, IPC::Channel::Listener* listener) { return ChildThread::AddRoute(routing_id, listener); } diff --git a/chrome/renderer/render_widget.cc b/chrome/renderer/render_widget.cc index c24e83f..c6993c1 100644 --- a/chrome/renderer/render_widget.cc +++ b/chrome/renderer/render_widget.cc @@ -23,58 +23,6 @@ #include "webkit/glue/webinputevent.h" #include "webkit/glue/webwidget.h" -/////////////////////////////////////////////////////////////////////////////// - -namespace { - -// This class is used to defer calling RenderWidget::Close() while the current -// thread is inside RenderThread::Send(), which in some cases can result in a -// nested MessageLoop being run. -class DeferredCloses : public Task { - public: - // Called to queue a deferred close for the given widget. - static void Push(RenderWidget* widget) { - if (!current_) - current_ = new DeferredCloses(); - current_->queue_.push(widget); - } - - // Called to trigger any deferred closes to be run. - static void Post() { - if (current_) { - MessageLoop::current()->PostTask(FROM_HERE, current_); - current_ = NULL; - } - } - - private: - virtual void Run() { - // Maybe we are being run from within another RenderWidget::Send call. If - // that is true, then we need to re-queue the widgets to be closed and try - // again later. - while (!queue_.empty()) { - if (queue_.front()->InSend()) { - Push(queue_.front()); - } else { - queue_.front()->Close(); - } - queue_.pop(); - } - } - - // The current DeferredCloses object. - static DeferredCloses* current_; - - typedef std::queue< scoped_refptr<RenderWidget> > WidgetQueue; - WidgetQueue queue_; -}; - -DeferredCloses* DeferredCloses::current_ = NULL; - -} // namespace - -/////////////////////////////////////////////////////////////////////////////// - RenderWidget::RenderWidget(RenderThreadBase* render_thread, bool activatable) : routing_id_(MSG_ROUTING_NONE), webwidget_(NULL), @@ -185,19 +133,7 @@ bool RenderWidget::Send(IPC::Message* message) { if (message->routing_id() == MSG_ROUTING_NONE) message->set_routing_id(routing_id_); - bool rv = render_thread_->Send(message); - - // If there aren't any more RenderThread::Send calls on the stack, then we - // can go ahead and schedule Close to be called on any RenderWidget objects - // that received a ViewMsg_Close while we were inside Send. - if (!render_thread_->InSend()) - DeferredCloses::Post(); - - return rv; -} - -bool RenderWidget::InSend() const { - return render_thread_->InSend(); + return render_thread_->Send(message); } // Got a response from the browser after the renderer decided to create a new @@ -217,17 +153,14 @@ void RenderWidget::OnClose() { if (routing_id_ != MSG_ROUTING_NONE) render_thread_->RemoveRoute(routing_id_); - // Balances the AddRef taken when we called AddRoute. This release happens - // via the MessageLoop since it may cause our destruction. - MessageLoop::current()->ReleaseSoon(FROM_HERE, this); - // If there is a Send call on the stack, then it could be dangerous to close - // now. Instead, we wait until we get out of Send. - if (render_thread_->InSend()) { - DeferredCloses::Push(this); - } else { - Close(); - } + // now. Post a task that only gets invoked when there are no nested message + // loops. + MessageLoop::current()->PostNonNestableTask(FROM_HERE, + NewRunnableMethod(this, &RenderWidget::Close)); + + // Balances the AddRef taken when we called AddRoute. + Release(); } void RenderWidget::OnResize(const gfx::Size& new_size, diff --git a/chrome/renderer/render_widget.h b/chrome/renderer/render_widget.h index edcc5af..4f8e3b4 100644 --- a/chrome/renderer/render_widget.h +++ b/chrome/renderer/render_widget.h @@ -63,9 +63,6 @@ class RenderWidget : public IPC::Channel::Listener, // IPC::Message::Sender virtual bool Send(IPC::Message* msg); - // True if the underlying IPC is currently sending data. - bool InSend() const; - // WebWidgetDelegate virtual gfx::NativeViewId GetContainingView(WebWidget* webwidget); virtual void DidInvalidateRect(WebWidget* webwidget, const gfx::Rect& rect); |