提交 c1cad6cc 编写于 作者: E Eric Seidel

Don't crash when main.dart is a 404.

Ideally we would show a failwhale or some such, but
I don't know how we would bundle that file with our
APK yet.

Fixes https://github.com/domokit/mojo/issues/228

R=abarth@chromium.org

Review URL: https://codereview.chromium.org/1182633002.
上级 08b0b8b5
......@@ -119,7 +119,9 @@ void DartController::DidLoadMainLibrary(KURL url) {
Dart_Handle library = Dart_LookupLibrary(
StringToDart(dart_state(), url.string()));
CHECK(!LogIfError(library));
// TODO(eseidel): We need to load a 404 page instead!
if (LogIfError(library))
return;
DartInvokeAppField(library, ToDart("main"), 0, nullptr);
}
......
......@@ -239,6 +239,11 @@ void DartLoader::WaitForDependencies(
}
void DartLoader::LoadLibrary(const KURL& url, mojo::URLResponsePtr response) {
if (response && response->status_code >= 400) {
LOG(ERROR) << url.string().utf8().data()
<< " failed with " << response->status_code;
}
const auto& result = pending_libraries_.add(url.string(), nullptr);
if (result.isNewEntry) {
OwnPtr<Job> job = adoptPtr(new ImportJob(this, url));
......
......@@ -76,9 +76,14 @@ public class UrlLoaderImpl implements UrlLoader {
buffer.put(tmp);
mProducer.endWriteData(result == -1 ? 0 : result);
} catch (MojoException e) {
if (e.getMojoResult() != MojoResult.SHOULD_WAIT)
throw e;
// No one read the pipe, they just closed it.
if (e.getMojoResult() == MojoResult.FAILED_PRECONDITION) {
break;
} else if (e.getMojoResult() == MojoResult.SHOULD_WAIT) {
mCore.wait(mProducer, Core.HandleSignals.WRITABLE, -1);
} else {
throw e;
}
} catch (IOException e) {
Log.e(TAG, "mSource.read failed", e);
break;
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册