Commit 1aacb731 authored by Shawn Gallea's avatar Shawn Gallea Committed by Commit Bot

Add webview functionality to PlatformViewsService

WebviewService will eventually be deprecated, this allows
PlatformViewsService to create webviews.

Bug: Internal b/144275588
Test: Build cast_shell
Change-Id: I96251d199d7c466e13be5fc05769a1d0c4717beb
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1907076Reviewed-by: default avatarDaniel Nicoara <dnicoara@chromium.org>
Commit-Queue: Shawn Gallea <sagallea@google.com>
Cr-Commit-Position: refs/heads/master@{#714298}
parent fdeb66cd
......@@ -7,6 +7,7 @@
#include "base/callback.h"
#include "chromecast/browser/webview/cast_app_rpc_instance.h"
#include "chromecast/browser/webview/web_contents_provider.h"
#include "chromecast/browser/webview/webview_rpc_instance.h"
#include "third_party/grpc/src/include/grpcpp/grpcpp.h"
#include "third_party/grpc/src/include/grpcpp/security/server_credentials.h"
#include "third_party/grpc/src/include/grpcpp/server_builder.h"
......@@ -35,9 +36,11 @@ void PlatformViewsAsyncService::ThreadMain() {
void* tag;
bool ok;
// This self-deletes.
// These self-delete.
new CastAppRpcInstance(service_.get(), cq_.get(), ui_task_runner_,
&window_manager_, web_contents_provider_);
new WebviewRpcInstance(service_.get(), cq_.get(), ui_task_runner_,
&window_manager_);
// This thread is joined when this service is destroyed.
while (cq_->Next(&tag, &ok)) {
reinterpret_cast<GrpcCallback*>(tag)->Run(ok);
......
......@@ -17,20 +17,40 @@
namespace chromecast {
// TODO(sagallea): Remove this when ready to deprecate WebviewService.
WebviewRpcInstance::WebviewRpcInstance(
webview::WebviewService::AsyncService* service,
grpc::ServerCompletionQueue* cq,
scoped_refptr<base::SingleThreadTaskRunner> task_runner,
WebviewWindowManager* window_manager)
: PlatformViewsRpcInstance(cq, task_runner, window_manager),
service_(service) {
service_->RequestCreateWebview(&ctx_, &io_, cq_, cq_, &init_callback_);
webview_service_(service),
platform_views_service_(nullptr) {
webview_service_->RequestCreateWebview(&ctx_, &io_, cq_, cq_,
&init_callback_);
}
WebviewRpcInstance::WebviewRpcInstance(
webview::PlatformViewsService::AsyncService* service,
grpc::ServerCompletionQueue* cq,
scoped_refptr<base::SingleThreadTaskRunner> task_runner,
WebviewWindowManager* window_manager)
: PlatformViewsRpcInstance(cq, task_runner, window_manager),
webview_service_(nullptr),
platform_views_service_(service) {
platform_views_service_->RequestCreateWebview(&ctx_, &io_, cq_, cq_,
&init_callback_);
}
WebviewRpcInstance::~WebviewRpcInstance() {}
void WebviewRpcInstance::CreateNewInstance() {
new WebviewRpcInstance(service_, cq_, task_runner_, window_manager_);
if (webview_service_)
new WebviewRpcInstance(webview_service_, cq_, task_runner_,
window_manager_);
else
new WebviewRpcInstance(platform_views_service_, cq_, task_runner_,
window_manager_);
}
bool WebviewRpcInstance::Initialize() {
......
......@@ -15,6 +15,10 @@ class WebviewRpcInstance : public PlatformViewsRpcInstance {
grpc::ServerCompletionQueue* cq,
scoped_refptr<base::SingleThreadTaskRunner> task_runner,
WebviewWindowManager* window_manager);
WebviewRpcInstance(webview::PlatformViewsService::AsyncService* service,
grpc::ServerCompletionQueue* cq,
scoped_refptr<base::SingleThreadTaskRunner> task_runner,
WebviewWindowManager* window_manager);
~WebviewRpcInstance() override;
protected:
......@@ -23,7 +27,8 @@ class WebviewRpcInstance : public PlatformViewsRpcInstance {
private:
void CreateWebview(int app_id, int window_id);
webview::WebviewService::AsyncService* service_;
webview::WebviewService::AsyncService* webview_service_;
webview::PlatformViewsService::AsyncService* platform_views_service_;
DISALLOW_COPY_AND_ASSIGN(WebviewRpcInstance);
};
......
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