Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
qq_34031325
engine
提交
65fcbf7c
E
engine
项目概览
qq_34031325
/
engine
与 Fork 源项目一致
从无法访问的项目Fork
通知
1
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
E
engine
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
65fcbf7c
编写于
3月 13, 2017
作者:
Z
Zachary Anderson
提交者:
GitHub
3月 13, 2017
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Add listViews service extension for the content handler (#3468)
上级
e0c702e3
变更
10
隐藏空白更改
内联
并排
Showing
10 changed file
with
220 addition
and
0 deletion
+220
-0
content_handler/BUILD.gn
content_handler/BUILD.gn
+2
-0
content_handler/app.cc
content_handler/app.cc
+46
-0
content_handler/app.h
content_handler/app.h
+15
-0
content_handler/application_controller_impl.cc
content_handler/application_controller_impl.cc
+13
-0
content_handler/application_controller_impl.h
content_handler/application_controller_impl.h
+5
-0
content_handler/runtime_holder.cc
content_handler/runtime_holder.cc
+13
-0
content_handler/runtime_holder.h
content_handler/runtime_holder.h
+3
-0
content_handler/service_protocol_hooks.cc
content_handler/service_protocol_hooks.cc
+92
-0
content_handler/service_protocol_hooks.h
content_handler/service_protocol_hooks.h
+29
-0
travis/licenses_golden/licenses_flutter
travis/licenses_golden/licenses_flutter
+2
-0
未找到文件。
content_handler/BUILD.gn
浏览文件 @
65fcbf7c
...
...
@@ -27,6 +27,8 @@ executable("content_handler") {
"rasterizer.h",
"runtime_holder.cc",
"runtime_holder.h",
"service_protocol_hooks.cc",
"service_protocol_hooks.h",
"software_rasterizer.cc",
"software_rasterizer.h",
]
...
...
content_handler/app.cc
浏览文件 @
65fcbf7c
...
...
@@ -11,6 +11,8 @@
#include "apps/tracing/lib/trace/provider.h"
#include "flutter/common/settings.h"
#include "flutter/common/threads.h"
#include "flutter/content_handler/service_protocol_hooks.h"
#include "flutter/runtime/dart_init.h"
#include "flutter/runtime/runtime_init.h"
#include "flutter/sky/engine/platform/fonts/fuchsia/FontCacheFuchsia.h"
#include "lib/ftl/macros.h"
...
...
@@ -20,6 +22,8 @@
namespace
flutter_runner
{
namespace
{
static
App
*
g_app
=
nullptr
;
void
QuitMessageLoop
()
{
mtl
::
MessageLoop
::
GetCurrent
()
->
QuitNow
();
}
...
...
@@ -27,6 +31,7 @@ void QuitMessageLoop() {
}
// namespace
App
::
App
()
{
g_app
=
this
;
context_
=
app
::
ApplicationContext
::
CreateFromStartupInfo
();
tracing
::
InitializeTracer
(
context_
.
get
(),
{});
...
...
@@ -57,6 +62,9 @@ App::App() {
blink
::
Settings
::
Set
(
settings
);
blink
::
InitRuntime
();
blink
::
SetRegisterNativeServiceProtocolExtensionHook
(
ServiceProtocolHooks
::
RegisterHooks
);
blink
::
SetFontProvider
(
context_
->
ConnectToEnvironmentService
<
fonts
::
FontProvider
>
());
...
...
@@ -70,6 +78,44 @@ App::~App() {
icu_data
::
Release
();
blink
::
Threads
::
Gpu
()
->
PostTask
(
QuitMessageLoop
);
blink
::
Threads
::
IO
()
->
PostTask
(
QuitMessageLoop
);
g_app
=
nullptr
;
}
App
&
App
::
Shared
()
{
FTL_DCHECK
(
g_app
);
return
*
g_app
;
}
void
App
::
WaitForPlatformViewIds
(
std
::
vector
<
PlatformViewInfo
>*
platform_view_ids
)
{
ftl
::
AutoResetWaitableEvent
latch
;
blink
::
Threads
::
UI
()
->
PostTask
([
this
,
platform_view_ids
,
&
latch
]()
{
WaitForPlatformViewsIdsUIThread
(
platform_view_ids
,
&
latch
);
});
latch
.
Wait
();
}
void
App
::
WaitForPlatformViewsIdsUIThread
(
std
::
vector
<
PlatformViewInfo
>*
platform_view_ids
,
ftl
::
AutoResetWaitableEvent
*
latch
)
{
for
(
auto
it
=
controllers_
.
begin
();
it
!=
controllers_
.
end
();
it
++
)
{
ApplicationControllerImpl
*
controller
=
it
->
first
;
if
(
!
controller
)
{
continue
;
}
PlatformViewInfo
info
;
// TODO(zra): We should create real IDs for these instead of relying on the
// address of the controller. Maybe just use the UI Isolate main port?
info
.
view_id
=
reinterpret_cast
<
uintptr_t
>
(
controller
);
info
.
isolate_id
=
controller
->
GetUIIsolateMainPort
();
info
.
isolate_name
=
controller
->
GetUIIsolateName
();
platform_view_ids
->
push_back
(
info
);
}
latch
->
Signal
();
}
void
App
::
StartApplication
(
...
...
content_handler/app.h
浏览文件 @
65fcbf7c
...
...
@@ -13,6 +13,7 @@
#include "flutter/content_handler/application_controller_impl.h"
#include "flutter/content_handler/content_handler_thread.h"
#include "lib/ftl/macros.h"
#include "lib/ftl/synchronization/waitable_event.h"
namespace
flutter_runner
{
...
...
@@ -21,6 +22,8 @@ class App : public app::ApplicationRunner {
App
();
~
App
();
static
App
&
Shared
();
// |app::ApplicationRunner| implementation:
void
StartApplication
(
app
::
ApplicationPackagePtr
application
,
...
...
@@ -30,7 +33,19 @@ class App : public app::ApplicationRunner {
void
Destroy
(
ApplicationControllerImpl
*
controller
);
struct
PlatformViewInfo
{
uintptr_t
view_id
;
int64_t
isolate_id
;
std
::
string
isolate_name
;
};
void
WaitForPlatformViewIds
(
std
::
vector
<
PlatformViewInfo
>*
platform_view_ids
);
private:
void
WaitForPlatformViewsIdsUIThread
(
std
::
vector
<
PlatformViewInfo
>*
platform_view_ids
,
ftl
::
AutoResetWaitableEvent
*
latch
);
std
::
unique_ptr
<
app
::
ApplicationContext
>
context_
;
std
::
unique_ptr
<
Thread
>
gpu_thread_
;
std
::
unique_ptr
<
Thread
>
io_thread_
;
...
...
content_handler/application_controller_impl.cc
浏览文件 @
65fcbf7c
...
...
@@ -79,4 +79,17 @@ void ApplicationControllerImpl::CreateView(
std
::
move
(
services
));
}
Dart_Port
ApplicationControllerImpl
::
GetUIIsolateMainPort
()
{
if
(
!
runtime_holder_
)
return
ILLEGAL_PORT
;
return
runtime_holder_
->
GetUIIsolateMainPort
();
}
std
::
string
ApplicationControllerImpl
::
GetUIIsolateName
()
{
if
(
!
runtime_holder_
)
{
return
""
;
}
return
runtime_holder_
->
GetUIIsolateName
();
}
}
// namespace flutter_runner
content_handler/application_controller_impl.h
浏览文件 @
65fcbf7c
...
...
@@ -11,9 +11,11 @@
#include "application/services/application_runner.fidl.h"
#include "application/services/service_provider.fidl.h"
#include "apps/mozart/services/views/view_provider.fidl.h"
#include "dart/runtime/include/dart_api.h"
#include "lib/fidl/cpp/bindings/binding.h"
#include "lib/fidl/cpp/bindings/binding_set.h"
#include "lib/ftl/macros.h"
#include "lib/ftl/synchronization/waitable_event.h"
namespace
flutter_runner
{
class
App
;
...
...
@@ -47,6 +49,9 @@ class ApplicationControllerImpl : public app::ApplicationController,
fidl
::
InterfaceRequest
<
mozart
::
ViewOwner
>
view_owner_request
,
fidl
::
InterfaceRequest
<
app
::
ServiceProvider
>
services
)
override
;
Dart_Port
GetUIIsolateMainPort
();
std
::
string
GetUIIsolateName
();
private:
void
StartRuntimeIfReady
();
...
...
content_handler/runtime_holder.cc
浏览文件 @
65fcbf7c
...
...
@@ -169,6 +169,19 @@ void RuntimeHolder::CreateView(
}
}
Dart_Port
RuntimeHolder
::
GetUIIsolateMainPort
()
{
if
(
!
runtime_
)
return
ILLEGAL_PORT
;
return
runtime_
->
GetMainPort
();
}
std
::
string
RuntimeHolder
::
GetUIIsolateName
()
{
if
(
!
runtime_
)
{
return
""
;
}
return
runtime_
->
GetIsolateName
();
}
void
RuntimeHolder
::
ScheduleFrame
()
{
if
(
pending_invalidation_
||
deferred_invalidation_callback_
)
return
;
...
...
content_handler/runtime_holder.h
浏览文件 @
65fcbf7c
...
...
@@ -45,6 +45,9 @@ class RuntimeHolder : public blink::RuntimeDelegate,
fidl
::
InterfaceRequest
<
mozart
::
ViewOwner
>
view_owner_request
,
fidl
::
InterfaceRequest
<
app
::
ServiceProvider
>
services
);
Dart_Port
GetUIIsolateMainPort
();
std
::
string
GetUIIsolateName
();
private:
// |blink::RuntimeDelegate| implementation:
void
ScheduleFrame
()
override
;
...
...
content_handler/service_protocol_hooks.cc
0 → 100644
浏览文件 @
65fcbf7c
// 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.
#include "flutter/content_handler/service_protocol_hooks.h"
#include <string.h>
#include <string>
#include <vector>
#include "flutter/common/threads.h"
#include "flutter/content_handler/app.h"
#include "lib/ftl/memory/weak_ptr.h"
namespace
flutter_runner
{
namespace
{
constexpr
char
kViewIdPrefx
[]
=
"_flutterView/"
;
static
void
AppendIsolateRef
(
std
::
stringstream
*
stream
,
int64_t
main_port
,
const
std
::
string
name
)
{
*
stream
<<
"{
\"
type
\"
:
\"
@Isolate
\"
,
\"
fixedId
\"
:true,
\"
id
\"
:
\"
isolates/"
;
*
stream
<<
main_port
<<
"
\"
,
\"
name
\"
:
\"
"
<<
name
<<
"
\"
,"
;
*
stream
<<
"
\"
number
\"
:
\"
"
<<
main_port
<<
"
\"
}"
;
}
static
void
AppendFlutterView
(
std
::
stringstream
*
stream
,
uintptr_t
view_id
,
int64_t
isolate_id
,
const
std
::
string
isolate_name
)
{
*
stream
<<
"{
\"
type
\"
:
\"
FlutterView
\"
,
\"
id
\"
:
\"
"
<<
kViewIdPrefx
<<
"0x"
<<
std
::
hex
<<
view_id
<<
std
::
dec
<<
"
\"
"
;
if
(
isolate_id
!=
ILLEGAL_PORT
)
{
// Append the isolate (if it exists).
*
stream
<<
","
<<
"
\"
isolate
\"
:"
;
AppendIsolateRef
(
stream
,
isolate_id
,
isolate_name
);
}
*
stream
<<
"}"
;
}
}
// namespace
void
ServiceProtocolHooks
::
RegisterHooks
(
bool
running_precompiled_code
)
{
// Listing of FlutterViews.
Dart_RegisterRootServiceRequestCallback
(
kListViewsExtensionName
,
&
ListViews
,
nullptr
);
}
const
char
*
ServiceProtocolHooks
::
kListViewsExtensionName
=
"_flutter.listViews"
;
bool
ServiceProtocolHooks
::
ListViews
(
const
char
*
method
,
const
char
**
param_keys
,
const
char
**
param_values
,
intptr_t
num_params
,
void
*
user_data
,
const
char
**
json_object
)
{
// Ask the App for the list of platform views. This will run a task on
// the UI thread before returning.
App
&
app
=
App
::
Shared
();
std
::
vector
<
App
::
PlatformViewInfo
>
platform_views
;
app
.
WaitForPlatformViewIds
(
&
platform_views
);
std
::
stringstream
response
;
response
<<
"{
\"
type
\"
:
\"
FlutterViewList
\"
,
\"
views
\"
:["
;
bool
prefix_comma
=
false
;
for
(
auto
it
=
platform_views
.
begin
();
it
!=
platform_views
.
end
();
it
++
)
{
uintptr_t
view_id
=
it
->
view_id
;
int64_t
isolate_id
=
it
->
isolate_id
;
const
std
::
string
&
isolate_name
=
it
->
isolate_name
;
if
(
!
view_id
)
{
continue
;
}
if
(
prefix_comma
)
{
response
<<
','
;
}
else
{
prefix_comma
=
true
;
}
AppendFlutterView
(
&
response
,
view_id
,
isolate_id
,
isolate_name
);
}
response
<<
"]}"
;
// Copy the response.
*
json_object
=
strdup
(
response
.
str
().
c_str
());
return
true
;
}
}
// namespace flutter_runner
content_handler/service_protocol_hooks.h
0 → 100644
浏览文件 @
65fcbf7c
// 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 FLUTTER_CONTENT_HANDLER_SERVICE_PROTOCOL_HOOKS_H_
#define FLUTTER_CONTENT_HANDLER_SERVICE_PROTOCOL_HOOKS_H_
#include "dart/runtime/include/dart_tools_api.h"
#include "lib/ftl/synchronization/waitable_event.h"
namespace
flutter_runner
{
class
ServiceProtocolHooks
{
public:
static
void
RegisterHooks
(
bool
running_precompiled_code
);
private:
static
const
char
*
kListViewsExtensionName
;
static
bool
ListViews
(
const
char
*
method
,
const
char
**
param_keys
,
const
char
**
param_values
,
intptr_t
num_params
,
void
*
user_data
,
const
char
**
json_object
);
};
}
// namespace flutter_runner
#endif // FLUTTER_CONTENT_HANDLER_SERVICE_PROTOCOL_HOOKS_H_
travis/licenses_golden/licenses_flutter
浏览文件 @
65fcbf7c
...
...
@@ -1904,6 +1904,8 @@ FILE: ../../../flutter/content_handler/content_handler_thread.cc
FILE: ../../../flutter/content_handler/content_handler_thread.h
FILE: ../../../flutter/content_handler/direct_input.cc
FILE: ../../../flutter/content_handler/direct_input.h
FILE: ../../../flutter/content_handler/service_protocol_hooks.cc
FILE: ../../../flutter/content_handler/service_protocol_hooks.h
FILE: ../../../flutter/content_handler/software_rasterizer.cc
FILE: ../../../flutter/content_handler/software_rasterizer.h
FILE: ../../../flutter/content_handler/vulkan_rasterizer.cc
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录