Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
weixin_43355755
engine
提交
8a701198
E
engine
项目概览
weixin_43355755
/
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,发现更多精彩内容 >>
提交
8a701198
编写于
2月 09, 2016
作者:
J
Jason Simmons
浏览文件
操作
浏览文件
下载
差异文件
Merge pull request #2369 from jason-simmons/refresh_update_snapshot
Add a way to override the snapshot when running an FLX bundle
上级
24808307
ae517c2f
变更
7
隐藏空白更改
内联
并排
Showing
7 changed file
with
73 addition
and
23 deletion
+73
-23
services/asset_bundle/zip_asset_bundle.cc
services/asset_bundle/zip_asset_bundle.cc
+26
-3
services/asset_bundle/zip_asset_bundle.h
services/asset_bundle/zip_asset_bundle.h
+13
-6
sky/services/engine/sky_engine.mojom
sky/services/engine/sky_engine.mojom
+4
-0
sky/shell/platform/android/org/domokit/sky/shell/PlatformViewAndroid.java
...rm/android/org/domokit/sky/shell/PlatformViewAndroid.java
+6
-2
sky/shell/platform/android/org/domokit/sky/shell/SkyActivity.java
...l/platform/android/org/domokit/sky/shell/SkyActivity.java
+3
-12
sky/shell/ui/engine.cc
sky/shell/ui/engine.cc
+19
-0
sky/shell/ui/engine.h
sky/shell/ui/engine.h
+2
-0
未找到文件。
services/asset_bundle/zip_asset_bundle.cc
浏览文件 @
8a701198
...
...
@@ -6,18 +6,26 @@
#include "base/bind.h"
#include "base/location.h"
#include "base/message_loop/message_loop.h"
#include "base/task_runner.h"
#include "base/message_loop/message_loop.h"
#include "mojo/data_pipe_utils/data_pipe_utils.h"
#include "third_party/zlib/contrib/minizip/unzip.h"
namespace
mojo
{
namespace
asset_bundle
{
void
ZipAssetBundle
::
Create
(
namespace
{
void
Ignored
(
bool
)
{
}
}
// namespace
ZipAssetBundle
*
ZipAssetBundle
::
Create
(
InterfaceRequest
<
AssetBundle
>
request
,
const
base
::
FilePath
&
zip_path
,
scoped_refptr
<
base
::
TaskRunner
>
worker_runner
)
{
new
ZipAssetBundle
(
request
.
Pass
(),
zip_path
,
worker_runner
.
Pass
());
return
new
ZipAssetBundle
(
request
.
Pass
(),
zip_path
,
worker_runner
.
Pass
());
}
ZipAssetBundle
::
ZipAssetBundle
(
...
...
@@ -32,12 +40,27 @@ ZipAssetBundle::ZipAssetBundle(
ZipAssetBundle
::~
ZipAssetBundle
()
{
}
void
ZipAssetBundle
::
AddOverlayFile
(
const
std
::
string
&
asset_name
,
const
base
::
FilePath
&
file_path
)
{
overlay_files_
.
insert
(
std
::
make_pair
(
String
(
asset_name
),
file_path
));
}
void
ZipAssetBundle
::
GetAsStream
(
const
String
&
asset_name
,
const
Callback
<
void
(
ScopedDataPipeConsumerHandle
)
>&
callback
)
{
DataPipe
pipe
;
callback
.
Run
(
pipe
.
consumer_handle
.
Pass
());
auto
overlay
=
overlay_files_
.
find
(
asset_name
);
if
(
overlay
!=
overlay_files_
.
end
())
{
common
::
CopyFromFile
(
overlay
->
second
,
pipe
.
producer_handle
.
Pass
(),
0
,
worker_runner_
.
get
(),
base
::
Bind
(
&
Ignored
));
return
;
}
ZipAssetHandler
*
handler
=
new
ZipAssetHandler
(
zip_path_
,
asset_name
.
To
<
std
::
string
>
(),
...
...
services/asset_bundle/zip_asset_bundle.h
浏览文件 @
8a701198
...
...
@@ -2,6 +2,8 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#include <map>
#include "base/task_runner.h"
#include "base/files/file_path.h"
#include "base/memory/weak_ptr.h"
...
...
@@ -18,9 +20,9 @@ namespace asset_bundle {
// ZIP archive.
class
ZipAssetBundle
:
public
AssetBundle
{
public:
static
void
Create
(
InterfaceRequest
<
AssetBundle
>
request
,
const
base
::
FilePath
&
zip_path
,
scoped_refptr
<
base
::
TaskRunner
>
worker_runner
);
static
ZipAssetBundle
*
Create
(
InterfaceRequest
<
AssetBundle
>
request
,
const
base
::
FilePath
&
zip_path
,
scoped_refptr
<
base
::
TaskRunner
>
worker_runner
);
~
ZipAssetBundle
()
override
;
// AssetBundle implementation
...
...
@@ -28,6 +30,10 @@ class ZipAssetBundle : public AssetBundle {
const
String
&
asset_name
,
const
Callback
<
void
(
ScopedDataPipeConsumerHandle
)
>&
callback
)
override
;
// Serve this asset from another file instead of using the ZIP contents.
void
AddOverlayFile
(
const
std
::
string
&
asset_name
,
const
base
::
FilePath
&
file_path
);
private:
ZipAssetBundle
(
InterfaceRequest
<
AssetBundle
>
request
,
const
base
::
FilePath
&
zip_path
,
...
...
@@ -36,6 +42,7 @@ class ZipAssetBundle : public AssetBundle {
StrongBinding
<
AssetBundle
>
binding_
;
const
base
::
FilePath
zip_path_
;
scoped_refptr
<
base
::
TaskRunner
>
worker_runner_
;
std
::
map
<
String
,
base
::
FilePath
>
overlay_files_
;
DISALLOW_COPY_AND_ASSIGN
(
ZipAssetBundle
);
};
...
...
@@ -46,9 +53,9 @@ class ZipAssetHandler {
public:
ZipAssetHandler
(
const
base
::
FilePath
&
zip_path
,
const
std
::
string
&
asset_name
,
ScopedDataPipeProducerHandle
producer
,
scoped_refptr
<
base
::
TaskRunner
>
worker_runner
);
const
std
::
string
&
asset_name
,
ScopedDataPipeProducerHandle
producer
,
scoped_refptr
<
base
::
TaskRunner
>
worker_runner
);
~
ZipAssetHandler
();
void
Start
();
...
...
sky/services/engine/sky_engine.mojom
浏览文件 @
8a701198
...
...
@@ -55,4 +55,8 @@ interface SkyEngine {
RunFromBundle(string path);
RunFromAssetBundle(string url, mojo.asset_bundle.AssetBundle bundle);
// Run the app from a bundle, but obtain the snapshot from snapshot_path
// instead of using the snapshot within the bundle.
RunFromBundleAndSnapshot(string bundle_path, string snapshot_path);
};
sky/shell/platform/android/org/domokit/sky/shell/PlatformViewAndroid.java
浏览文件 @
8a701198
...
...
@@ -305,7 +305,7 @@ public class PlatformViewAndroid extends SurfaceView
mServiceProvider
=
new
PlatformServiceProvider
(
core
,
getContext
(),
localRegistry
);
}
void
runFromBundle
(
String
p
ath
)
{
void
runFromBundle
(
String
bundlePath
,
String
snapshotP
ath
)
{
if
(
mServiceProvider
!=
null
)
{
mServiceProvider
.
close
();
...
...
@@ -330,7 +330,11 @@ public class PlatformViewAndroid extends SurfaceView
resetAccessibilityTree
();
mSkyEngine
.
runFromBundle
(
path
);
if
(
snapshotPath
!=
null
)
{
mSkyEngine
.
runFromBundleAndSnapshot
(
bundlePath
,
snapshotPath
);
}
else
{
mSkyEngine
.
runFromBundle
(
bundlePath
);
}
}
private
static
native
long
nativeAttach
(
int
inputObserverHandle
);
...
...
sky/shell/platform/android/org/domokit/sky/shell/SkyActivity.java
浏览文件 @
8a701198
...
...
@@ -141,7 +141,7 @@ public class SkyActivity extends Activity {
File
dataDir
=
new
File
(
PathUtils
.
getDataDirectory
(
this
));
File
appBundle
=
new
File
(
dataDir
,
SkyApplication
.
APP_BUNDLE
);
if
(
appBundle
.
exists
())
{
mView
.
runFromBundle
(
appBundle
.
getPath
());
mView
.
runFromBundle
(
appBundle
.
getPath
()
,
null
);
return
;
}
}
...
...
@@ -154,7 +154,8 @@ public class SkyActivity extends Activity {
String
action
=
intent
.
getAction
();
if
(
Intent
.
ACTION_RUN
.
equals
(
action
))
{
mView
.
runFromBundle
(
intent
.
getDataString
());
mView
.
runFromBundle
(
intent
.
getDataString
(),
intent
.
getStringExtra
(
"snapshot"
));
String
route
=
intent
.
getStringExtra
(
"route"
);
if
(
route
!=
null
)
mView
.
getEngine
().
pushRoute
(
route
);
...
...
@@ -164,16 +165,6 @@ public class SkyActivity extends Activity {
return
false
;
}
public
boolean
loadBundleByName
(
String
name
)
{
File
dataDir
=
new
File
(
PathUtils
.
getDataDirectory
(
this
));
File
bundle
=
new
File
(
dataDir
,
name
);
if
(!
bundle
.
exists
())
{
return
false
;
}
mView
.
runFromBundle
(
bundle
.
getPath
());
return
true
;
}
public
void
onConfigurationChanged
(
Configuration
newConfig
)
{
super
.
onConfigurationChanged
(
newConfig
);
...
...
sky/shell/ui/engine.cc
浏览文件 @
8a701198
...
...
@@ -244,6 +244,25 @@ void Engine::RunFromAssetBundle(const mojo::String& url,
weak_factory_
.
GetWeakPtr
(),
url_str
));
}
void
Engine
::
RunFromBundleAndSnapshot
(
const
mojo
::
String
&
bundle_path
,
const
mojo
::
String
&
snapshot_path
)
{
TRACE_EVENT0
(
"flutter"
,
"Engine::RunFromBundleAndSnapshot"
);
std
::
string
bundle_path_str
=
bundle_path
;
ZipAssetBundle
*
asset_bundle
=
ZipAssetBundle
::
Create
(
mojo
::
GetProxy
(
&
root_bundle_
),
base
::
FilePath
(
bundle_path_str
),
base
::
WorkerPool
::
GetTaskRunner
(
true
));
std
::
string
snapshot_path_str
=
snapshot_path
;
asset_bundle
->
AddOverlayFile
(
kSnapshotKey
,
base
::
FilePath
(
snapshot_path_str
));
root_bundle_
->
GetAsStream
(
kSnapshotKey
,
base
::
Bind
(
&
Engine
::
RunFromSnapshotStream
,
weak_factory_
.
GetWeakPtr
(),
bundle_path_str
));
}
void
Engine
::
PushRoute
(
const
mojo
::
String
&
route
)
{
if
(
sky_view_
)
sky_view_
->
PushRoute
(
route
);
...
...
sky/shell/ui/engine.h
浏览文件 @
8a701198
...
...
@@ -67,6 +67,8 @@ class Engine : public UIDelegate,
void
RunFromBundle
(
const
mojo
::
String
&
path
)
override
;
void
RunFromAssetBundle
(
const
mojo
::
String
&
url
,
mojo
::
asset_bundle
::
AssetBundlePtr
bundle
)
override
;
void
RunFromBundleAndSnapshot
(
const
mojo
::
String
&
bundle_path
,
const
mojo
::
String
&
snapshot_path
)
override
;
void
PushRoute
(
const
mojo
::
String
&
route
)
override
;
void
PopRoute
()
override
;
void
OnAppLifecycleStateChanged
(
sky
::
AppLifecycleState
state
)
override
;
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录