| OLD | NEW |
| 1 // Copyright (c) 2009, Google Inc. | 1 // Copyright (c) 2009, Google Inc. |
| 2 // All rights reserved. | 2 // All rights reserved. |
| 3 // | 3 // |
| 4 // Redistribution and use in source and binary forms, with or without | 4 // Redistribution and use in source and binary forms, with or without |
| 5 // modification, are permitted provided that the following conditions are | 5 // modification, are permitted provided that the following conditions are |
| 6 // met: | 6 // met: |
| 7 // | 7 // |
| 8 // * Redistributions of source code must retain the above copyright | 8 // * Redistributions of source code must retain the above copyright |
| 9 // notice, this list of conditions and the following disclaimer. | 9 // notice, this list of conditions and the following disclaimer. |
| 10 // * Redistributions in binary form must reproduce the above | 10 // * Redistributions in binary form must reproduce the above |
| (...skipping 249 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 260 } | 260 } |
| 261 | 261 |
| 262 void DartApplicationLoader::load(PassRefPtr<DartErrorEventDispatcher> errorEvent
Dispatcher) | 262 void DartApplicationLoader::load(PassRefPtr<DartErrorEventDispatcher> errorEvent
Dispatcher) |
| 263 { | 263 { |
| 264 RELEASE_ASSERT(m_state == Ready || m_state == DeferredReady); | 264 RELEASE_ASSERT(m_state == Ready || m_state == DeferredReady); |
| 265 | 265 |
| 266 m_errorEventDispatcher = errorEventDispatcher; | 266 m_errorEventDispatcher = errorEventDispatcher; |
| 267 | 267 |
| 268 DartIsolateScope isolateScope(m_isolate); | 268 DartIsolateScope isolateScope(m_isolate); |
| 269 DartApiScope dartApiScope; | 269 DartApiScope dartApiScope; |
| 270 bool completeFutures = false; |
| 270 | 271 |
| 271 // Indicate to the VM that all outstanding load requests are done. This | 272 // Finalize classes and complete futures if there are any deferred loads. |
| 272 // call will finalize all the classes loaded so far and complete all | 273 if (!m_mainInvoked) { |
| 273 // deferred library load futures. | 274 RELEASE_ASSERT(m_state == Ready); |
| 275 } else { |
| 276 // We have already invoked the entry point on the main script URL at |
| 277 // this point we will start running dart code again. |
| 278 RELEASE_ASSERT(m_state == DeferredReady); |
| 279 m_state = Running; |
| 280 completeFutures = true; |
| 281 } |
| 274 { | 282 { |
| 275 V8Scope v8scope(DartDOMData::current()); | 283 V8Scope v8scope(DartDOMData::current()); |
| 276 Dart_Handle result = Dart_FinalizeLoading(true); | 284 Dart_Handle result = Dart_FinalizeLoading(completeFutures); |
| 277 if (Dart_IsError(result)) { | 285 if (Dart_IsError(result)) { |
| 278 reportDartError(result); | 286 reportDartError(result); |
| 279 return; | 287 return; |
| 280 } | 288 } |
| 281 } | 289 } |
| 282 | |
| 283 // Invoke the entry point on the main script URL if it has not yet been | 290 // Invoke the entry point on the main script URL if it has not yet been |
| 284 // invoked. | 291 // invoked. |
| 285 if (!m_mainInvoked) { | 292 if (!m_mainInvoked) { |
| 286 RELEASE_ASSERT(m_state == Ready); | |
| 287 // Call the entry point on the main script URL. | 293 // Call the entry point on the main script URL. |
| 288 callEntryPoint(); | 294 callEntryPoint(); |
| 289 } | 295 } |
| 290 } | 296 } |
| 291 | 297 |
| 292 void DartApplicationLoader::loadScriptFromSnapshot(const String& url, const uint
8_t* snapshot, intptr_t snapshotSize) | 298 void DartApplicationLoader::loadScriptFromSnapshot(const String& url, const uint
8_t* snapshot, intptr_t snapshotSize) |
| 293 { | 299 { |
| 294 // FIXME(vsm): State? | 300 // FIXME(vsm): State? |
| 295 | 301 |
| 296 Timeline timeline(m_originDocument->frame(), String("loadSnapshot@") + m_scr
iptUrlString); | 302 Timeline timeline(m_originDocument->frame(), String("loadSnapshot@") + m_scr
iptUrlString); |
| (...skipping 326 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 623 void DartApplicationLoader::reportError(const String& error, const String& url) | 629 void DartApplicationLoader::reportError(const String& error, const String& url) |
| 624 { | 630 { |
| 625 if (m_state < Running) | 631 if (m_state < Running) |
| 626 m_state = Error; | 632 m_state = Error; |
| 627 m_error = true; | 633 m_error = true; |
| 628 m_loadCallback->reportError(error, url); | 634 m_loadCallback->reportError(error, url); |
| 629 } | 635 } |
| 630 | 636 |
| 631 | 637 |
| 632 } | 638 } |
| OLD | NEW |