Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
sxychenjing
engine
提交
1e23d648
E
engine
项目概览
sxychenjing
/
engine
与 Fork 源项目一致
从无法访问的项目Fork
通知
3
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,发现更多精彩内容 >>
未验证
提交
1e23d648
编写于
1月 15, 2018
作者:
S
Sarah Zakarias
提交者:
GitHub
1月 15, 2018
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Run Fuchsia apps without flx (#4550)
上级
e7e94c63
变更
5
隐藏空白更改
内联
并排
Showing
5 changed file
with
87 addition
and
16 deletion
+87
-16
assets/directory_asset_bundle.cc
assets/directory_asset_bundle.cc
+35
-5
assets/directory_asset_bundle.h
assets/directory_asset_bundle.h
+4
-0
content_handler/application_controller_impl.cc
content_handler/application_controller_impl.cc
+5
-3
content_handler/runtime_holder.cc
content_handler/runtime_holder.cc
+39
-8
content_handler/runtime_holder.h
content_handler/runtime_holder.h
+4
-0
未找到文件。
assets/directory_asset_bundle.cc
浏览文件 @
1e23d648
...
...
@@ -7,21 +7,48 @@
#include <fcntl.h>
#if !defined(OS_WIN)
#include <unistd.h>
#endif
#include <utility>
#include "lib/fxl/files/eintr_wrapper.h"
#include "lib/fxl/files/file.h"
#include "lib/fxl/files/path.h"
#include "lib/fxl/files/unique_fd.h"
#include "lib/fxl/portable_unistd.h"
namespace
blink
{
bool
DirectoryAssetBundle
::
GetAsBuffer
(
const
std
::
string
&
asset_name
,
std
::
vector
<
uint8_t
>*
data
)
{
if
(
fd_
.
is_valid
())
{
#if defined(OS_WIN)
// This code path is not valid in a Windows environment.
return
false
;
#else
fxl
::
UniqueFD
asset_file
(
openat
(
fd_
.
get
(),
asset_name
.
c_str
(),
O_RDONLY
));
if
(
!
asset_file
.
is_valid
())
{
FXL_LOG
(
ERROR
)
<<
"Could not load asset "
<<
asset_name
;
return
false
;
}
constexpr
size_t
kBufferSize
=
1
<<
16
;
size_t
offset
=
0
;
ssize_t
bytes_read
=
0
;
do
{
offset
+=
bytes_read
;
data
->
resize
(
offset
+
kBufferSize
);
bytes_read
=
read
(
asset_file
.
get
(),
&
(
*
data
)[
offset
],
kBufferSize
);
}
while
(
bytes_read
>
0
);
if
(
bytes_read
<
0
)
{
FXL_LOG
(
ERROR
)
<<
"Reading "
<<
asset_name
<<
" failed"
;
data
->
clear
();
return
false
;
}
data
->
resize
(
offset
+
bytes_read
);
return
true
;
#endif
}
std
::
string
asset_path
=
GetPathForAsset
(
asset_name
);
if
(
asset_path
.
empty
())
return
false
;
...
...
@@ -31,7 +58,10 @@ bool DirectoryAssetBundle::GetAsBuffer(const std::string& asset_name,
DirectoryAssetBundle
::~
DirectoryAssetBundle
()
{}
DirectoryAssetBundle
::
DirectoryAssetBundle
(
std
::
string
directory
)
:
directory_
(
std
::
move
(
directory
))
{}
:
directory_
(
std
::
move
(
directory
)),
fd_
()
{}
DirectoryAssetBundle
::
DirectoryAssetBundle
(
fxl
::
UniqueFD
fd
)
:
fd_
(
std
::
move
(
fd
))
{}
std
::
string
DirectoryAssetBundle
::
GetPathForAsset
(
const
std
::
string
&
asset_name
)
{
...
...
assets/directory_asset_bundle.h
浏览文件 @
1e23d648
...
...
@@ -8,6 +8,7 @@
#include <string>
#include <vector>
#include "lib/fxl/files/unique_fd.h"
#include "lib/fxl/macros.h"
#include "lib/fxl/memory/ref_counted.h"
...
...
@@ -17,6 +18,8 @@ class DirectoryAssetBundle
:
public
fxl
::
RefCountedThreadSafe
<
DirectoryAssetBundle
>
{
public:
explicit
DirectoryAssetBundle
(
std
::
string
directory
);
// Expects fd to be valid, otherwise the file descriptor is ignored.
explicit
DirectoryAssetBundle
(
fxl
::
UniqueFD
fd
);
~
DirectoryAssetBundle
();
bool
GetAsBuffer
(
const
std
::
string
&
asset_name
,
std
::
vector
<
uint8_t
>*
data
);
...
...
@@ -25,6 +28,7 @@ class DirectoryAssetBundle
private:
const
std
::
string
directory_
;
fxl
::
UniqueFD
fd_
;
FXL_DISALLOW_COPY_AND_ASSIGN
(
DirectoryAssetBundle
);
};
...
...
content_handler/application_controller_impl.cc
浏览文件 @
1e23d648
...
...
@@ -32,9 +32,11 @@ ApplicationControllerImpl::ApplicationControllerImpl(
}
std
::
vector
<
char
>
bundle
;
if
(
!
fsl
::
VectorFromVmo
(
std
::
move
(
application
->
data
),
&
bundle
))
{
FXL_LOG
(
ERROR
)
<<
"Failed to receive bundle."
;
return
;
if
(
application
->
data
)
{
if
(
!
fsl
::
VectorFromVmo
(
std
::
move
(
application
->
data
),
&
bundle
))
{
FXL_LOG
(
ERROR
)
<<
"Failed to receive bundle."
;
return
;
}
}
// TODO(jeffbrown): Decide what to do with command-line arguments and
...
...
content_handler/runtime_holder.cc
浏览文件 @
1e23d648
...
...
@@ -5,6 +5,7 @@
#include "flutter/content_handler/runtime_holder.h"
#include <dlfcn.h>
#include <fcntl.h>
#include <fdio/namespace.h>
#include <zircon/dlfcn.h>
#include <utility>
...
...
@@ -23,6 +24,7 @@
#include "flutter/runtime/runtime_init.h"
#include "lib/app/cpp/connect.h"
#include "lib/fsl/vmo/vector.h"
#include "lib/fxl/files/unique_fd.h"
#include "lib/fxl/functional/make_copyable.h"
#include "lib/fxl/logging.h"
#include "lib/fxl/time/time_delta.h"
...
...
@@ -45,6 +47,7 @@ constexpr char kAssetChannel[] = "flutter/assets";
constexpr
char
kKeyEventChannel
[]
=
"flutter/keyevent"
;
constexpr
char
kTextInputChannel
[]
=
"flutter/textinput"
;
constexpr
char
kFlutterPlatformChannel
[]
=
"flutter/platform"
;
constexpr
char
kFuchsiaPackageResourceDirectory
[]
=
"pkg/data"
;
void
SetThreadName
(
fxl
::
RefPtr
<
fxl
::
TaskRunner
>
runner
,
std
::
string
name
)
{
runner
->
PostTask
([
name
]()
{
...
...
@@ -117,6 +120,7 @@ void RuntimeHolder::Init(
context_
->
ConnectToEnvironmentService
(
view_manager_
.
NewRequest
());
// TODO(zarah): remove bundle entirely once flx is removed.
InitRootBundle
(
std
::
move
(
bundle
));
const
uint8_t
*
vm_snapshot_data
;
...
...
@@ -130,7 +134,7 @@ void RuntimeHolder::Init(
default_isolate_snapshot_instr
=
::
kDartIsolateCoreSnapshotInstructions
;
}
else
{
std
::
vector
<
uint8_t
>
dylib_blob
;
if
(
!
asset_store_
->
G
etAsBuffer
(
kDylibKey
,
&
dylib_blob
))
{
if
(
!
GetAss
etAsBuffer
(
kDylibKey
,
&
dylib_blob
))
{
FXL_LOG
(
ERROR
)
<<
"Failed to extract app dylib"
;
return
;
}
...
...
@@ -193,8 +197,8 @@ void RuntimeHolder::CreateView(
std
::
vector
<
uint8_t
>
kernel
;
std
::
vector
<
uint8_t
>
snapshot
;
if
(
!
Dart_IsPrecompiledRuntime
())
{
if
(
!
asset_store_
->
G
etAsBuffer
(
kKernelKey
,
&
kernel
)
&&
!
asset_store_
->
G
etAsBuffer
(
kSnapshotKey
,
&
snapshot
))
{
if
(
!
GetAss
etAsBuffer
(
kKernelKey
,
&
kernel
)
&&
!
GetAss
etAsBuffer
(
kSnapshotKey
,
&
snapshot
))
{
FXL_LOG
(
ERROR
)
<<
"Unable to load kernel or snapshot from root bundle."
;
return
;
}
...
...
@@ -387,8 +391,11 @@ void RuntimeHolder::HandlePlatformMessage(
}
void
RuntimeHolder
::
DidCreateMainIsolate
(
Dart_Isolate
isolate
)
{
if
(
asset_store_
)
if
(
directory_asset_bundle_
)
{
blink
::
AssetFontSelector
::
Install
(
directory_asset_bundle_
);
}
else
if
(
asset_store_
)
{
blink
::
AssetFontSelector
::
Install
(
asset_store_
);
}
InitDartIoInternal
();
InitFuchsia
();
InitMozartInternal
();
...
...
@@ -448,9 +455,26 @@ void RuntimeHolder::InitMozartInternal() {
}
void
RuntimeHolder
::
InitRootBundle
(
std
::
vector
<
char
>
bundle
)
{
root_bundle_data_
=
std
::
move
(
bundle
);
asset_store_
=
fxl
::
MakeRefCounted
<
blink
::
ZipAssetStore
>
(
GetUnzipperProviderForRootBundle
());
if
(
!
bundle
.
empty
())
{
root_bundle_data_
=
std
::
move
(
bundle
);
asset_store_
=
fxl
::
MakeRefCounted
<
blink
::
ZipAssetStore
>
(
GetUnzipperProviderForRootBundle
());
}
else
{
fxl
::
UniqueFD
root_dir
(
fdio_ns_opendir
(
namespc_
));
if
(
!
root_dir
.
is_valid
())
{
FXL_LOG
(
ERROR
)
<<
"Unable to load root dir"
;
return
;
}
fxl
::
UniqueFD
data_dir
(
openat
(
root_dir
.
get
(),
kFuchsiaPackageResourceDirectory
,
O_RDONLY
|
O_DIRECTORY
));
if
(
!
data_dir
.
is_valid
())
{
FXL_LOG
(
ERROR
)
<<
"Unable to load data dir"
;
return
;
}
directory_asset_bundle_
=
fxl
::
MakeRefCounted
<
blink
::
DirectoryAssetBundle
>
(
std
::
move
(
data_dir
));
}
}
mozart
::
View
*
RuntimeHolder
::
GetMozartView
()
{
...
...
@@ -466,7 +490,7 @@ bool RuntimeHolder::HandleAssetPlatformMessage(
std
::
string
asset_name
(
reinterpret_cast
<
const
char
*>
(
data
.
data
()),
data
.
size
());
std
::
vector
<
uint8_t
>
asset_data
;
if
(
asset_store_
&&
asset_store_
->
G
etAsBuffer
(
asset_name
,
&
asset_data
))
{
if
(
GetAss
etAsBuffer
(
asset_name
,
&
asset_data
))
{
response
->
Complete
(
std
::
move
(
asset_data
));
}
else
{
response
->
CompleteEmpty
();
...
...
@@ -474,6 +498,13 @@ bool RuntimeHolder::HandleAssetPlatformMessage(
return
true
;
}
bool
RuntimeHolder
::
GetAssetAsBuffer
(
const
std
::
string
&
name
,
std
::
vector
<
uint8_t
>*
data
)
{
return
(
directory_asset_bundle_
&&
directory_asset_bundle_
->
GetAsBuffer
(
name
,
data
))
||
(
asset_store_
&&
asset_store_
->
GetAsBuffer
(
name
,
data
));
}
bool
RuntimeHolder
::
HandleFlutterPlatformMessage
(
blink
::
PlatformMessage
*
message
)
{
const
auto
&
data
=
message
->
data
();
...
...
content_handler/runtime_holder.h
浏览文件 @
1e23d648
...
...
@@ -11,6 +11,7 @@
#include <unordered_set>
#include "dart-pkg/fuchsia/sdk_ext/fuchsia.h"
#include "flutter/assets/directory_asset_bundle.h"
#include "flutter/assets/unzipper_provider.h"
#include "flutter/assets/zip_asset_store.h"
#include "flutter/content_handler/accessibility_bridge.h"
...
...
@@ -92,6 +93,7 @@ class RuntimeHolder : public blink::RuntimeDelegate,
void
InitRootBundle
(
std
::
vector
<
char
>
bundle
);
blink
::
UnzipperProvider
GetUnzipperProviderForRootBundle
();
bool
HandleAssetPlatformMessage
(
blink
::
PlatformMessage
*
message
);
bool
GetAssetAsBuffer
(
const
std
::
string
&
name
,
std
::
vector
<
uint8_t
>*
data
);
bool
HandleTextInputPlatformMessage
(
blink
::
PlatformMessage
*
message
);
bool
HandleFlutterPlatformMessage
(
blink
::
PlatformMessage
*
message
);
...
...
@@ -109,7 +111,9 @@ class RuntimeHolder : public blink::RuntimeDelegate,
std
::
unique_ptr
<
app
::
ApplicationContext
>
context_
;
fidl
::
InterfaceRequest
<
app
::
ServiceProvider
>
outgoing_services_
;
std
::
vector
<
char
>
root_bundle_data_
;
// TODO(zarah): Remove asset_store_ when flx is completely removed
fxl
::
RefPtr
<
blink
::
ZipAssetStore
>
asset_store_
;
fxl
::
RefPtr
<
blink
::
DirectoryAssetBundle
>
directory_asset_bundle_
;
void
*
dylib_handle_
=
nullptr
;
std
::
unique_ptr
<
Rasterizer
>
rasterizer_
;
std
::
unique_ptr
<
blink
::
RuntimeController
>
runtime_
;
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录