Commit 9dc47d86 authored by Dave Tapuska's avatar Dave Tapuska Committed by Commit Bot

Convert AwViewMsg_SetJsOnlineProperty to a Renderer mojom message.

Convert this message to a mojo message like ClearCache.

The associated channel can be bound when the AwRenderProcess object is
created because it doesn't need to be in the Ready state for it to get
attached. Likewise this object will be deleted when the render process
terminates so it doesn't need to worry about rebinding the mojo channel.

BUG=1146490

Change-Id: I2e3d6888debf85570117ba79fece34530fa12b50
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2522961
Commit-Queue: Dave Tapuska <dtapuska@chromium.org>
Reviewed-by: default avatarDaniel Cheng <dcheng@chromium.org>
Reviewed-by: default avatarBo <boliu@chromium.org>
Cr-Commit-Position: refs/heads/master@{#825382}
parent b9fd94b9
......@@ -1433,7 +1433,11 @@ void AwContents::SetJsOnlineProperty(JNIEnv* env,
const JavaParamRef<jobject>& obj,
jboolean network_up) {
DCHECK_CURRENTLY_ON(BrowserThread::UI);
render_view_host_ext_->SetJsOnlineProperty(network_up);
AwRenderProcess* aw_render_process =
AwRenderProcess::GetInstanceForRenderProcessHost(
web_contents_->GetMainFrame()->GetProcess());
aw_render_process->SetJsOnlineProperty(network_up);
}
void AwContents::TrimMemory(JNIEnv* env,
......
......@@ -46,6 +46,8 @@ AwRenderProcess::AwRenderProcess(RenderProcessHost* render_process_host)
if (render_process_host_->IsReady()) {
Ready();
}
render_process_host_->GetChannel()->GetRemoteAssociatedInterface(
&renderer_remote_);
render_process_host->AddObserver(this);
}
......@@ -57,12 +59,11 @@ AwRenderProcess::~AwRenderProcess() {
}
void AwRenderProcess::ClearCache() {
// If the renderer is in between the Init and the Ready phase (ie. hasn't
// started child process yet), clearing the cache will not do anything so it
// is fine to drop it here if there isn't a |renderer_remote_|.
if (renderer_remote_) {
renderer_remote_->ClearCache();
}
renderer_remote_->ClearCache();
}
void AwRenderProcess::SetJsOnlineProperty(bool network_up) {
renderer_remote_->SetJsOnlineProperty(network_up);
}
void AwRenderProcess::Ready() {
......@@ -70,10 +71,6 @@ void AwRenderProcess::Ready() {
Java_AwRenderProcess_setNative(AttachCurrentThread(), java_obj_,
reinterpret_cast<jlong>(this));
renderer_remote_.reset();
render_process_host_->GetChannel()->GetRemoteAssociatedInterface(
&renderer_remote_);
}
void AwRenderProcess::Cleanup() {
......
......@@ -33,6 +33,7 @@ class AwRenderProcess : public content::RenderProcessHostObserver,
~AwRenderProcess() override;
void ClearCache();
void SetJsOnlineProperty(bool network_up);
private:
void Ready();
......
......@@ -109,11 +109,6 @@ void AwRenderViewHostExt::SetWillSuppressErrorPage(bool suppress) {
will_suppress_error_page_ = suppress;
}
void AwRenderViewHostExt::SetJsOnlineProperty(bool network_up) {
web_contents()->GetRenderViewHost()->Send(
new AwViewMsg_SetJsOnlineProperty(network_up));
}
void AwRenderViewHostExt::SmoothScroll(int target_x,
int target_y,
base::TimeDelta duration) {
......
......@@ -71,7 +71,6 @@ class AwRenderViewHostExt : public content::WebContentsObserver {
void SetInitialPageScale(double page_scale_factor);
void SetBackgroundColor(SkColor c);
void SetWillSuppressErrorPage(bool suppress);
void SetJsOnlineProperty(bool network_up);
void SmoothScroll(int target_x, int target_y, base::TimeDelta duration);
......
......@@ -10,4 +10,7 @@ interface Renderer {
// Clear the memory cache. The cache is process wide so this will influence
// other webview instances as well.
ClearCache();
// Adjusts the javascript 'online' property value.
SetJsOnlineProperty(bool network_up);
};
......@@ -68,9 +68,6 @@ IPC_MESSAGE_ROUTED0(AwViewMsg_ResetScrollAndScaleState)
IPC_MESSAGE_ROUTED1(AwViewMsg_SetInitialPageScale,
double /* page_scale_factor */)
IPC_MESSAGE_CONTROL1(AwViewMsg_SetJsOnlineProperty,
bool /* network_up */)
// Tells blink to smooth scroll to the specified location within |duration_ms|.
IPC_MESSAGE_ROUTED3(AwViewMsg_SmoothScroll,
int /* target_x */,
......
......@@ -4,8 +4,6 @@
#include "android_webview/renderer/aw_render_thread_observer.h"
#include "android_webview/common/render_view_messages.h"
#include "ipc/ipc_message_macros.h"
#include "third_party/blink/public/common/associated_interfaces/associated_interface_registry.h"
#include "third_party/blink/public/platform/web_cache.h"
#include "third_party/blink/public/platform/web_network_state_notifier.h"
......@@ -18,16 +16,6 @@ AwRenderThreadObserver::AwRenderThreadObserver() {
AwRenderThreadObserver::~AwRenderThreadObserver() {
}
bool AwRenderThreadObserver::OnControlMessageReceived(
const IPC::Message& message) {
bool handled = true;
IPC_BEGIN_MESSAGE_MAP(AwRenderThreadObserver, message)
IPC_MESSAGE_HANDLER(AwViewMsg_SetJsOnlineProperty, OnSetJsOnlineProperty)
IPC_MESSAGE_UNHANDLED(handled = false)
IPC_END_MESSAGE_MAP()
return handled;
}
void AwRenderThreadObserver::RegisterMojoInterfaces(
blink::AssociatedInterfaceRegistry* associated_interfaces) {
// base::Unretained can be used here because the associated_interfaces
......@@ -52,7 +40,7 @@ void AwRenderThreadObserver::ClearCache() {
blink::WebCache::Clear();
}
void AwRenderThreadObserver::OnSetJsOnlineProperty(bool network_up) {
void AwRenderThreadObserver::SetJsOnlineProperty(bool network_up) {
blink::WebNetworkStateNotifier::SetOnLine(network_up);
}
......
......@@ -21,7 +21,6 @@ class AwRenderThreadObserver : public content::RenderThreadObserver,
~AwRenderThreadObserver() override;
// content::RenderThreadObserver implementation.
bool OnControlMessageReceived(const IPC::Message& message) override;
void RegisterMojoInterfaces(
blink::AssociatedInterfaceRegistry* associated_interfaces) override;
void UnregisterMojoInterfaces(
......@@ -30,10 +29,10 @@ class AwRenderThreadObserver : public content::RenderThreadObserver,
private:
// mojom::Renderer overrides:
void ClearCache() override;
void SetJsOnlineProperty(bool network_up) override;
void OnRendererAssociatedRequest(
mojo::PendingAssociatedReceiver<mojom::Renderer> receiver);
void OnSetJsOnlineProperty(bool network_up);
mojo::AssociatedReceiver<mojom::Renderer> receiver_{this};
};
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment