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

Side by Side Diff: content/renderer/render_widget.cc

Issue 14335017: content: Use base::MessageLoop. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: rebase Created 7 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
« no previous file with comments | « content/renderer/render_view_impl.cc ('k') | content/renderer/renderer_main.cc » ('j') | 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) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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 "content/renderer/render_widget.h" 5 #include "content/renderer/render_widget.h"
6 6
7 #include "base/bind.h" 7 #include "base/bind.h"
8 #include "base/command_line.h" 8 #include "base/command_line.h"
9 #include "base/debug/trace_event.h" 9 #include "base/debug/trace_event.h"
10 #include "base/logging.h" 10 #include "base/logging.h"
(...skipping 408 matching lines...) Expand 10 before | Expand all | Expand 10 after
419 419
420 // Browser correspondence is no longer needed at this point. 420 // Browser correspondence is no longer needed at this point.
421 if (routing_id_ != MSG_ROUTING_NONE) { 421 if (routing_id_ != MSG_ROUTING_NONE) {
422 RenderThread::Get()->RemoveRoute(routing_id_); 422 RenderThread::Get()->RemoveRoute(routing_id_);
423 SetHidden(false); 423 SetHidden(false);
424 } 424 }
425 425
426 // If there is a Send call on the stack, then it could be dangerous to close 426 // If there is a Send call on the stack, then it could be dangerous to close
427 // now. Post a task that only gets invoked when there are no nested message 427 // now. Post a task that only gets invoked when there are no nested message
428 // loops. 428 // loops.
429 MessageLoop::current()->PostNonNestableTask( 429 base::MessageLoop::current()->PostNonNestableTask(
430 FROM_HERE, base::Bind(&RenderWidget::Close, this)); 430 FROM_HERE, base::Bind(&RenderWidget::Close, this));
431 431
432 // Balances the AddRef taken when we called AddRoute. 432 // Balances the AddRef taken when we called AddRoute.
433 Release(); 433 Release();
434 } 434 }
435 435
436 // Got a response from the browser after the renderer decided to create a new 436 // Got a response from the browser after the renderer decided to create a new
437 // view. 437 // view.
438 void RenderWidget::OnCreatingNewAck() { 438 void RenderWidget::OnCreatingNewAck() {
439 DCHECK(routing_id_ != MSG_ROUTING_NONE); 439 DCHECK(routing_id_ != MSG_ROUTING_NONE);
(...skipping 878 matching lines...) Expand 10 before | Expand all | Expand 10 after
1318 animation_update_pending_ && 1318 animation_update_pending_ &&
1319 animation_timer_.IsRunning()) 1319 animation_timer_.IsRunning())
1320 return; 1320 return;
1321 1321
1322 // Perform updating asynchronously. This serves two purposes: 1322 // Perform updating asynchronously. This serves two purposes:
1323 // 1) Ensures that we call WebView::Paint without a bunch of other junk 1323 // 1) Ensures that we call WebView::Paint without a bunch of other junk
1324 // on the call stack. 1324 // on the call stack.
1325 // 2) Allows us to collect more damage rects before painting to help coalesce 1325 // 2) Allows us to collect more damage rects before painting to help coalesce
1326 // the work that we will need to do. 1326 // the work that we will need to do.
1327 invalidation_task_posted_ = true; 1327 invalidation_task_posted_ = true;
1328 MessageLoop::current()->PostTask( 1328 base::MessageLoop::current()->PostTask(
1329 FROM_HERE, base::Bind(&RenderWidget::InvalidationCallback, this)); 1329 FROM_HERE, base::Bind(&RenderWidget::InvalidationCallback, this));
1330 } 1330 }
1331 1331
1332 void RenderWidget::didScrollRect(int dx, int dy, 1332 void RenderWidget::didScrollRect(int dx, int dy,
1333 const WebRect& clip_rect) { 1333 const WebRect& clip_rect) {
1334 // Drop scrolls on the floor when we are in compositing mode. 1334 // Drop scrolls on the floor when we are in compositing mode.
1335 // TODO(nduca): stop WebViewImpl from sending scrolls in the first place. 1335 // TODO(nduca): stop WebViewImpl from sending scrolls in the first place.
1336 if (is_accelerated_compositing_active_) 1336 if (is_accelerated_compositing_active_)
1337 return; 1337 return;
1338 1338
(...skipping 20 matching lines...) Expand all
1359 animation_update_pending_ && 1359 animation_update_pending_ &&
1360 animation_timer_.IsRunning()) 1360 animation_timer_.IsRunning())
1361 return; 1361 return;
1362 1362
1363 // Perform updating asynchronously. This serves two purposes: 1363 // Perform updating asynchronously. This serves two purposes:
1364 // 1) Ensures that we call WebView::Paint without a bunch of other junk 1364 // 1) Ensures that we call WebView::Paint without a bunch of other junk
1365 // on the call stack. 1365 // on the call stack.
1366 // 2) Allows us to collect more damage rects before painting to help coalesce 1366 // 2) Allows us to collect more damage rects before painting to help coalesce
1367 // the work that we will need to do. 1367 // the work that we will need to do.
1368 invalidation_task_posted_ = true; 1368 invalidation_task_posted_ = true;
1369 MessageLoop::current()->PostTask( 1369 base::MessageLoop::current()->PostTask(
1370 FROM_HERE, base::Bind(&RenderWidget::InvalidationCallback, this)); 1370 FROM_HERE, base::Bind(&RenderWidget::InvalidationCallback, this));
1371 } 1371 }
1372 1372
1373 void RenderWidget::didAutoResize(const WebSize& new_size) { 1373 void RenderWidget::didAutoResize(const WebSize& new_size) {
1374 if (size_.width() != new_size.width || size_.height() != new_size.height) { 1374 if (size_.width() != new_size.width || size_.height() != new_size.height) {
1375 size_ = new_size; 1375 size_ = new_size;
1376 // If we don't clear PaintAggregator after changing autoResize state, then 1376 // If we don't clear PaintAggregator after changing autoResize state, then
1377 // we might end up in a situation where bitmap_rect is larger than the 1377 // we might end up in a situation where bitmap_rect is larger than the
1378 // view_size. By clearing PaintAggregator, we ensure that we don't end up 1378 // view_size. By clearing PaintAggregator, we ensure that we don't end up
1379 // with invalid damage rects. 1379 // with invalid damage rects.
(...skipping 223 matching lines...) Expand 10 before | Expand all | Expand 10 after
1603 } 1603 }
1604 1604
1605 // If a page calls window.close() twice, we'll end up here twice, but that's 1605 // If a page calls window.close() twice, we'll end up here twice, but that's
1606 // OK. It is safe to send multiple Close messages. 1606 // OK. It is safe to send multiple Close messages.
1607 1607
1608 // Ask the RenderWidgetHost to initiate close. We could be called from deep 1608 // Ask the RenderWidgetHost to initiate close. We could be called from deep
1609 // in Javascript. If we ask the RendwerWidgetHost to close now, the window 1609 // in Javascript. If we ask the RendwerWidgetHost to close now, the window
1610 // could be closed before the JS finishes executing. So instead, post a 1610 // could be closed before the JS finishes executing. So instead, post a
1611 // message back to the message loop, which won't run until the JS is 1611 // message back to the message loop, which won't run until the JS is
1612 // complete, and then the Close message can be sent. 1612 // complete, and then the Close message can be sent.
1613 MessageLoop::current()->PostTask( 1613 base::MessageLoop::current()->PostTask(
1614 FROM_HERE, base::Bind(&RenderWidget::DoDeferredClose, this)); 1614 FROM_HERE, base::Bind(&RenderWidget::DoDeferredClose, this));
1615 } 1615 }
1616 1616
1617 void RenderWidget::Close() { 1617 void RenderWidget::Close() {
1618 if (webwidget_) { 1618 if (webwidget_) {
1619 webwidget_->willCloseLayerTreeView(); 1619 webwidget_->willCloseLayerTreeView();
1620 compositor_.reset(); 1620 compositor_.reset();
1621 webwidget_->close(); 1621 webwidget_->close();
1622 webwidget_ = NULL; 1622 webwidget_ = NULL;
1623 } 1623 }
(...skipping 699 matching lines...) Expand 10 before | Expand all | Expand 10 after
2323 2323
2324 if (!context->Initialize( 2324 if (!context->Initialize(
2325 attributes, 2325 attributes,
2326 false /* bind generates resources */, 2326 false /* bind generates resources */,
2327 CAUSE_FOR_GPU_LAUNCH_WEBGRAPHICSCONTEXT3DCOMMANDBUFFERIMPL_INITIALIZE) ) 2327 CAUSE_FOR_GPU_LAUNCH_WEBGRAPHICSCONTEXT3DCOMMANDBUFFERIMPL_INITIALIZE) )
2328 return NULL; 2328 return NULL;
2329 return context.release(); 2329 return context.release();
2330 } 2330 }
2331 2331
2332 } // namespace content 2332 } // namespace content
OLDNEW
« no previous file with comments | « content/renderer/render_view_impl.cc ('k') | content/renderer/renderer_main.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698