Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1427)

Unified Diff: content/browser/android/render_widget_host_connector.h

Issue 2792063003: Factor out RenderWidgetHostConnector (Closed)
Patch Set: base::ObserverList Created 3 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: content/browser/android/render_widget_host_connector.h
diff --git a/content/browser/android/render_widget_host_connector.h b/content/browser/android/render_widget_host_connector.h
new file mode 100644
index 0000000000000000000000000000000000000000..94c2a29f8704e14b8c6ab6584990cb685f81e110
--- /dev/null
+++ b/content/browser/android/render_widget_host_connector.h
@@ -0,0 +1,47 @@
+// Copyright 2017 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#ifndef CONTENT_BROWSER_ANDROID_RENDER_WIDGET_HOST_CONNECTOR_H_
+#define CONTENT_BROWSER_ANDROID_RENDER_WIDGET_HOST_CONNECTOR_H_
+
+#include "base/memory/weak_ptr.h"
+#include "content/browser/renderer_host/render_widget_host_view_android.h"
+#include "content/public/browser/web_contents_observer.h"
+
+namespace content {
+
+// A base class used to connect an object of the content layer lifecycle
+// to |RenderWidgetHostViewAndroid|. The inherting class needs to
+// override |UpdateRenderProcessConnection| to set itself to the RWHVA
+// brought up foreground, and null out its reference in the RWHVA going
+// away so it won't access the object any more.
+// This class owns itself and gets deleted when WebContents is deleted.
+class RenderWidgetHostConnector {
+ public:
+ explicit RenderWidgetHostConnector(WebContents* web_contents);
+ virtual ~RenderWidgetHostConnector();
+
+ // Method to set itself to the |new_rwhva|, and null out the reference
+ // in |old_rwvha|. Example:
+ //
+ // if (old_rwhva)
+ // old_rwhva->set_object(nullptr);
+ // if (new_rwhva)
+ // new_rwhva->set_object(this);
+ virtual void UpdateRenderProcessConnection(
+ RenderWidgetHostViewAndroid* old_rwhva,
+ RenderWidgetHostViewAndroid* new_rhwva) = 0;
+
+ RenderWidgetHostViewAndroid* GetRWHVAForTesting() const;
+
+ private:
+ class Observer;
+ std::unique_ptr<Observer> render_widget_observer_;
+
+ DISALLOW_COPY_AND_ASSIGN(RenderWidgetHostConnector);
+};
+
+} // namespace content
+
+#endif // CONTENT_BROWSER_ANDROID_RENDER_WIDGET_HOST_CONNECTOR_H_
« no previous file with comments | « content/browser/android/ime_adapter_android.cc ('k') | content/browser/android/render_widget_host_connector.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698