| OLD | NEW |
| 1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "sky/engine/tonic/dart_library_loader.h" | 5 #include "sky/engine/tonic/dart_library_loader.h" |
| 6 | 6 |
| 7 #include "base/callback.h" | 7 #include "base/callback.h" |
| 8 #include "base/trace_event/trace_event.h" | 8 #include "base/trace_event/trace_event.h" |
| 9 #include "mojo/common/data_pipe_drainer.h" | 9 #include "mojo/common/data_pipe_drainer.h" |
| 10 #include "sky/engine/tonic/dart_api_scope.h" | 10 #include "sky/engine/tonic/dart_api_scope.h" |
| (...skipping 224 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 235 return library_provider_->CanonicalizeURL(library, url); | 235 return library_provider_->CanonicalizeURL(library, url); |
| 236 } | 236 } |
| 237 | 237 |
| 238 void DartLibraryLoader::DidCompleteImportJob(ImportJob* job, | 238 void DartLibraryLoader::DidCompleteImportJob(ImportJob* job, |
| 239 const Vector<uint8_t>& buffer) { | 239 const Vector<uint8_t>& buffer) { |
| 240 DartIsolateScope scope(dart_state_->isolate()); | 240 DartIsolateScope scope(dart_state_->isolate()); |
| 241 DartApiScope api_scope; | 241 DartApiScope api_scope; |
| 242 | 242 |
| 243 WatcherSignaler watcher_signaler(*this, job); | 243 WatcherSignaler watcher_signaler(*this, job); |
| 244 | 244 |
| 245 LogIfError(Dart_LoadLibrary( | 245 Dart_Handle result = Dart_LoadLibrary( |
| 246 StringToDart(dart_state_, job->name()), | 246 StringToDart(dart_state_, job->name()), |
| 247 Dart_NewStringFromUTF8(buffer.data(), buffer.size()), 0, 0)); | 247 Dart_NewStringFromUTF8(buffer.data(), buffer.size()), 0, 0); |
| 248 if (Dart_IsError(result)) { |
| 249 LOG(ERROR) << "Error Loading " << job->name().utf8().data() << " " |
| 250 << Dart_GetError(result); |
| 251 } |
| 248 | 252 |
| 249 pending_libraries_.remove(job->name()); | 253 pending_libraries_.remove(job->name()); |
| 250 jobs_.remove(job); | 254 jobs_.remove(job); |
| 251 } | 255 } |
| 252 | 256 |
| 253 void DartLibraryLoader::DidCompleteSourceJob(SourceJob* job, | 257 void DartLibraryLoader::DidCompleteSourceJob(SourceJob* job, |
| 254 const Vector<uint8_t>& buffer) { | 258 const Vector<uint8_t>& buffer) { |
| 255 DartIsolateScope scope(dart_state_->isolate()); | 259 DartIsolateScope scope(dart_state_->isolate()); |
| 256 DartApiScope api_scope; | 260 DartApiScope api_scope; |
| 257 | 261 |
| 258 WatcherSignaler watcher_signaler(*this, job); | 262 WatcherSignaler watcher_signaler(*this, job); |
| 259 | 263 |
| 260 LogIfError(Dart_LoadSource( | 264 Dart_Handle result = Dart_LoadSource( |
| 261 Dart_HandleFromPersistent(job->library()), | 265 Dart_HandleFromPersistent(job->library()), |
| 262 StringToDart(dart_state_, job->name()), | 266 StringToDart(dart_state_, job->name()), |
| 263 Dart_NewStringFromUTF8(buffer.data(), buffer.size()), 0, 0)); | 267 Dart_NewStringFromUTF8(buffer.data(), buffer.size()), 0, 0); |
| 268 |
| 269 if (Dart_IsError(result)) { |
| 270 LOG(ERROR) << "Error Loading " << job->name().utf8().data() << " " |
| 271 << Dart_GetError(result); |
| 272 } |
| 264 | 273 |
| 265 jobs_.remove(job); | 274 jobs_.remove(job); |
| 266 } | 275 } |
| 267 | 276 |
| 268 void DartLibraryLoader::DidFailJob(Job* job) { | 277 void DartLibraryLoader::DidFailJob(Job* job) { |
| 269 DartIsolateScope scope(dart_state_->isolate()); | 278 DartIsolateScope scope(dart_state_->isolate()); |
| 270 DartApiScope api_scope; | 279 DartApiScope api_scope; |
| 271 | 280 |
| 272 WatcherSignaler watcher_signaler(*this, job); | 281 WatcherSignaler watcher_signaler(*this, job); |
| 273 | 282 |
| 274 LOG(ERROR) << "Library Load failed: " << job->name().utf8().data(); | 283 LOG(ERROR) << "Library Load failed: " << job->name().utf8().data(); |
| 275 // TODO(eseidel): Call Dart_LibraryHandleError in the SourceJob case? | 284 // TODO(eseidel): Call Dart_LibraryHandleError in the SourceJob case? |
| 276 | 285 |
| 277 jobs_.remove(job); | 286 jobs_.remove(job); |
| 278 } | 287 } |
| 279 | 288 |
| 280 } // namespace blink | 289 } // namespace blink |
| OLD | NEW |