Skip to content

Commit a3327bf

Browse files
authored
Re-land "Support multiple shells in a single process. (flutter#4932)" (flutter#4977)
This reverts commit 9199b40.
1 parent 13fd804 commit a3327bf

File tree

345 files changed

+12558
-11071
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

345 files changed

+12558
-11071
lines changed

BUILD.gn

+32-42
Original file line numberDiff line numberDiff line change
@@ -10,14 +10,12 @@ group("flutter") {
1010
public_deps = [
1111
"$flutter_root/lib/snapshot:generate_snapshot_bin",
1212
"$flutter_root/lib/snapshot:kernel_platform_files",
13+
"$flutter_root/shell/testing",
1314
"$flutter_root/sky",
14-
"$flutter_root/third_party/txt",
1515
]
1616

1717
if (flutter_runtime_mode != "debug") {
18-
public_deps += [
19-
"$flutter_root/lib/snapshot:entry_points_json_files",
20-
]
18+
public_deps += [ "$flutter_root/lib/snapshot:entry_points_json_files" ]
2119
}
2220

2321
if (!is_fuchsia && !is_fuchsia_host) {
@@ -45,20 +43,24 @@ group("flutter") {
4543
"$flutter_root/shell/platform/embedder:flutter_embedder_framework",
4644
]
4745
}
48-
if (!is_win) {
49-
public_deps += [
50-
"$flutter_root/shell/platform/embedder:embedder_unittests",
51-
"$flutter_root/shell/platform/embedder:flutter_engine",
52-
]
53-
}
46+
5447
public_deps += [
5548
"$flutter_root/flow:flow_unittests",
5649
"$flutter_root/fml:fml_unittests",
50+
"$flutter_root/runtime:runtime_unittests",
51+
"$flutter_root/shell/common:shell_unittests",
5752
"$flutter_root/sky/engine/wtf:wtf_unittests",
5853
"$flutter_root/synchronization:synchronization_unittests",
5954
"$flutter_root/third_party/txt:txt_unittests",
6055
"//garnet/public/lib/fxl:fxl_unittests",
6156
]
57+
58+
if (!is_win) {
59+
public_deps += [
60+
"$flutter_root/shell/platform/embedder:embedder_unittests",
61+
"$flutter_root/shell/platform/embedder:flutter_engine",
62+
]
63+
}
6264
}
6365
}
6466

@@ -74,59 +76,47 @@ if (is_fuchsia) {
7476
"$flutter_root/content_handler:aot",
7577
]
7678
if (flutter_runtime_mode != "release") {
77-
deps += [
78-
"//third_party/dart/runtime/observatory:embedded_archive_observatory",
79-
]
79+
deps += [ "//third_party/dart/runtime/observatory:embedded_archive_observatory" ]
8080
}
8181

8282
binary = "flutter_aot_runner"
8383

8484
if (flutter_runtime_mode != "release") {
85-
resources = [
86-
{
87-
path = rebase_path(
88-
"$root_gen_dir/observatory/embedded_archive_observatory.tar")
89-
dest = "observatory.tar"
90-
},
91-
]
85+
resources = [ {
86+
path = rebase_path(
87+
"$root_gen_dir/observatory/embedded_archive_observatory.tar")
88+
dest = "observatory.tar"
89+
} ]
9290
}
9391

94-
meta = [
95-
{
96-
path = rebase_path("content_handler/meta/sandbox")
97-
dest = "sandbox"
98-
},
99-
]
92+
meta = [ {
93+
path = rebase_path("content_handler/meta/sandbox")
94+
dest = "sandbox"
95+
} ]
10096
}
10197

