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

Side by Side Diff: content/browser/renderer_host/render_widget_host_view_base.cc

Issue 1711103002: Implement lifetime observer on RenderWidgetHostViewBase. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Restructure, and make RWHVB derived classes responsible for early notification. Created 4 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 unified diff | Download patch
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/browser/renderer_host/render_widget_host_view_base.h" 5 #include "content/browser/renderer_host/render_widget_host_view_base.h"
6 6
7 #include "base/logging.h" 7 #include "base/logging.h"
8 #include "build/build_config.h" 8 #include "build/build_config.h"
9 #include "content/browser/accessibility/browser_accessibility_manager.h" 9 #include "content/browser/accessibility/browser_accessibility_manager.h"
10 #include "content/browser/gpu/gpu_data_manager_impl.h" 10 #include "content/browser/gpu/gpu_data_manager_impl.h"
11 #include "content/browser/renderer_host/input/synthetic_gesture_target_base.h" 11 #include "content/browser/renderer_host/input/synthetic_gesture_target_base.h"
12 #include "content/browser/renderer_host/render_process_host_impl.h" 12 #include "content/browser/renderer_host/render_process_host_impl.h"
13 #include "content/browser/renderer_host/render_widget_host_impl.h" 13 #include "content/browser/renderer_host/render_widget_host_impl.h"
14 #include "content/browser/renderer_host/render_widget_host_view_base_observer.h"
14 #include "content/common/content_switches_internal.h" 15 #include "content/common/content_switches_internal.h"
15 #include "content/public/browser/render_widget_host_view_frame_subscriber.h" 16 #include "content/public/browser/render_widget_host_view_frame_subscriber.h"
16 #include "ui/gfx/display.h" 17 #include "ui/gfx/display.h"
17 #include "ui/gfx/geometry/point_conversions.h" 18 #include "ui/gfx/geometry/point_conversions.h"
18 #include "ui/gfx/geometry/size_conversions.h" 19 #include "ui/gfx/geometry/size_conversions.h"
19 #include "ui/gfx/geometry/size_f.h" 20 #include "ui/gfx/geometry/size_f.h"
20 #include "ui/gfx/screen.h" 21 #include "ui/gfx/screen.h"
21 22
22 #if defined(OS_WIN) 23 #if defined(OS_WIN)
23 #include "base/command_line.h" 24 #include "base/command_line.h"
(...skipping 346 matching lines...) Expand 10 before | Expand all | Expand 10 after
370 : popup_type_(blink::WebPopupTypeNone), 371 : popup_type_(blink::WebPopupTypeNone),
371 background_color_(SK_ColorWHITE), 372 background_color_(SK_ColorWHITE),
372 mouse_locked_(false), 373 mouse_locked_(false),
373 showing_context_menu_(false), 374 showing_context_menu_(false),
374 selection_text_offset_(0), 375 selection_text_offset_(0),
375 selection_range_(gfx::Range::InvalidRange()), 376 selection_range_(gfx::Range::InvalidRange()),
376 current_device_scale_factor_(0), 377 current_device_scale_factor_(0),
377 current_display_rotation_(gfx::Display::ROTATE_0), 378 current_display_rotation_(gfx::Display::ROTATE_0),
378 pinch_zoom_enabled_(content::IsPinchToZoomEnabled()), 379 pinch_zoom_enabled_(content::IsPinchToZoomEnabled()),
379 renderer_frame_number_(0), 380 renderer_frame_number_(0),
380 weak_factory_(this) { 381 weak_factory_(this) {}
381 }
382 382
383 RenderWidgetHostViewBase::~RenderWidgetHostViewBase() { 383 RenderWidgetHostViewBase::~RenderWidgetHostViewBase() {
384 DCHECK(!mouse_locked_); 384 DCHECK(!mouse_locked_);
385 // We call this here to guarantee that observers are notified before we go
386 // away. However, some subclasses may wish to call this earlier in their
387 // shutdown process, e.g. to force removal from
388 // RenderWidgetHostInputEventRouter's surface map before relinquishing a
389 // host pointer, as in RenderWidgetHostViewGuest. There is no harm in calling
390 // NotifyObserversAboutShutdown() twice, as the observers are required to
391 // de-register on the first call, and so the second call does nothing.
kenrb 2016/02/22 17:05:10 Do you know of any case where this is actually nee
wjmaclean 2016/02/23 13:13:26 My hope was that, by putting this here, then only
392 NotifyObserversAboutShutdown();
393 }
394
395 void RenderWidgetHostViewBase::NotifyObserversAboutShutdown() {
396 // Note: RenderWidgetHostInputEventRouter is an observer, and uses the
397 // following notification to remove this view from its surface owners map.
398 FOR_EACH_OBSERVER(RenderWidgetHostViewBaseObserver,
399 observers_,
400 OnRenderWidgetHostViewBaseDestroyed(this));
401 // All observers are required to disconnect after they are notified.
402 DCHECK(!observers_.might_have_observers());
385 } 403 }
386 404
387 bool RenderWidgetHostViewBase::OnMessageReceived(const IPC::Message& msg){ 405 bool RenderWidgetHostViewBase::OnMessageReceived(const IPC::Message& msg){
388 return false; 406 return false;
389 } 407 }
390 408
391 void RenderWidgetHostViewBase::SetBackgroundColor(SkColor color) { 409 void RenderWidgetHostViewBase::SetBackgroundColor(SkColor color) {
392 background_color_ = color; 410 background_color_ = color;
393 } 411 }
394 412
(...skipping 299 matching lines...) Expand 10 before | Expand all | Expand 10 after
694 gfx::ToRoundedPoint(point))); 712 gfx::ToRoundedPoint(point)));
695 } 713 }
696 714
697 void RenderWidgetHostViewBase::TransformPointToLocalCoordSpace( 715 void RenderWidgetHostViewBase::TransformPointToLocalCoordSpace(
698 const gfx::Point& point, 716 const gfx::Point& point,
699 cc::SurfaceId original_surface, 717 cc::SurfaceId original_surface,
700 gfx::Point* transformed_point) { 718 gfx::Point* transformed_point) {
701 *transformed_point = point; 719 *transformed_point = point;
702 } 720 }
703 721
722 void RenderWidgetHostViewBase::AddObserver(
723 RenderWidgetHostViewBaseObserver* observer) {
724 observers_.AddObserver(observer);
725 }
726
727 void RenderWidgetHostViewBase::RemoveObserver(
728 RenderWidgetHostViewBaseObserver* observer) {
729 observers_.RemoveObserver(observer);
730 }
731
704 } // namespace content 732 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698