| OLD | NEW |
| 1 // Copyright 2011, Google Inc. | 1 // Copyright 2011, 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 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 46 class DartApplicationLoader; | 46 class DartApplicationLoader; |
| 47 class DartAsyncLoader; | 47 class DartAsyncLoader; |
| 48 class DartDOMData; | 48 class DartDOMData; |
| 49 class DartScriptState; | 49 class DartScriptState; |
| 50 class DOMWindow; | 50 class DOMWindow; |
| 51 class Frame; | 51 class Frame; |
| 52 class ScriptElementProxy; | 52 class ScriptElementProxy; |
| 53 class ScriptExecutionContext; | 53 class ScriptExecutionContext; |
| 54 class ScriptState; | 54 class ScriptState; |
| 55 | 55 |
| 56 typedef HashMap<intptr_t, DartScriptState*> LibraryIdMap; |
| 57 typedef HashMap<Dart_Isolate, LibraryIdMap*> ScriptStatesMap; |
| 58 |
| 56 // This class provides the linkage between a Frame and its attached | 59 // This class provides the linkage between a Frame and its attached |
| 57 // Dart isolates. It is similar to ScriptController for JavaScript. | 60 // Dart isolates. It is similar to ScriptController for JavaScript. |
| 58 // The DartController is owned by its Frame. | 61 // The DartController is owned by its Frame. |
| 59 class DartController { | 62 class DartController { |
| 60 public: | 63 public: |
| 61 DartController(Frame*); | 64 DartController(Frame*); |
| 62 virtual ~DartController(); | 65 virtual ~DartController(); |
| 63 | 66 |
| 64 void evaluate(const ScriptSourceCode&); | 67 void evaluate(const ScriptSourceCode&); |
| 65 void isolatedWorldCreated(v8::Handle<v8::Context>); | 68 void isolatedWorldCreated(v8::Handle<v8::Context>); |
| 66 | 69 |
| 67 // Exposes NPObject instance to Dart environment. | 70 // Exposes NPObject instance to Dart environment. |
| 68 void bindToWindowObject(Frame*, const String& key, NPObject*); | 71 void bindToWindowObject(Frame*, const String& key, NPObject*); |
| 69 NPObject* npObject(const String& key); | 72 NPObject* npObject(const String& key); |
| 70 | 73 |
| 71 void clearWindowShell(); | 74 void clearWindowShell(); |
| 72 | 75 |
| 73 Dart_Handle callFunction(Dart_Handle function, int argc, Dart_Handle* argv); | 76 Dart_Handle callFunction(Dart_Handle function, int argc, Dart_Handle* argv); |
| 74 | 77 |
| 75 void startDart(); | 78 void startDart(); |
| 76 | 79 |
| 77 Frame* frame() const { return m_frame; } | 80 Frame* frame() const { return m_frame; } |
| 78 void collectScriptStates(ScriptState* v8ScriptState, Vector<ScriptState*>& r
esult); | 81 void collectScriptStates(ScriptState* v8ScriptState, Vector<ScriptState*>& r
esult); |
| 79 void collectScriptStatesForIsolate(Dart_Isolate, v8::Handle<v8::Context> v8C
ontext, Vector<ScriptState*>& result); | 82 void collectScriptStatesForIsolate(Dart_Isolate, v8::Handle<v8::Context> v8C
ontext, Vector<ScriptState*>& result); |
| 83 DartScriptState* lookupScriptState(Dart_Isolate, v8::Handle<v8::Context> v8C
ontext, intptr_t libraryId); |
| 80 | 84 |
| 81 static DartController* retrieve(Frame*); | 85 static DartController* retrieve(Frame*); |
| 82 static DartController* retrieve(ScriptExecutionContext*); | 86 static DartController* retrieve(ScriptExecutionContext*); |
| 83 | 87 |
| 84 // FIXME: Move. | 88 // FIXME: Move. |
| 85 void loadAndRunScript(const String&, PassRefPtr<DartAsyncLoader>, PassRefPtr
<ScriptElementProxy>); | 89 void loadAndRunScript(const String&, PassRefPtr<DartAsyncLoader>, PassRefPtr
<ScriptElementProxy>); |
| 86 private: | 90 private: |
| 87 static void initVMIfNeeded(); | 91 static void initVMIfNeeded(); |
| 88 | 92 |
| 89 static Dart_Isolate createIsolate(const char* scriptURL, const char* entryPo
int, Document*, bool isDOMEnabled, char** errorMessage); | 93 static Dart_Isolate createIsolate(const char* scriptURL, const char* entryPo
int, Document*, bool isDOMEnabled, char** errorMessage); |
| 90 static void shutdownIsolate(Dart_Isolate); | 94 static void shutdownIsolate(Dart_Isolate); |
| 91 | 95 |
| 92 void createDOMEnabledIsolateIfNeeded(const String& scriptURL, const String&
entryPoint, Document*); | 96 void createDOMEnabledIsolateIfNeeded(const String& scriptURL, const String&
entryPoint, Document*); |
| 93 | 97 |
| 94 static Dart_Isolate createPureIsolateCallback(const char* prefix, const char
* main, void* callbackData, char** errorMsg); | 98 static Dart_Isolate createPureIsolateCallback(const char* prefix, const char
* main, void* callbackData, char** errorMsg); |
| 95 void installDartExtensions(v8::Handle<v8::Context>); | 99 void installDartExtensions(v8::Handle<v8::Context>); |
| 96 | 100 |
| 97 bool isDartMimeType(const String& mimeType); | 101 bool isDartMimeType(const String& mimeType); |
| 98 void loadScripts(); | 102 void loadScripts(); |
| 99 void collectScripts(HashSet<Document*>&, Document*); | 103 void collectScripts(HashSet<Document*>&, Document*); |
| 100 void processScriptInQueue(); | 104 void processScriptInQueue(); |
| 101 | 105 |
| 106 LibraryIdMap* libraryIdMapForIsolate(Dart_Isolate); |
| 107 DartScriptState* lookupScriptStateFromLibraryIdMap(Dart_Isolate, v8::Handle<
v8::Context>, LibraryIdMap*, intptr_t libraryId); |
| 108 |
| 102 // The frame that owns this controller. | 109 // The frame that owns this controller. |
| 103 Frame* m_frame; | 110 Frame* m_frame; |
| 104 | 111 |
| 105 bool m_scriptsLoaded; | 112 bool m_scriptsLoaded; |
| 106 Deque< RefPtr<Node> > m_scriptsToLoadQueue; | 113 Deque< RefPtr<Node> > m_scriptsToLoadQueue; |
| 107 | 114 |
| 108 // Isolate associated with scripts in this document. | 115 // Isolate associated with scripts in this document. |
| 109 Dart_Isolate m_isolate; | 116 Dart_Isolate m_isolate; |
| 110 RefPtr<DartApplicationLoader> m_loader; | 117 RefPtr<DartApplicationLoader> m_loader; |
| 111 | 118 |
| 112 typedef HashMap<intptr_t, DartScriptState*> LibraryIdMap; | |
| 113 typedef HashMap<Dart_Isolate, LibraryIdMap*> ScriptStatesMap; | |
| 114 ScriptStatesMap m_scriptStates; | 119 ScriptStatesMap m_scriptStates; |
| 115 | 120 |
| 116 typedef HashMap<String, NPObject*> NPObjectMap; | 121 typedef HashMap<String, NPObject*> NPObjectMap; |
| 117 NPObjectMap m_npObjectMap; | 122 NPObjectMap m_npObjectMap; |
| 118 | 123 |
| 119 friend class DartScriptRunner; | 124 friend class DartScriptRunner; |
| 120 friend class DartDomCallback; | 125 friend class DartDomCallback; |
| 121 }; | 126 }; |
| 122 | 127 |
| 123 } | 128 } |
| 124 | 129 |
| 125 #endif // DartController_h | 130 #endif // DartController_h |
| OLD | NEW |