| OLD | NEW |
| 1 // Copyright 2017 The Chromium Authors. All rights reserved. | 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 | 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_BROWSER_ANDROID_RENDER_WIDGET_HOST_CONNECTOR_H_ | 5 #ifndef CONTENT_BROWSER_ANDROID_RENDER_WIDGET_HOST_CONNECTOR_H_ |
| 6 #define CONTENT_BROWSER_ANDROID_RENDER_WIDGET_HOST_CONNECTOR_H_ | 6 #define CONTENT_BROWSER_ANDROID_RENDER_WIDGET_HOST_CONNECTOR_H_ |
| 7 | 7 |
| 8 #include "base/memory/weak_ptr.h" | 8 #include "base/memory/weak_ptr.h" |
| 9 #include "content/browser/renderer_host/render_widget_host_view_android.h" | 9 #include "content/browser/renderer_host/render_widget_host_view_android.h" |
| 10 #include "content/public/browser/web_contents_observer.h" | 10 #include "content/public/browser/web_contents_observer.h" |
| 11 | 11 |
| 12 namespace content { | 12 namespace content { |
| 13 | 13 |
| 14 // A base class used to connect an object of the content layer lifecycle | 14 // A base class used to connect an object of the content layer lifecycle |
| 15 // to |RenderWidgetHostViewAndroid|. The inherting class needs to | 15 // to |RenderWidgetHostViewAndroid|. The inherting class needs to |
| 16 // override |UpdateRenderProcessConnection| to set itself to the RWHVA | 16 // override |UpdateRenderProcessConnection| to set itself to the RWHVA |
| 17 // brought up foreground, and null out its reference in the RWHVA going | 17 // brought up foreground, and null out its reference in the RWHVA going |
| 18 // away so it won't access the object any more. | 18 // away so it won't access the object any more. |
| 19 // This class owns itself and gets deleted when WebContents is deleted. | 19 // This class owns itself and gets deleted when WebContents is deleted. |
| 20 class RenderWidgetHostConnector { | 20 class RenderWidgetHostConnector { |
| 21 public: | 21 public: |
| 22 explicit RenderWidgetHostConnector(WebContents* web_contents); | 22 explicit RenderWidgetHostConnector(WebContents* web_contents); |
| 23 virtual ~RenderWidgetHostConnector(); | 23 virtual ~RenderWidgetHostConnector(); |
| 24 | 24 |
| 25 // Establish initial connection to rwhva if it is present. |
| 26 void Initialize(); |
| 27 |
| 25 // Method to set itself to the |new_rwhva|, and null out the reference | 28 // Method to set itself to the |new_rwhva|, and null out the reference |
| 26 // in |old_rwvha|. Example: | 29 // in |old_rwvha|. Example: |
| 27 // | 30 // |
| 28 // if (old_rwhva) | 31 // if (old_rwhva) |
| 29 // old_rwhva->set_object(nullptr); | 32 // old_rwhva->set_object(nullptr); |
| 30 // if (new_rwhva) | 33 // if (new_rwhva) |
| 31 // new_rwhva->set_object(this); | 34 // new_rwhva->set_object(this); |
| 32 virtual void UpdateRenderProcessConnection( | 35 virtual void UpdateRenderProcessConnection( |
| 33 RenderWidgetHostViewAndroid* old_rwhva, | 36 RenderWidgetHostViewAndroid* old_rwhva, |
| 34 RenderWidgetHostViewAndroid* new_rhwva) = 0; | 37 RenderWidgetHostViewAndroid* new_rhwva) = 0; |
| 35 | 38 |
| 36 RenderWidgetHostViewAndroid* GetRWHVAForTesting() const; | 39 RenderWidgetHostViewAndroid* GetRWHVAForTesting() const; |
| 37 | 40 |
| 38 private: | 41 private: |
| 39 class Observer; | 42 class Observer; |
| 40 std::unique_ptr<Observer> render_widget_observer_; | 43 std::unique_ptr<Observer> render_widget_observer_; |
| 41 | 44 |
| 42 DISALLOW_COPY_AND_ASSIGN(RenderWidgetHostConnector); | 45 DISALLOW_COPY_AND_ASSIGN(RenderWidgetHostConnector); |
| 43 }; | 46 }; |
| 44 | 47 |
| 45 } // namespace content | 48 } // namespace content |
| 46 | 49 |
| 47 #endif // CONTENT_BROWSER_ANDROID_RENDER_WIDGET_HOST_CONNECTOR_H_ | 50 #endif // CONTENT_BROWSER_ANDROID_RENDER_WIDGET_HOST_CONNECTOR_H_ |
| OLD | NEW |