The default behavior of these two methods is deleting the observer while the RenderFrame/RenderView goes away. As developers are generally not aware of that simply inheriting the observer interface means transferring the ownership to RenderFrame/RenderView, this can cause "mysterious crash" and is very difficult to debug. For safety, we should make OnDestruct() a pure virtual method in RFObserver/RenderView. All classes must implement the method, even if it should be empty. This would ensure the compiler makes a developer aware of the lifecycle concerns around RenderFrame. In the header file, document that OnDestruct() can be used by a subclass to delete itself, but if it does not, then the subclass must always null-check each call to RFO::render_frame()/RVO::render_view() because the RenderFrame/RenderView can go away at any time.
Comment 1 by x...@chromium.org
, Jun 3 2016