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_RENDERER_RENDER_VIEW_OBSERVER_H_ | 5 #ifndef CONTENT_PUBLIC_RENDERER_RENDER_VIEW_OBSERVER_H_ |
6 #define CONTENT_PUBLIC_RENDERER_RENDER_VIEW_OBSERVER_H_ | 6 #define CONTENT_PUBLIC_RENDERER_RENDER_VIEW_OBSERVER_H_ |
7 | 7 |
8 #include "base/compiler_specific.h" | 8 #include "base/compiler_specific.h" |
9 #include "base/macros.h" | 9 #include "base/macros.h" |
10 #include "content/common/content_export.h" | 10 #include "content/common/content_export.h" |
(...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
76 | 76 |
77 virtual void OnStop() {} | 77 virtual void OnStop() {} |
78 virtual void OnZoomLevelChanged() {} | 78 virtual void OnZoomLevelChanged() {} |
79 | 79 |
80 // IPC::Listener implementation. | 80 // IPC::Listener implementation. |
81 bool OnMessageReceived(const IPC::Message& message) override; | 81 bool OnMessageReceived(const IPC::Message& message) override; |
82 | 82 |
83 // IPC::Sender implementation. | 83 // IPC::Sender implementation. |
84 bool Send(IPC::Message* message) override; | 84 bool Send(IPC::Message* message) override; |
85 | 85 |
| 86 // Returns the observed RenderView or nullptr if the RenderView has been |
| 87 // destroyed. |
86 RenderView* render_view() const; | 88 RenderView* render_view() const; |
87 int routing_id() const { return routing_id_; } | 89 |
| 90 // Returns routing id of the observed RenderView or MSG_ROUTING_NONE if the |
| 91 // RenderView has been destroyed. |
| 92 int routing_id() const; |
88 | 93 |
89 protected: | 94 protected: |
90 explicit RenderViewObserver(RenderView* render_view); | 95 explicit RenderViewObserver(RenderView* render_view); |
91 ~RenderViewObserver() override; | 96 ~RenderViewObserver() override; |
92 | 97 |
93 // Sets |render_view_| to track. | 98 // Sets |render_view_| to track. |
94 // Removes itself of previous (if any) |render_view_| observer list and adds | 99 // Removes itself of previous (if any) |render_view_| observer list and adds |
95 // to the new |render_view|. Since it assumes that observer outlives | 100 // to the new |render_view|. Since it assumes that observer outlives |
96 // render_view, OnDestruct should be overridden. | 101 // render_view, OnDestruct should be overridden. |
97 void Observe(RenderView* render_view); | 102 void Observe(RenderView* render_view); |
98 | 103 |
99 private: | 104 private: |
100 friend class RenderViewImpl; | 105 friend class RenderViewImpl; |
101 | 106 |
102 // This is called by the RenderView when it's going away so that this object | 107 // This is called by the RenderView when it's going away so that this object |
103 // can null out its pointer. | 108 // can null out its pointer. |
104 void RenderViewGone(); | 109 void RenderViewGone(); |
105 | 110 |
106 RenderViewImpl* render_view_; | 111 RenderViewImpl* render_view_; |
107 // The routing ID of the associated RenderView. | |
108 int routing_id_; | |
109 | 112 |
110 DISALLOW_COPY_AND_ASSIGN(RenderViewObserver); | 113 DISALLOW_COPY_AND_ASSIGN(RenderViewObserver); |
111 }; | 114 }; |
112 | 115 |
113 } // namespace content | 116 } // namespace content |
114 | 117 |
115 #endif // CONTENT_PUBLIC_RENDERER_RENDER_VIEW_OBSERVER_H_ | 118 #endif // CONTENT_PUBLIC_RENDERER_RENDER_VIEW_OBSERVER_H_ |
OLD | NEW |