Update file_loader after Dart API updates
Change-Id: I06cb339a8be0bf78fd7d9ba6c79d20f3a1267b3b
diff --git a/file_loader/file_loader.cc b/file_loader/file_loader.cc
index ea7424b..4d0a23a 100644
--- a/file_loader/file_loader.cc
+++ b/file_loader/file_loader.cc
@@ -122,19 +122,6 @@
TONIC_DCHECK(Dart_IsString(url));
if (tag == Dart_kCanonicalizeUrl)
return CanonicalizeURL(library, url);
- if (tag == Dart_kImportTag)
- return Import(url);
- if (tag == Dart_kSourceTag)
- return Source(library, url);
- if (tag == Dart_kScriptTag) {
- // Clear dependencies.
- dependencies_.clear();
- url_dependencies_.clear();
- // Reload packages map.
- SetPackagesUrl(library);
- // Load the root script.
- return Script(url);
- }
if (tag == Dart_kKernelTag)
return Kernel(url);
return Dart_NewApiError("Unknown library tag.");
@@ -166,29 +153,6 @@
return url;
}
-std::string FileLoader::Fetch(const std::string& url,
- std::string* resolved_url) {
- std::string path = filesystem::SimplifyPath(GetFilePathForURL(url));
- if (path.empty()) {
- tonic::Log("error: Unable to read Dart source '%s'.", url.c_str());
- PlatformExit(1);
- }
- if (resolved_url)
- *resolved_url = GetFileURLForPath(path);
- std::string source;
- if (!ReadFileToString(filesystem::GetAbsoluteFilePath(path), &source)) {
- // TODO(johnmccutchan): The file loader should not explicitly log the error
- // or exit the process. Instead these errors should be reported to the
- // caller of the FileLoader who can implement the application-specific error
- // handling policy.
- tonic::Log("error: Unable to read Dart source '%s'.", url.c_str());
- PlatformExit(1);
- }
- url_dependencies_.insert(url);
- dependencies_.insert(path);
- return source;
-}
-
std::pair<uint8_t*, intptr_t> FileLoader::FetchBytes(const std::string& url) {
std::string path = filesystem::SimplifyPath(GetFilePathForURL(url));
if (path.empty()) {
@@ -210,29 +174,6 @@
return result;
}
-Dart_Handle FileLoader::LoadLibrary(const std::string& url) {
- std::string resolved_url;
- Dart_Handle source = ToDart(Fetch(url, &resolved_url));
- return Dart_LoadLibrary(ToDart(url), ToDart(resolved_url), source, 0, 0);
-}
-
-Dart_Handle FileLoader::LoadScript(const std::string& url) {
- std::string resolved_url;
- Dart_Handle source = ToDart(Fetch(url, &resolved_url));
- Dart_Handle result =
- Dart_LoadScript(ToDart(url), ToDart(resolved_url), source, 0, 0);
- if (!Dart_IsError(result)) {
- Dart_Handle finalize_result = Dart_FinalizeLoading(true);
- if (Dart_IsError(finalize_result))
- return finalize_result;
- }
- return result;
-}
-
-Dart_Handle FileLoader::Import(Dart_Handle url) {
- return LoadLibrary(StdStringFromDart(url));
-}
-
namespace {
void MallocFinalizer(void* isolate_callback_data,
Dart_WeakPersistentHandle handle,
@@ -251,17 +192,7 @@
return result;
}
-Dart_Handle FileLoader::Source(Dart_Handle library, Dart_Handle url) {
- std::string resolved_url;
- Dart_Handle source = ToDart(Fetch(StdStringFromDart(url), &resolved_url));
- return Dart_LoadSource(library, url, ToDart(resolved_url), source, 0, 0);
-}
-
// This is invoked upon a reload request.
-Dart_Handle FileLoader::Script(Dart_Handle url) {
- return LoadScript(StdStringFromDart(url));
-}
-
void FileLoader::SetPackagesUrl(Dart_Handle url) {
if (url == Dart_Null()) {
// No packages url specified.
diff --git a/file_loader/file_loader.h b/file_loader/file_loader.h
index 3d5a7d9..41a576b 100644
--- a/file_loader/file_loader.h
+++ b/file_loader/file_loader.h
@@ -40,17 +40,9 @@
Dart_Handle url);
Dart_Handle CanonicalizeURL(Dart_Handle library, Dart_Handle url);
- Dart_Handle Import(Dart_Handle url);
Dart_Handle Kernel(Dart_Handle url);
- Dart_Handle Source(Dart_Handle library, Dart_Handle url);
- Dart_Handle Script(Dart_Handle url);
void SetPackagesUrl(Dart_Handle url);
- Dart_Handle LoadLibrary(const std::string& url);
- Dart_Handle LoadScript(const std::string& url);
-
- std::string Fetch(const std::string& url,
- std::string* resolved_url = nullptr);
std::pair<uint8_t*, intptr_t> FetchBytes(const std::string& url);
static const char kFileURLPrefix[];