Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
qq_34031325
engine
提交
ee3bc0cc
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,发现更多精彩内容 >>
提交
ee3bc0cc
编写于
3月 02, 2016
作者:
J
Jason Simmons
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Remove obsolete AssetBundle implementations
上级
58a7a7ae
变更
9
隐藏空白更改
内联
并排
Showing
9 changed file
with
0 addition
and
492 deletion
+0
-492
services/asset_bundle/BUILD.gn
services/asset_bundle/BUILD.gn
+0
-44
services/asset_bundle/asset_bundle_apptest.cc
services/asset_bundle/asset_bundle_apptest.cc
+0
-95
services/asset_bundle/asset_bundle_impl.cc
services/asset_bundle/asset_bundle_impl.cc
+0
-54
services/asset_bundle/asset_bundle_impl.h
services/asset_bundle/asset_bundle_impl.h
+0
-43
services/asset_bundle/asset_unpacker_impl.cc
services/asset_bundle/asset_unpacker_impl.cc
+0
-28
services/asset_bundle/asset_unpacker_impl.h
services/asset_bundle/asset_unpacker_impl.h
+0
-39
services/asset_bundle/asset_unpacker_job.cc
services/asset_bundle/asset_unpacker_job.cc
+0
-85
services/asset_bundle/asset_unpacker_job.h
services/asset_bundle/asset_unpacker_job.h
+0
-41
services/asset_bundle/main.cc
services/asset_bundle/main.cc
+0
-63
未找到文件。
services/asset_bundle/BUILD.gn
浏览文件 @
ee3bc0cc
...
...
@@ -6,12 +6,6 @@ import("//mojo/public/mojo_application.gni")
source_set("lib") {
sources = [
"asset_bundle_impl.cc",
"asset_bundle_impl.h",
"asset_unpacker_impl.cc",
"asset_unpacker_impl.h",
"asset_unpacker_job.cc",
"asset_unpacker_job.h",
"zip_asset_bundle.cc",
"zip_asset_bundle.h",
]
...
...
@@ -25,41 +19,3 @@ source_set("lib") {
"//third_party/zlib:zip",
]
}
mojo_native_application("asset_bundle") {
sources = [
"main.cc",
]
deps = [
"//base",
"//mojo/application",
"//mojo/public/cpp/application",
"//mojo/public/cpp/bindings:callback",
"//mojo/public/cpp/system",
"//mojo/services/asset_bundle/interfaces",
":lib",
]
}
mojo_native_application("apptests") {
output_name = "asset_bundle_apptests"
testonly = true
sources = [
"asset_bundle_apptest.cc",
]
deps = [
"//base",
"//mojo/application",
"//mojo/application:test_support",
"//mojo/data_pipe_utils",
"//mojo/public/cpp/bindings",
"//mojo/services/asset_bundle/interfaces",
"//third_party/zlib:zip",
]
data_deps = [ ":asset_bundle($default_toolchain)" ]
}
services/asset_bundle/asset_bundle_apptest.cc
已删除
100644 → 0
浏览文件 @
58a7a7ae
// Copyright 2015 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 "base/bind.h"
#include "base/files/file_path.h"
#include "base/files/file_util.h"
#include "base/files/scoped_temp_dir.h"
#include "base/run_loop.h"
#include "mojo/data_pipe_utils/data_pipe_utils.h"
#include "mojo/public/cpp/application/application_impl.h"
#include "mojo/public/cpp/application/application_test_base.h"
#include "mojo/services/asset_bundle/interfaces/asset_bundle.mojom.h"
#include "third_party/zlib/google/zip.h"
namespace
asset_bundle
{
class
AssetBundleAppTest
:
public
mojo
::
test
::
ApplicationTestBase
{
public:
AssetBundleAppTest
()
{}
~
AssetBundleAppTest
()
override
{}
void
SetUp
()
override
{
mojo
::
test
::
ApplicationTestBase
::
SetUp
();
application_impl
()
->
ConnectToService
(
"mojo:asset_bundle"
,
&
asset_unpacker_
);
}
protected:
mojo
::
asset_bundle
::
AssetUnpackerPtr
asset_unpacker_
;
DISALLOW_COPY_AND_ASSIGN
(
AssetBundleAppTest
);
};
TEST_F
(
AssetBundleAppTest
,
CanGetText
)
{
std
::
string
foo_content
=
"Some plain data"
;
std
::
string
bar_content
=
"The wrong data"
;
base
::
ScopedTempDir
zip_dir
;
ASSERT_TRUE
(
zip_dir
.
CreateUniqueTempDir
());
base
::
FilePath
foo_path
=
zip_dir
.
path
().
Append
(
"foo.txt"
);
base
::
WriteFile
(
foo_path
,
foo_content
.
data
(),
foo_content
.
size
());
base
::
FilePath
bar_path
=
zip_dir
.
path
().
Append
(
"bar.txt"
);
base
::
WriteFile
(
bar_path
,
bar_content
.
data
(),
bar_content
.
size
());
base
::
FilePath
zip_path
;
ASSERT_TRUE
(
base
::
CreateTemporaryFile
(
&
zip_path
));
zip
::
Zip
(
zip_dir
.
path
(),
zip_path
,
false
);
std
::
string
zip_contents
;
ASSERT_TRUE
(
base
::
ReadFileToString
(
zip_path
,
&
zip_contents
));
ASSERT_TRUE
(
base
::
DeleteFile
(
zip_path
,
false
));
mojo
::
DataPipe
zip_pipe
;
mojo
::
asset_bundle
::
AssetBundlePtr
asset_bundle
;
asset_unpacker_
->
UnpackZipStream
(
zip_pipe
.
consumer_handle
.
Pass
(),
GetProxy
(
&
asset_bundle
));
EXPECT_TRUE
(
mojo
::
common
::
BlockingCopyFromString
(
zip_contents
,
zip_pipe
.
producer_handle
));
zip_pipe
.
producer_handle
.
reset
();
std
::
string
asset_content
;
asset_bundle
->
GetAsStream
(
"foo.txt"
,
[
&
](
mojo
::
ScopedDataPipeConsumerHandle
asset_pipe
)
{
mojo
::
common
::
BlockingCopyToString
(
asset_pipe
.
Pass
(),
&
asset_content
);
});
ASSERT_TRUE
(
asset_bundle
.
WaitForIncomingResponse
());
EXPECT_EQ
(
foo_content
,
asset_content
)
<<
"Failed to get the correct contents back from the asset bundle"
;
std
::
string
missing_content
;
asset_bundle
->
GetAsStream
(
"missing.txt"
,
[
&
](
mojo
::
ScopedDataPipeConsumerHandle
asset_pipe
)
{
mojo
::
common
::
BlockingCopyToString
(
asset_pipe
.
Pass
(),
&
missing_content
);
});
ASSERT_TRUE
(
asset_bundle
.
WaitForIncomingResponse
());
EXPECT_EQ
(
""
,
missing_content
)
<<
"Missing asset keys are treated as empty data streams"
;
std
::
string
outside_content
;
asset_bundle
->
GetAsStream
(
"../../out-of-bundle.txt"
,
[
&
](
mojo
::
ScopedDataPipeConsumerHandle
asset_pipe
)
{
mojo
::
common
::
BlockingCopyToString
(
asset_pipe
.
Pass
(),
&
outside_content
);
});
ASSERT_TRUE
(
asset_bundle
.
WaitForIncomingResponse
());
EXPECT_EQ
(
""
,
outside_content
)
<<
"Traversing outside of bundle is treated as an empty data stream"
;
}
}
// namespace asset_bundle
services/asset_bundle/asset_bundle_impl.cc
已删除
100644 → 0
浏览文件 @
58a7a7ae
// Copyright 2015 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 "services/asset_bundle/asset_bundle_impl.h"
#include "base/bind.h"
#include "base/files/file_path.h"
#include "base/files/file_util.h"
#include "base/logging.h"
#include "mojo/data_pipe_utils/data_pipe_utils.h"
namespace
mojo
{
namespace
asset_bundle
{
namespace
{
void
Ignored
(
bool
)
{
}
}
// namespace
AssetBundleImpl
::
AssetBundleImpl
(
InterfaceRequest
<
AssetBundle
>
request
,
scoped_ptr
<
base
::
ScopedTempDir
>
asset_dir
,
scoped_refptr
<
base
::
TaskRunner
>
worker_runner
)
:
binding_
(
this
,
request
.
Pass
()),
asset_dir_
(
asset_dir
.
Pass
()),
worker_runner_
(
worker_runner
.
Pass
())
{
}
AssetBundleImpl
::~
AssetBundleImpl
()
{
}
void
AssetBundleImpl
::
GetAsStream
(
const
String
&
asset_name
,
const
Callback
<
void
(
ScopedDataPipeConsumerHandle
)
>&
callback
)
{
DataPipe
pipe
;
callback
.
Run
(
pipe
.
consumer_handle
.
Pass
());
std
::
string
asset_string
=
asset_name
.
To
<
std
::
string
>
();
base
::
FilePath
asset_path
=
base
::
MakeAbsoluteFilePath
(
asset_dir_
->
path
().
Append
(
asset_string
));
auto
asset_dir_abs
=
base
::
MakeAbsoluteFilePath
(
asset_dir_
->
path
());
if
(
!
asset_dir_abs
.
IsParent
(
asset_path
))
{
LOG
(
WARNING
)
<<
"Requested asset '"
<<
asset_string
<<
"' does not exist."
;
return
;
}
common
::
CopyFromFile
(
asset_path
,
pipe
.
producer_handle
.
Pass
(),
0
,
worker_runner_
.
get
(),
base
::
Bind
(
&
Ignored
));
}
}
// namespace asset_bundle
}
// namespace mojo
services/asset_bundle/asset_bundle_impl.h
已删除
100644 → 0
浏览文件 @
58a7a7ae
// Copyright 2015 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 SERVICES_ASSET_BUNDLE_ASSET_BUNDLE_IMPL_H_
#define SERVICES_ASSET_BUNDLE_ASSET_BUNDLE_IMPL_H_
#include "base/files/scoped_temp_dir.h"
#include "base/macros.h"
#include "base/memory/scoped_ptr.h"
#include "base/task_runner.h"
#include "mojo/public/cpp/bindings/interface_request.h"
#include "mojo/public/cpp/bindings/strong_binding.h"
#include "mojo/public/cpp/system/data_pipe.h"
#include "mojo/services/asset_bundle/interfaces/asset_bundle.mojom.h"
namespace
mojo
{
namespace
asset_bundle
{
class
AssetBundleImpl
:
public
AssetBundle
{
public:
AssetBundleImpl
(
InterfaceRequest
<
AssetBundle
>
request
,
scoped_ptr
<
base
::
ScopedTempDir
>
asset_dir
,
scoped_refptr
<
base
::
TaskRunner
>
worker_runner
);
~
AssetBundleImpl
()
override
;
// AssetBundle implementation
void
GetAsStream
(
const
String
&
asset_name
,
const
Callback
<
void
(
ScopedDataPipeConsumerHandle
)
>&
callback
)
override
;
private:
StrongBinding
<
AssetBundle
>
binding_
;
scoped_ptr
<
base
::
ScopedTempDir
>
asset_dir_
;
scoped_refptr
<
base
::
TaskRunner
>
worker_runner_
;
DISALLOW_COPY_AND_ASSIGN
(
AssetBundleImpl
);
};
}
// namespace asset_bundle
}
// namespace mojo
#endif // SERVICES_ASSET_BUNDLE_ASSET_BUNDLE_IMPL_H_
services/asset_bundle/asset_unpacker_impl.cc
已删除
100644 → 0
浏览文件 @
58a7a7ae
// Copyright 2015 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 "services/asset_bundle/asset_unpacker_impl.h"
#include "base/logging.h"
#include "services/asset_bundle/asset_unpacker_job.h"
namespace
mojo
{
namespace
asset_bundle
{
AssetUnpackerImpl
::
AssetUnpackerImpl
(
InterfaceRequest
<
AssetUnpacker
>
request
,
scoped_refptr
<
base
::
TaskRunner
>
worker_runner
)
:
binding_
(
this
,
request
.
Pass
()),
worker_runner_
(
worker_runner
.
Pass
())
{
}
AssetUnpackerImpl
::~
AssetUnpackerImpl
()
{
}
void
AssetUnpackerImpl
::
UnpackZipStream
(
ScopedDataPipeConsumerHandle
zipped
,
InterfaceRequest
<
AssetBundle
>
request
)
{
(
new
AssetUnpackerJob
(
request
.
Pass
(),
worker_runner_
))
->
Unpack
(
zipped
.
Pass
());
}
}
// namespace asset_bundle
}
// namespace mojo
services/asset_bundle/asset_unpacker_impl.h
已删除
100644 → 0
浏览文件 @
58a7a7ae
// Copyright 2015 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 SERVICES_ASSET_BUNDLE_ASSET_UNPACKER_IMPL_H_
#define SERVICES_ASSET_BUNDLE_ASSET_UNPACKER_IMPL_H_
#include "base/macros.h"
#include "base/task_runner.h"
#include "mojo/public/cpp/bindings/interface_request.h"
#include "mojo/public/cpp/bindings/strong_binding.h"
#include "mojo/public/cpp/system/data_pipe.h"
#include "mojo/services/asset_bundle/interfaces/asset_bundle.mojom.h"
namespace
mojo
{
namespace
asset_bundle
{
class
AssetUnpackerImpl
:
public
AssetUnpacker
{
public:
AssetUnpackerImpl
(
InterfaceRequest
<
AssetUnpacker
>
request
,
scoped_refptr
<
base
::
TaskRunner
>
worker_runner
);
~
AssetUnpackerImpl
()
override
;
// AssetUnpacker implementation
void
UnpackZipStream
(
ScopedDataPipeConsumerHandle
zipped_assets
,
InterfaceRequest
<
AssetBundle
>
asset_bundle
)
override
;
private:
StrongBinding
<
AssetUnpacker
>
binding_
;
scoped_refptr
<
base
::
TaskRunner
>
worker_runner_
;
DISALLOW_COPY_AND_ASSIGN
(
AssetUnpackerImpl
);
};
}
// namespace asset_bundle
}
// namespace mojo
#endif // SERVICES_ASSET_BUNDLE_ASSET_UNPACKER_IMPL_H_
services/asset_bundle/asset_unpacker_job.cc
已删除
100644 → 0
浏览文件 @
58a7a7ae
// Copyright 2015 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 "services/asset_bundle/asset_unpacker_job.h"
#include "base/bind.h"
#include "base/files/file_path.h"
#include "base/files/file_util.h"
#include "base/memory/scoped_ptr.h"
#include "base/message_loop/message_loop.h"
#include "services/asset_bundle/asset_bundle_impl.h"
#include "third_party/zlib/google/zip.h"
namespace
mojo
{
namespace
asset_bundle
{
namespace
{
void
UnzipAssets
(
const
base
::
FilePath
&
zip_path
,
scoped_ptr
<
base
::
ScopedTempDir
>
asset_dir
,
scoped_refptr
<
base
::
TaskRunner
>
task_runner
,
base
::
Callback
<
void
(
scoped_ptr
<
base
::
ScopedTempDir
>
)
>
callback
)
{
if
(
!
zip
::
Unzip
(
zip_path
,
asset_dir
->
path
()))
{
task_runner
->
PostTask
(
FROM_HERE
,
base
::
Bind
(
callback
,
nullptr
));
}
else
{
task_runner
->
PostTask
(
FROM_HERE
,
base
::
Bind
(
callback
,
base
::
Passed
(
asset_dir
.
Pass
())));
}
base
::
DeleteFile
(
zip_path
,
false
);
}
}
// namespace
AssetUnpackerJob
::
AssetUnpackerJob
(
InterfaceRequest
<
AssetBundle
>
asset_bundle
,
scoped_refptr
<
base
::
TaskRunner
>
worker_runner
)
:
asset_bundle_
(
asset_bundle
.
Pass
()),
worker_runner_
(
worker_runner
.
Pass
()),
weak_factory_
(
this
)
{
}
AssetUnpackerJob
::~
AssetUnpackerJob
()
{
}
void
AssetUnpackerJob
::
Unpack
(
ScopedDataPipeConsumerHandle
zipped_assets
)
{
base
::
FilePath
zip_path
;
if
(
!
CreateTemporaryFile
(
&
zip_path
))
{
delete
this
;
return
;
}
common
::
CopyToFile
(
zipped_assets
.
Pass
(),
zip_path
,
worker_runner_
.
get
(),
base
::
Bind
(
&
AssetUnpackerJob
::
OnZippedAssetsAvailable
,
weak_factory_
.
GetWeakPtr
(),
zip_path
));
}
void
AssetUnpackerJob
::
OnZippedAssetsAvailable
(
const
base
::
FilePath
&
zip_path
,
bool
success
)
{
if
(
!
success
)
{
delete
this
;
return
;
}
scoped_ptr
<
base
::
ScopedTempDir
>
asset_dir
(
new
base
::
ScopedTempDir
());
if
(
!
asset_dir
->
CreateUniqueTempDir
())
{
delete
this
;
return
;
}
worker_runner_
->
PostTask
(
FROM_HERE
,
base
::
Bind
(
&
UnzipAssets
,
zip_path
,
base
::
Passed
(
asset_dir
.
Pass
()),
base
::
MessageLoop
::
current
()
->
task_runner
(),
base
::
Bind
(
&
AssetUnpackerJob
::
OnUnzippedAssetsAvailable
,
weak_factory_
.
GetWeakPtr
())));
}
void
AssetUnpackerJob
::
OnUnzippedAssetsAvailable
(
scoped_ptr
<
base
::
ScopedTempDir
>
asset_dir
)
{
if
(
asset_dir
)
new
AssetBundleImpl
(
asset_bundle_
.
Pass
(),
asset_dir
.
Pass
(),
worker_runner_
);
delete
this
;
}
}
// namespace asset_bundle
}
// namespace mojo
services/asset_bundle/asset_unpacker_job.h
已删除
100644 → 0
浏览文件 @
58a7a7ae
// Copyright 2015 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 SERVICES_ASSET_BUNDLE_ASSET_UNPACKER_JOB_H_
#define SERVICES_ASSET_BUNDLE_ASSET_UNPACKER_JOB_H_
#include "base/files/scoped_temp_dir.h"
#include "base/macros.h"
#include "base/memory/weak_ptr.h"
#include "base/task_runner.h"
#include "mojo/data_pipe_utils/data_pipe_utils.h"
#include "mojo/public/cpp/bindings/interface_request.h"
#include "mojo/services/asset_bundle/interfaces/asset_bundle.mojom.h"
namespace
mojo
{
namespace
asset_bundle
{
class
AssetUnpackerJob
{
public:
AssetUnpackerJob
(
InterfaceRequest
<
AssetBundle
>
asset_bundle
,
scoped_refptr
<
base
::
TaskRunner
>
worker_runner
);
~
AssetUnpackerJob
();
void
Unpack
(
ScopedDataPipeConsumerHandle
zipped_assets
);
private:
void
OnZippedAssetsAvailable
(
const
base
::
FilePath
&
zip_path
,
bool
success
);
void
OnUnzippedAssetsAvailable
(
scoped_ptr
<
base
::
ScopedTempDir
>
temp_dir
);
InterfaceRequest
<
AssetBundle
>
asset_bundle_
;
scoped_refptr
<
base
::
TaskRunner
>
worker_runner_
;
base
::
WeakPtrFactory
<
AssetUnpackerJob
>
weak_factory_
;
DISALLOW_COPY_AND_ASSIGN
(
AssetUnpackerJob
);
};
}
// namespace asset_bundle
}
// namespace mojo
#endif // SERVICES_ASSET_BUNDLE_ASSET_UNPACKER_JOB_H_
services/asset_bundle/main.cc
已删除
100644 → 0
浏览文件 @
58a7a7ae
// Copyright 2015 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 "base/macros.h"
#include "base/threading/sequenced_worker_pool.h"
#include "mojo/application/application_runner_chromium.h"
#include "mojo/public/c/system/main.h"
#include "mojo/public/cpp/application/application_connection.h"
#include "mojo/public/cpp/application/application_delegate.h"
#include "mojo/public/cpp/application/interface_factory.h"
#include "services/asset_bundle/asset_unpacker_impl.h"
namespace
mojo
{
namespace
asset_bundle
{
class
AssetBundleApp
:
public
ApplicationDelegate
,
public
InterfaceFactory
<
AssetUnpacker
>
{
public:
AssetBundleApp
()
{}
~
AssetBundleApp
()
override
{}
private:
// |ApplicationDelegate| override:
bool
ConfigureIncomingConnection
(
ApplicationConnection
*
connection
)
override
{
connection
->
AddService
<
AssetUnpacker
>
(
this
);
return
true
;
}
// |InterfaceFactory<AssetUnpacker>| implementation:
void
Create
(
ApplicationConnection
*
connection
,
InterfaceRequest
<
AssetUnpacker
>
request
)
override
{
// Lazily initialize |sequenced_worker_pool_|. (We can't create it in the
// constructor, since AtExitManager is only created in
// ApplicationRunnerChromium::Run().)
if
(
!
sequenced_worker_pool_
)
{
// TODO(vtl): What's the "right" way to choose the maximum number of
// threads?
sequenced_worker_pool_
=
new
base
::
SequencedWorkerPool
(
4
,
"AssetBundleWorker"
);
}
new
AssetUnpackerImpl
(
request
.
Pass
(),
sequenced_worker_pool_
->
GetTaskRunnerWithShutdownBehavior
(
base
::
SequencedWorkerPool
::
SKIP_ON_SHUTDOWN
));
}
// We don't really need the "sequenced" part, but we need to be able to shut
// down our worker pool.
scoped_refptr
<
base
::
SequencedWorkerPool
>
sequenced_worker_pool_
;
DISALLOW_COPY_AND_ASSIGN
(
AssetBundleApp
);
};
}
// namespace asset_bundle
}
// namespace mojo
MojoResult
MojoMain
(
MojoHandle
application_request
)
{
mojo
::
ApplicationRunnerChromium
runner
(
new
mojo
::
asset_bundle
::
AssetBundleApp
());
return
runner
.
Run
(
application_request
);
}
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录