forked from flutter/engine
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Revert "Revert "Support multiple shells in a single process. (flutter…
…#4932)" (flutter#4964)" This reverts commit 9199b40.
- Loading branch information
1 parent
13fd804
commit 6e0932e
Showing
345 changed files
with
12,543 additions
and
11,072 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
// Copyright 2017 The Flutter 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/assets/asset_manager.h" | ||
|
||
#include "flutter/assets/directory_asset_bundle.h" | ||
#include "flutter/assets/zip_asset_store.h" | ||
#include "flutter/glue/trace_event.h" | ||
#include "lib/fxl/files/path.h" | ||
|
||
namespace blink { | ||
|
||
AssetManager::AssetManager() = default; | ||
|
||
AssetManager::~AssetManager() = default; | ||
|
||
void AssetManager::PushFront(std::unique_ptr<AssetResolver> resolver) { | ||
if (resolver == nullptr || !resolver->IsValid()) { | ||
return; | ||
} | ||
|
||
resolvers_.push_front(std::move(resolver)); | ||
} | ||
|
||
void AssetManager::PushBack(std::unique_ptr<AssetResolver> resolver) { | ||
if (resolver == nullptr || !resolver->IsValid()) { | ||
return; | ||
} | ||
|
||
resolvers_.push_back(std::move(resolver)); | ||
} | ||
|
||
// |blink::AssetResolver| | ||
bool AssetManager::GetAsBuffer(const std::string& asset_name, | ||
std::vector<uint8_t>* data) const { | ||
if (asset_name.size() == 0) { | ||
return false; | ||
} | ||
TRACE_EVENT0("flutter", "AssetManager::GetAsBuffer"); | ||
for (const auto& resolver : resolvers_) { | ||
if (resolver->GetAsBuffer(asset_name, data)) { | ||
return true; | ||
} | ||
} | ||
FXL_DLOG(ERROR) << "Could not find asset: " << asset_name; | ||
return false; | ||
} | ||
|
||
// |blink::AssetResolver| | ||
bool AssetManager::IsValid() const { | ||
return resolvers_.size() > 0; | ||
} | ||
|
||
} // namespace blink |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
// Copyright 2017 The Flutter 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_ASSETS_ASSET_MANAGER_H_ | ||
#define FLUTTER_ASSETS_ASSET_MANAGER_H_ | ||
|
||
#include <deque> | ||
#include <memory> | ||
#include <string> | ||
|
||
#include "flutter/assets/asset_resolver.h" | ||
#include "lib/fxl/files/unique_fd.h" | ||
#include "lib/fxl/macros.h" | ||
#include "lib/fxl/memory/ref_counted.h" | ||
|
||
namespace blink { | ||
|
||
class AssetManager final : public AssetResolver, | ||
public fxl::RefCountedThreadSafe<AssetManager> { | ||
public: | ||
void PushFront(std::unique_ptr<AssetResolver> resolver); | ||
|
||
void PushBack(std::unique_ptr<AssetResolver> resolver); | ||
|
||
// |blink::AssetResolver| | ||
bool IsValid() const override; | ||
|
||
// |blink::AssetResolver| | ||
bool GetAsBuffer(const std::string& asset_name, | ||
std::vector<uint8_t>* data) const override; | ||
|
||
private: | ||
std::deque<std::unique_ptr<AssetResolver>> resolvers_; | ||
|
||
AssetManager(); | ||
|
||
~AssetManager(); | ||
|
||
FXL_DISALLOW_COPY_AND_ASSIGN(AssetManager); | ||
FRIEND_MAKE_REF_COUNTED(AssetManager); | ||
FRIEND_REF_COUNTED_THREAD_SAFE(AssetManager); | ||
}; | ||
|
||
} // namespace blink | ||
|
||
#endif // FLUTTER_ASSETS_ASSET_MANAGER_H_ |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
// Copyright 2017 The Flutter 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_ASSETS_ASSET_RESOLVER_H_ | ||
#define FLUTTER_ASSETS_ASSET_RESOLVER_H_ | ||
|
||
#include <string> | ||
#include <vector> | ||
|
||
#include "lib/fxl/macros.h" | ||
|
||
namespace blink { | ||
|
||
class AssetResolver { | ||
public: | ||
AssetResolver() = default; | ||
|
||
virtual ~AssetResolver() = default; | ||
|
||
virtual bool IsValid() const = 0; | ||
|
||
virtual bool GetAsBuffer(const std::string& asset_name, | ||
std::vector<uint8_t>* data) const = 0; | ||
|
||
private: | ||
FXL_DISALLOW_COPY_AND_ASSIGN(AssetResolver); | ||
}; | ||
|
||
} // namespace blink | ||
|
||
#endif // FLUTTER_ASSETS_ASSET_RESOLVER_H_ |
Oops, something went wrong.