Chromium Code Reviews| OLD | NEW |
|---|---|
| (Empty) | |
| 1 // Copyright 2017 The Chromium Authors. All rights reserved. | |
| 2 // Use of this source code is governed by a BSD-style license that can be | |
| 3 // found in the LICENSE file. | |
| 4 | |
| 5 #ifndef CONTENT_BROWSER_ANDROID_RENDER_PROCESS_CONNECTOR_H_ | |
| 6 #define CONTENT_BROWSER_ANDROID_RENDER_PROCESS_CONNECTOR_H_ | |
| 7 | |
| 8 #include "base/memory/weak_ptr.h" | |
| 9 #include "content/public/browser/web_contents_observer.h" | |
| 10 | |
| 11 namespace content { | |
| 12 | |
| 13 class RenderWidgetHostViewAndroid; | |
| 14 | |
| 15 // An base class used to connect an object of the content layer lifecycle | |
| 16 // to |RenderWidgetHostViewAndroid|. The inherting class needs to do following: | |
| 17 // | |
| 18 // 1) Override |UpdateRenderProcessConnection| to set itself to the RWHVA | |
| 19 // brought up foreground, and null out its reference in the RWHVA going | |
| 20 // away so it won't access the object any more. | |
| 21 // 2) Call |UpdateRenderProcessConnection(rwhva(), nullptr)| in its destructor | |
| 22 // to clean up its reference from existing RWHVA. Note that this cannot be | |
| 23 // done in the base destructor since the method is pure virtual. | |
| 24 class RenderProcessConnector : public WebContentsObserver { | |
|
boliu
2017/04/07 18:47:10
this has nothing to do with RenderProcess though,
Jinsuk Kim
2017/04/10 05:11:48
- Renamed as suggested.
- Defined an inner class (
| |
| 25 public: | |
| 26 RenderProcessConnector(WebContents* web_contents); | |
|
boliu
2017/04/07 18:47:10
explicit
Jinsuk Kim
2017/04/10 05:11:47
Done.
| |
| 27 ~RenderProcessConnector() override; | |
| 28 | |
| 29 // WebContentsObserver implementation. | |
| 30 void RenderViewReady() override; | |
| 31 void RenderViewHostChanged(RenderViewHost* old_host, | |
| 32 RenderViewHost* new_host) override; | |
| 33 void DidAttachInterstitialPage() override; | |
| 34 void DidDetachInterstitialPage() override; | |
| 35 void WebContentsDestroyed() override; | |
| 36 | |
| 37 // Method to set itself to the |new_rwhva|, and null out the reference | |
| 38 // in |old_rwvha|. Example: | |
| 39 // | |
| 40 // if (old_rwhva) | |
| 41 // old_rwhva->set_object(nullptr); | |
| 42 // if (new_rwhva) | |
| 43 // new_rwhva->set_object(this); | |
| 44 virtual void UpdateRenderProcessConnection( | |
| 45 RenderWidgetHostViewAndroid* old_rwhva, | |
| 46 RenderWidgetHostViewAndroid* new_rhwva) = 0; | |
| 47 | |
| 48 RenderWidgetHostViewAndroid* rwhva() const { return rwhva_.get(); } | |
|
boliu
2017/04/07 18:47:10
Hmm, people will forget the null check in the futu
boliu
2017/04/07 18:48:40
Actually, even better idea, this should not exist
Jinsuk Kim
2017/04/10 05:11:47
Sorry but what should not exist? null checking? If
Jinsuk Kim
2017/04/10 05:11:47
Acknowledged.
| |
| 49 | |
| 50 private: | |
| 51 RenderWidgetHostViewAndroid* GetRenderWidgetHostViewAndroid() const; | |
| 52 void UpdateRenderWidgetHostView(RenderWidgetHostViewAndroid* new_rwhva); | |
| 53 | |
| 54 base::WeakPtr<RenderWidgetHostViewAndroid> rwhva_; | |
|
boliu
2017/04/07 18:47:10
DISALLOW_
Jinsuk Kim
2017/04/10 05:11:47
Done.
| |
| 55 }; | |
| 56 | |
| 57 } // namespace content | |
| 58 | |
| 59 #endif // CONTENT_BROWSER_ANDROID_RENDER_PROCESS_CONNECTOR_H_ | |
| OLD | NEW |