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

Unified Diff: chrome/renderer/render_widget.cc

Issue 28090: Keeping track of whether WebKit is in the callstack using RenderThread doesn'... (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: Created 11 years, 10 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 side-by-side diff with in-line comments
Download patch
« chrome/common/child_process.cc ('K') | « chrome/renderer/render_widget.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/renderer/render_widget.cc
===================================================================
--- chrome/renderer/render_widget.cc (revision 10288)
+++ chrome/renderer/render_widget.cc (working copy)
@@ -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,21 +133,9 @@
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;
+ return render_thread_->Send(message);
}
-bool RenderWidget::InSend() const {
- return render_thread_->InSend();
-}
-
// Got a response from the browser after the renderer decided to create a new
// view.
void RenderWidget::OnCreatingNewAck(gfx::NativeViewId parent) {
@@ -217,17 +153,14 @@
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,
« chrome/common/child_process.cc ('K') | « chrome/renderer/render_widget.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698