OLD | NEW |
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 #ifndef CONTENT_PUBLIC_BROWSER_RENDER_WIDGET_HOST_H_ | 5 #ifndef CONTENT_PUBLIC_BROWSER_RENDER_WIDGET_HOST_H_ |
6 #define CONTENT_PUBLIC_BROWSER_RENDER_WIDGET_HOST_H_ | 6 #define CONTENT_PUBLIC_BROWSER_RENDER_WIDGET_HOST_H_ |
7 #pragma once | 7 #pragma once |
8 | 8 |
9 #include "base/callback.h" | 9 #include "base/callback.h" |
10 #include "content/common/content_export.h" | 10 #include "content/common/content_export.h" |
(...skipping 30 matching lines...) Expand all Loading... |
41 // windows events are sent over IPC to the corresponding object in the | 41 // windows events are sent over IPC to the corresponding object in the |
42 // renderer. The renderer paints into shared memory, which we | 42 // renderer. The renderer paints into shared memory, which we |
43 // transfer to a backing store and blit to the screen when Windows | 43 // transfer to a backing store and blit to the screen when Windows |
44 // sends us a WM_PAINT message. | 44 // sends us a WM_PAINT message. |
45 // | 45 // |
46 // How Shutdown Works | 46 // How Shutdown Works |
47 // | 47 // |
48 // There are two situations in which this object, a RenderWidgetHost, can be | 48 // There are two situations in which this object, a RenderWidgetHost, can be |
49 // instantiated: | 49 // instantiated: |
50 // | 50 // |
51 // 1. By a TabContents as the communication conduit for a rendered web page. | 51 // 1. By a WebContents as the communication conduit for a rendered web page. |
52 // The TabContents instantiates a derived class: RenderViewHost. | 52 // The WebContents instantiates a derived class: RenderViewHost. |
53 // 2. By a TabContents as the communication conduit for a select widget. The | 53 // 2. By a WebContents as the communication conduit for a select widget. The |
54 // TabContents instantiates the RenderWidgetHost directly. | 54 // WebContents instantiates the RenderWidgetHost directly. |
55 // | 55 // |
56 // For every TabContents there are several objects in play that need to be | 56 // For every WebContents there are several objects in play that need to be |
57 // properly destroyed or cleaned up when certain events occur. | 57 // properly destroyed or cleaned up when certain events occur. |
58 // | 58 // |
59 // - TabContents - the TabContents itself, and its associated HWND. | 59 // - WebContents - the WebContents itself, and its associated HWND. |
60 // - RenderViewHost - representing the communication conduit with the child | 60 // - RenderViewHost - representing the communication conduit with the child |
61 // process. | 61 // process. |
62 // - RenderWidgetHostView - the view of the web page content, message handler, | 62 // - RenderWidgetHostView - the view of the web page content, message handler, |
63 // and plugin root. | 63 // and plugin root. |
64 // | 64 // |
65 // Normally, the TabContents contains a child RenderWidgetHostView that renders | 65 // Normally, the WebContents contains a child RenderWidgetHostView that renders |
66 // the contents of the loaded page. It has a WS_CLIPCHILDREN style so that it | 66 // the contents of the loaded page. It has a WS_CLIPCHILDREN style so that it |
67 // does no painting of its own. | 67 // does no painting of its own. |
68 // | 68 // |
69 // The lifetime of the RenderWidgetHostView is tied to the render process. If | 69 // The lifetime of the RenderWidgetHostView is tied to the render process. If |
70 // the render process dies, the RenderWidgetHostView goes away and all | 70 // the render process dies, the RenderWidgetHostView goes away and all |
71 // references to it must become NULL. If the TabContents finds itself without a | 71 // references to it must become NULL. |
72 // RenderWidgetHostView, it paints Sad Tab instead. | |
73 // | 72 // |
74 // RenderViewHost (a RenderWidgetHost subclass) is the conduit used to | 73 // RenderViewHost (a RenderWidgetHost subclass) is the conduit used to |
75 // communicate with the RenderView and is owned by the TabContents. If the | 74 // communicate with the RenderView and is owned by the WebContents. If the |
76 // render process crashes, the RenderViewHost remains and restarts the render | 75 // render process crashes, the RenderViewHost remains and restarts the render |
77 // process if needed to continue navigation. | 76 // process if needed to continue navigation. |
78 // | 77 // |
79 // The TabContents is itself owned by the NavigationController in which it | |
80 // resides. | |
81 // | |
82 // Some examples of how shutdown works: | 78 // Some examples of how shutdown works: |
83 // | 79 // |
84 // When a tab is closed (either by the user, the web page calling window.close, | 80 // For a WebContents, its Destroy method tells the RenderViewHost to |
85 // etc) the TabStrip destroys the associated NavigationController, which calls | |
86 // Destroy on each TabContents it owns. | |
87 // | |
88 // For a TabContents, its Destroy method tells the RenderViewHost to | |
89 // shut down the render process and die. | 81 // shut down the render process and die. |
90 // | 82 // |
91 // When the render process is destroyed it destroys the View: the | 83 // When the render process is destroyed it destroys the View: the |
92 // RenderWidgetHostView, which destroys its HWND and deletes that object. | 84 // RenderWidgetHostView, which destroys its HWND and deletes that object. |
93 // | 85 // |
94 // For select popups, the situation is a little different. The RenderWidgetHost | 86 // For select popups, the situation is a little different. The RenderWidgetHost |
95 // associated with the select popup owns the view and itself (is responsible | 87 // associated with the select popup owns the view and itself (is responsible |
96 // for destroying itself when the view is closed). The TabContents's only | 88 // for destroying itself when the view is closed). The WebContents's only |
97 // responsibility is to select popups is to create them when it is told to. When | 89 // responsibility is to select popups is to create them when it is told to. When |
98 // the View is destroyed via an IPC message (for when WebCore destroys the | 90 // the View is destroyed via an IPC message (for when WebCore destroys the |
99 // popup, e.g. if the user selects one of the options), or because | 91 // popup, e.g. if the user selects one of the options), or because |
100 // WM_CANCELMODE is received by the view, the View schedules the destruction of | 92 // WM_CANCELMODE is received by the view, the View schedules the destruction of |
101 // the render process. However in this case since there's no TabContents | 93 // the render process. However in this case since there's no WebContents |
102 // container, when the render process is destroyed, the RenderWidgetHost just | 94 // container, when the render process is destroyed, the RenderWidgetHost just |
103 // deletes itself, which is safe because no one else should have any references | 95 // deletes itself, which is safe because no one else should have any references |
104 // to it (the TabContents does not). | 96 // to it (the WebContents does not). |
105 // | 97 // |
106 // It should be noted that the RenderViewHost, not the RenderWidgetHost, | 98 // It should be noted that the RenderViewHost, not the RenderWidgetHost, |
107 // handles IPC messages relating to the render process going away, since the | 99 // handles IPC messages relating to the render process going away, since the |
108 // way a RenderViewHost (TabContents) handles the process dying is different to | 100 // way a RenderViewHost (WebContents) handles the process dying is different to |
109 // the way a select popup does. As such the RenderWidgetHostView handles these | 101 // the way a select popup does. As such the RenderWidgetHostView handles these |
110 // messages for select popups. This placement is more out of convenience than | 102 // messages for select popups. This placement is more out of convenience than |
111 // anything else. When the view is live, these messages are forwarded to it by | 103 // anything else. When the view is live, these messages are forwarded to it by |
112 // the RenderWidgetHost's IPC message map. | 104 // the RenderWidgetHost's IPC message map. |
113 class CONTENT_EXPORT RenderWidgetHost : public IPC::Channel::Sender { | 105 class CONTENT_EXPORT RenderWidgetHost : public IPC::Channel::Sender { |
114 public: | 106 public: |
115 // Free all backing stores used for rendering to drop memory usage. | 107 // Free all backing stores used for rendering to drop memory usage. |
116 static void RemoveAllBackingStores(); | 108 static void RemoveAllBackingStores(); |
117 | 109 |
118 // Returns the size of all the backing stores used for rendering | 110 // Returns the size of all the backing stores used for rendering |
(...skipping 172 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
291 // within content/. This method is necessary because | 283 // within content/. This method is necessary because |
292 // RenderWidgetHost is the root of a diamond inheritance pattern, so | 284 // RenderWidgetHost is the root of a diamond inheritance pattern, so |
293 // subclasses inherit it virtually, which removes our ability to | 285 // subclasses inherit it virtually, which removes our ability to |
294 // static_cast to the subclass. | 286 // static_cast to the subclass. |
295 virtual RenderWidgetHostImpl* AsRenderWidgetHostImpl() = 0; | 287 virtual RenderWidgetHostImpl* AsRenderWidgetHostImpl() = 0; |
296 }; | 288 }; |
297 | 289 |
298 } // namespace content | 290 } // namespace content |
299 | 291 |
300 #endif // CONTENT_PUBLIC_BROWSER_RENDER_WIDGET_HOST_H_ | 292 #endif // CONTENT_PUBLIC_BROWSER_RENDER_WIDGET_HOST_H_ |
OLD | NEW |