Skip to content

Commit

Permalink
Revert "[fuchsia] Enable running from source packages (flutter#4629)" (
Browse files Browse the repository at this point in the history
…flutter#4632)

This reverts commit 8f63859.
  • Loading branch information
zanderso authored Feb 3, 2018
1 parent 8f63859 commit 151bb37
Show file tree
Hide file tree
Showing 7 changed files with 9 additions and 30 deletions.
1 change: 0 additions & 1 deletion content_handler/application_controller_impl.cc
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,6 @@ ApplicationControllerImpl::ApplicationControllerImpl(
fdio_ns_t* fdio_ns = SetupNamespace(startup_info->flat_namespace);
if (fdio_ns == nullptr) {
FXL_LOG(ERROR) << "Failed to initialize namespace";
return;
}

url_ = startup_info->launch_info->url;
Expand Down
19 changes: 3 additions & 16 deletions content_handler/runtime_holder.cc
Original file line number Diff line number Diff line change
Expand Up @@ -24,12 +24,10 @@
#include "flutter/runtime/runtime_init.h"
#include "lib/app/cpp/connect.h"
#include "lib/fsl/vmo/vector.h"
#include "lib/fxl/files/path.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"
#include "lib/tonic/logging/dart_error.h"
#include "lib/zip/create_unzipper.h"
#include "third_party/dart/runtime/include/dart_api.h"
#include "third_party/rapidjson/rapidjson/document.h"
Expand Down Expand Up @@ -117,11 +115,6 @@ void RuntimeHolder::Init(
FXL_DCHECK(rasterizer_);

namespc_ = namespc;
dirfd_ = fdio_ns_opendir(namespc);
if (dirfd_ == -1) {
FXL_LOG(ERROR) << "Failed to get fd for namespace";
return;
}
context_ = std::move(context);
outgoing_services_ = std::move(outgoing_services);

Expand Down Expand Up @@ -203,12 +196,11 @@ void RuntimeHolder::CreateView(

std::vector<uint8_t> kernel;
std::vector<uint8_t> snapshot;
bool maybe_running_from_source = false;
if (!Dart_IsPrecompiledRuntime()) {
if (!GetAssetAsBuffer(kKernelKey, &kernel) &&
!GetAssetAsBuffer(kSnapshotKey, &snapshot)) {
maybe_running_from_source = true;
FXL_LOG(INFO) << "No kernel or snapshot in root bundle.";
FXL_LOG(ERROR) << "Unable to load kernel or snapshot from root bundle.";
return;
}
}

Expand Down Expand Up @@ -281,19 +273,14 @@ void RuntimeHolder::CreateView(
dlsym(dylib_handle_, "_kDartIsolateSnapshotInstructions"));
}
runtime_->CreateDartController(script_uri, isolate_snapshot_data,
isolate_snapshot_instr, dirfd_);
isolate_snapshot_instr);

runtime_->SetViewportMetrics(viewport_metrics_);

if (Dart_IsPrecompiledRuntime()) {
runtime_->dart_controller()->RunFromPrecompiledSnapshot();
} else if (!kernel.empty()) {
runtime_->dart_controller()->RunFromKernel(std::move(kernel));
} else if (maybe_running_from_source) {
std::string basename = files::GetBaseName(script_uri);
std::string main_dart = "pkg/data/" + basename + "/lib/main.dart";
FXL_LOG(INFO) << "Running from source with entrypoint: '" << main_dart << "'";
runtime_->dart_controller()->RunFromSource(main_dart, "pkg/data/.packages");
} else {
runtime_->dart_controller()->RunFromScriptSnapshot(snapshot.data(),
snapshot.size());
Expand Down
1 change: 0 additions & 1 deletion content_handler/runtime_holder.h
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,6 @@ class RuntimeHolder : public blink::RuntimeDelegate,
void Invalidate();

fdio_ns_t* namespc_;
int dirfd_;
std::unique_ptr<app::ApplicationContext> context_;
fidl::InterfaceRequest<app::ServiceProvider> outgoing_services_;
std::vector<char> root_bundle_data_;
Expand Down
6 changes: 2 additions & 4 deletions lib/ui/ui_dart_state.cc
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,8 @@ namespace blink {
IsolateClient::~IsolateClient() {}

UIDartState::UIDartState(IsolateClient* isolate_client,
std::unique_ptr<Window> window,
int dirfd)
: tonic::DartState(dirfd),
isolate_client_(isolate_client),
std::unique_ptr<Window> window)
: isolate_client_(isolate_client),
main_port_(ILLEGAL_PORT),
window_(std::move(window)) {}

Expand Down
4 changes: 1 addition & 3 deletions lib/ui/ui_dart_state.h
Original file line number Diff line number Diff line change
Expand Up @@ -28,9 +28,7 @@ class IsolateClient {

class UIDartState : public tonic::DartState {
public:
UIDartState(IsolateClient* isolate_client,
std::unique_ptr<Window> window,
int dirfd = -1);
UIDartState(IsolateClient* isolate_client, std::unique_ptr<Window> window);
~UIDartState() override;

static UIDartState* Current();
Expand Down
5 changes: 2 additions & 3 deletions runtime/runtime_controller.cc
Original file line number Diff line number Diff line change
Expand Up @@ -29,14 +29,13 @@ RuntimeController::~RuntimeController() {}
void RuntimeController::CreateDartController(
const std::string& script_uri,
const uint8_t* isolate_snapshot_data,
const uint8_t* isolate_snapshot_instr,
int dirfd) {
const uint8_t* isolate_snapshot_instr) {
FXL_DCHECK(!dart_controller_);

dart_controller_.reset(new DartController());
dart_controller_->CreateIsolateFor(
script_uri, isolate_snapshot_data, isolate_snapshot_instr,
std::make_unique<UIDartState>(this, std::make_unique<Window>(this), dirfd));
std::make_unique<UIDartState>(this, std::make_unique<Window>(this)));

UIDartState* dart_state = dart_controller_->dart_state();
DartState::Scope scope(dart_state);
Expand Down
3 changes: 1 addition & 2 deletions runtime/runtime_controller.h
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,7 @@ class RuntimeController : public WindowClient, public IsolateClient {

void CreateDartController(const std::string& script_uri,
const uint8_t* isolate_snapshot_data,
const uint8_t* isolate_snapshot_instr,
int dirfd = -1);
const uint8_t* isolate_snapshot_instr);
DartController* dart_controller() const { return dart_controller_.get(); }

void SetViewportMetrics(const ViewportMetrics& metrics);
Expand Down

0 comments on commit 151bb37

Please sign in to comment.