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

Side by Side Diff: sky/engine/bindings-dart/core/dart/DartController.h

Issue 918273002: Remove bindings-dart (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 unified diff | Download patch
OLDNEW
(Empty)
1 // Copyright 2011, Google Inc.
2 // All rights reserved.
3 //
4 // Redistribution and use in source and binary forms, with or without
5 // modification, are permitted provided that the following conditions are
6 // met:
7 //
8 // * Redistributions of source code must retain the above copyright
9 // notice, this list of conditions and the following disclaimer.
10 // * Redistributions in binary form must reproduce the above
11 // copyright notice, this list of conditions and the following disclaimer
12 // in the documentation and/or other materials provided with the
13 // distribution.
14 // * Neither the name of Google Inc. nor the names of its
15 // contributors may be used to endorse or promote products derived from
16 // this software without specific prior written permission.
17 //
18 // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
19 // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
20 // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
21 // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
22 // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
23 // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
24 // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
25 // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
26 // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
27 // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
28 // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
29
30 #ifndef DartController_h
31 #define DartController_h
32
33 #include "bindings/core/v8/ScriptSourceCode.h"
34 #include "wtf/Deque.h"
35 #include "wtf/HashMap.h"
36 #include "wtf/Vector.h"
37 #include "wtf/text/WTFString.h"
38
39 #include <dart_api.h>
40 #include <v8.h>
41
42 struct NPObject;
43
44 namespace blink {
45
46 class DartApplicationLoader;
47 class DartDOMData;
48 class DartScriptInfo;
49 class DartScriptState;
50 class Document;
51 class ExecutionContext;
52 class LocalDOMWindow;
53 class LocalFrame;
54 class ScriptLoader;
55 class ScriptState;
56 class V8ScriptState;
57
58 typedef HashMap<intptr_t, RefPtr<DartScriptState> > LibraryIdMap;
59 typedef HashMap<Dart_Isolate, LibraryIdMap*> ScriptStatesMap;
60
61 // This class provides the linkage between a LocalFrame and its attached
62 // Dart isolates. It is similar to ScriptController for JavaScript.
63 // The DartController is owned by its LocalFrame.
64 class DartController {
65 public:
66 DartController(LocalFrame*);
67 virtual ~DartController();
68
69 void evaluate(const ScriptSourceCode&, ScriptLoader* = 0);
70
71 // Exposes NPObject instance to Dart environment.
72 void bindToWindowObject(LocalFrame*, const String& key, NPObject*);
73 NPObject* npObject(const String& key);
74
75 void clearWindowShell();
76 void clearScriptObjects();
77
78 Dart_Handle callFunction(Dart_Handle function, int argc, Dart_Handle* argv);
79
80 LocalFrame* frame() const { return m_frame; }
81 void collectScriptStates(V8ScriptState*, Vector<DartScriptState*>& result);
82 void collectScriptStatesForIsolate(Dart_Isolate, v8::Handle<v8::Context> v8C ontext, Vector<DartScriptState*>& result);
83 DartScriptState* lookupScriptState(Dart_Isolate, v8::Handle<v8::Context> v8C ontext, intptr_t libraryId);
84
85 static DartController* retrieve(LocalFrame*);
86 static DartController* retrieve(ExecutionContext*);
87
88 bool isActive() { return !m_isolates.isEmpty(); }
89
90 void spawnDomUri(const String& uri);
91
92 private:
93 static void initVMIfNeeded();
94
95 static Dart_Isolate createIsolate(const char* scriptURL, const char* entryPo int, Document*, bool isDOMEnabled, bool isDebuggerEnabled, char** errorMessage);
96 void shutdownIsolate(Dart_Isolate);
97
98 Dart_Isolate createDOMEnabledIsolate(const String& scriptURL, const String& entryPoint, Document*);
99 void scheduleScriptExecution(const String&, Dart_Isolate, PassRefPtr<DartScr iptInfo>);
100 void loadAndRunScript(const String&, Dart_Isolate, PassRefPtr<DartScriptInfo >);
101 static void shutdownIsolateCallback(void* data);
102 static Dart_Isolate createServiceIsolateCallback(void* callbackData, char** error);
103 static Dart_Isolate createPureIsolateCallback(const char* prefix, const char * main, const char* packageRoot, void* callbackData, char** errorMsg);
104
105 static void weakCallback(void* isolateCallbackData, Dart_WeakPersistentHandl e, void* peer);
106
107 HashSet<Document*> m_documentsWithDart;
108
109 LibraryIdMap* libraryIdMapForIsolate(Dart_Isolate);
110 DartScriptState* lookupScriptStateFromLibraryIdMap(Dart_Isolate, v8::Handle< v8::Context>, LibraryIdMap*, intptr_t libraryId);
111
112 // The frame that owns this controller.
113 LocalFrame* m_frame;
114
115 // Isolate associated with scripts in this document.
116 Vector<Dart_Isolate> m_isolates;
117 RefPtr<DartApplicationLoader> m_loader;
118
119 ScriptStatesMap m_scriptStates;
120
121 typedef HashMap<String, NPObject*> NPObjectMap;
122 NPObjectMap m_npObjectMap;
123
124 friend class DartDomLoadCallback;
125 friend class DartScriptRunner;
126 friend class DartService;
127 };
128
129 }
130
131 #endif // DartController_h
OLDNEW
« no previous file with comments | « sky/engine/bindings-dart/core/dart/DartCallback.cpp ('k') | sky/engine/bindings-dart/core/dart/DartController.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698