10298
package("flutter_jit_runner") {
10399
deps = [
104100
"$flutter_root/content_handler:jit",
105101
]
106102
if (flutter_runtime_mode != "release") {
107-
deps += [
108-
"//third_party/dart/runtime/observatory:embedded_archive_observatory",
109-
]
103+
deps += [ "//third_party/dart/runtime/observatory:embedded_archive_observatory" ]
110104
}
111105

112106
binary = "flutter_jit_runner"
113107

114108
if (flutter_runtime_mode != "release") {
115-
resources = [
116-
{
117-
path = rebase_path(
118-
"$root_gen_dir/observatory/embedded_archive_observatory.tar")
119-
dest = "observatory.tar"
120-
},
121-
]
109+
resources = [ {
110+
path = rebase_path(
111+
"$root_gen_dir/observatory/embedded_archive_observatory.tar")
112+
dest = "observatory.tar"
113+
} ]
122114
}
123115

124-
meta = [
125-
{
126-
path = rebase_path("content_handler/meta/sandbox")
127-
dest = "sandbox"
128-
},
129-
]
116+
meta = [ {
117+
path = rebase_path("content_handler/meta/sandbox")
118+
dest = "sandbox"
119+
} ]
130120
}
131121
} else {
132122
group("dist") {

DEPS

+1-1
Original file line numberDiff line numberDiff line change
@@ -115,7 +115,7 @@ allowed_hosts = [
115115
]
116116

117117
deps = {
118-
'src': 'https://github.com/flutter/buildroot.git' + '@' + '8dddd90bf943a8174913564353b30a3b11ee0f7a',
118+
'src': 'https://github.com/flutter/buildroot.git' + '@' + '3cf97e01cdbd4bb920fa3d40282a56c4b2d62a58',
119119

120120
# Fuchsia compatibility
121121
#

assets/BUILD.gn

+6-6
Original file line numberDiff line numberDiff line change
@@ -4,16 +4,18 @@
44

55
source_set("assets") {
66
sources = [
7-
"asset_provider.h",
7+
"asset_manager.cc",
8+
"asset_manager.h",
9+
"asset_resolver.h",
810
"directory_asset_bundle.cc",
911
"directory_asset_bundle.h",
10-
"unzipper_provider.cc",
11-
"unzipper_provider.h",
1212
"zip_asset_store.cc",
1313
"zip_asset_store.h",
1414
]
1515

1616
deps = [
17+
"$flutter_root/common",
18+
"$flutter_root/fml",
1719
"$flutter_root/glue",
1820
"//garnet/public/lib/fxl",
1921
"//garnet/public/lib/zip",
@@ -23,7 +25,5 @@ source_set("assets") {
2325
"//third_party/zlib:minizip",
2426
]
2527

26-
public_configs = [
27-
"$flutter_root:config",
28-
]
28+
public_configs = [ "$flutter_root:config" ]
2929
}

assets/asset_manager.cc

+59
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
1+
// Copyright 2017 The Flutter Authors. All rights reserved.
2+
// Use of this source code is governed by a BSD-style license that can be
3+
// found in the LICENSE file.
4+
5+
#include "flutter/assets/asset_manager.h"
6+
7+
#include "flutter/assets/directory_asset_bundle.h"
8+
#include "flutter/assets/zip_asset_store.h"
9+
#include "flutter/glue/trace_event.h"
10+
#include "lib/fxl/files/path.h"
11+
12+
#ifdef ERROR
13+
#undef ERROR
14+
#endif
15+
16+
namespace blink {
17+
18+
AssetManager::AssetManager() = default;
19+
20+
AssetManager::~AssetManager() = default;
21+
22+
void AssetManager::PushFront(std::unique_ptr<AssetResolver> resolver) {
23+
if (resolver == nullptr || !resolver->IsValid()) {
24+
return;
25+
}
26+
27+
resolvers_.push_front(std::move(resolver));
28+
}
29+
30+
void AssetManager::PushBack(std::unique_ptr<AssetResolver> resolver) {
31+
if (resolver == nullptr || !resolver->IsValid()) {
32+
return;
33+
}
34+
35+
resolvers_.push_back(std::move(resolver));
36+
}
37+
38+
// |blink::AssetResolver|
39+
bool AssetManager::GetAsBuffer(const std::string& asset_name,
40+
std::vector<uint8_t>* data) const {
41+
if (asset_name.size() == 0) {
42+
return false;
43+
}
44+
TRACE_EVENT0("flutter", "AssetManager::GetAsBuffer");
45+
for (const auto& resolver : resolvers_) {
46+
if (resolver->GetAsBuffer(asset_name, data)) {
47+
return true;
48+
}
49+
}
50+
FXL_DLOG(ERROR) << "Could not find asset: " << asset_name;
51+
return false;
52+
}
53+
54+
// |blink::AssetResolver|
55+
bool AssetManager::IsValid() const {
56+
return resolvers_.size() > 0;
57+
}
58+
59+
} // namespace blink

assets/asset_manager.h

+47
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
// Copyright 2017 The Flutter Authors. All rights reserved.
2+
// Use of this source code is governed by a BSD-style license that can be
3+
// found in the LICENSE file.
4+
5+
#ifndef FLUTTER_ASSETS_ASSET_MANAGER_H_
6+
#define FLUTTER_ASSETS_ASSET_MANAGER_H_
7+
8+
#include <deque>
9+
#include <memory>
10+
#include <string>
11+
12+
#include "flutter/assets/asset_resolver.h"
13+
#include "lib/fxl/files/unique_fd.h"
14+
#include "lib/fxl/macros.h"
15+
#include "lib/fxl/memory/ref_counted.h"
16+
17+
namespace blink {
18+
19+
class AssetManager final : public AssetResolver,
20+
public fxl::RefCountedThreadSafe<AssetManager> {
21+
public:
22+
void PushFront(std::unique_ptr<AssetResolver> resolver);
23+
24+
void PushBack(std::unique_ptr<AssetResolver> resolver);
25+
26+
// |blink::AssetResolver|
27+
bool IsValid() const override;
28+
29+
// |blink::AssetResolver|
30+
bool GetAsBuffer(const std::string& asset_name,
31+
std::vector<uint8_t>* data) const override;
32+
33+
private:
34+
std::deque<std::unique_ptr<AssetResolver>> resolvers_;
35+
36+
AssetManager();
37+
38+
~AssetManager();
39+
40+
FXL_DISALLOW_COPY_AND_ASSIGN(AssetManager);
41+
FRIEND_MAKE_REF_COUNTED(AssetManager);
42+
FRIEND_REF_COUNTED_THREAD_SAFE(AssetManager);
43+
};
44+
45+
} // namespace blink
46+
47+
#endif // FLUTTER_ASSETS_ASSET_MANAGER_H_

assets/asset_provider.h

-25
This file was deleted.

assets/asset_resolver.h

+32
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
// Copyright 2017 The Flutter Authors. All rights reserved.
2+
// Use of this source code is governed by a BSD-style license that can be
3+
// found in the LICENSE file.
4+
5+
#ifndef FLUTTER_ASSETS_ASSET_RESOLVER_H_
6+
#define FLUTTER_ASSETS_ASSET_RESOLVER_H_
7+
8+
#include <string>
9+
#include <vector>
10+
11+
#include "lib/fxl/macros.h"
12+
13+
namespace blink {
14+
15+
class AssetResolver {
16+
public:
17+
AssetResolver() = default;
18+
19+
virtual ~AssetResolver() = default;
20+
21+
virtual bool IsValid() const = 0;
22+
23+
virtual bool GetAsBuffer(const std::string& asset_name,
24+
std::vector<uint8_t>* data) const = 0;
25+
26+
private:
27+
FXL_DISALLOW_COPY_AND_ASSIGN(AssetResolver);
28+
};
29+
30+
} // namespace blink
31+
32+
#endif // FLUTTER_ASSETS_ASSET_RESOLVER_H_

0 commit comments

Comments
 (0)