Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(76)

Unified Diff: sky/engine/core/script/dart_loader.cc

Issue 926753002: Improve DartLoader error handling. (Closed) Base URL: git@github.com:domokit/mojo.git@master
Patch Set: Created 5 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « sky/engine/core/script/dart_loader.h ('k') | sky/engine/tonic/dart_error.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: sky/engine/core/script/dart_loader.cc
diff --git a/sky/engine/core/script/dart_loader.cc b/sky/engine/core/script/dart_loader.cc
index 4345dda3c099db161affa41fedbc171cf2a83df4..95ac8dc0442a3bc86565c0af25244911d50a8ef2 100644
--- a/sky/engine/core/script/dart_loader.cc
+++ b/sky/engine/core/script/dart_loader.cc
@@ -59,6 +59,10 @@ class DartLoader::Job : public DartDependency,
private:
// MojoFetcher::Client
void OnReceivedResponse(mojo::URLResponsePtr response) override {
+ if (response->status_code != 200) {
+ loader_->DidFailJob(this);
+ return;
+ }
// TODO(abarth): Handle network errors.
drainer_ = adoptPtr(new DataPipeDrainer(this, response->body.Pass()));
}
@@ -81,7 +85,9 @@ class DartLoader::ImportJob : public Job {
private:
// DataPipeDrainer::Client
void OnDataComplete() override {
- loader_->DidCompleteImportJob(this, buffer_);
+ // DataPipeDrainer calls OnDataComplete regardless of errors.
+ if (!loader_->saw_error())
+ loader_->DidCompleteImportJob(this, buffer_);
}
};
@@ -95,7 +101,9 @@ class DartLoader::SourceJob : public Job {
private:
// DataPipeDrainer::Client
void OnDataComplete() override {
- loader_->DidCompleteSourceJob(this, buffer_);
+ // DataPipeDrainer calls OnDataComplete regardless of errors.
+ if (!loader_->saw_error())
abarth-chromium 2015/02/13 23:50:29 Why do we only do this once for the entire lifetim
+ loader_->DidCompleteSourceJob(this, buffer_);
}
DartPersistentValue library_;
@@ -175,7 +183,9 @@ class DartLoader::WatcherSignaler {
};
DartLoader::DartLoader(DartState* dart_state)
- : dart_state_(dart_state->GetWeakPtr()), dependency_catcher_(nullptr) {
+ : dart_state_(dart_state->GetWeakPtr()),
+ dependency_catcher_(nullptr),
+ saw_error_(false) {
}
DartLoader::~DartLoader() {
@@ -231,6 +241,7 @@ Dart_Handle DartLoader::Source(Dart_Handle library, Dart_Handle url) {
void DartLoader::DidCompleteImportJob(ImportJob* job,
const Vector<uint8_t>& buffer) {
+ DCHECK(!saw_error_);
DCHECK(dart_state_);
DartIsolateScope scope(dart_state_->isolate());
DartApiScope api_scope;
@@ -248,6 +259,7 @@ void DartLoader::DidCompleteImportJob(ImportJob* job,
void DartLoader::DidCompleteSourceJob(SourceJob* job,
const Vector<uint8_t>& buffer) {
+ DCHECK(!saw_error_);
DCHECK(dart_state_);
DartIsolateScope scope(dart_state_->isolate());
DartApiScope api_scope;
@@ -262,4 +274,19 @@ void DartLoader::DidCompleteSourceJob(SourceJob* job,
jobs_.remove(job);
}
+void DartLoader::DidFailJob(Job* job) {
+ DCHECK(!saw_error_);
+ saw_error_ = true;
+ DCHECK(dart_state_);
+ DartIsolateScope scope(dart_state_->isolate());
+ DartApiScope api_scope;
+
+ WatcherSignaler watcher_signaler(*this, job);
+
+ LOG(ERROR) << "Library Load failed: " << job->url().string().utf8().data();
+ // TODO(eseidel): Call Dart_LibraryHandleError in the SourceJob case?
+
+ jobs_.remove(job);
+}
+
} // namespace blink
« no previous file with comments | « sky/engine/core/script/dart_loader.h ('k') | sky/engine/tonic/dart_error.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698