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

Side by Side Diff: Source/WebCore/bindings/dart/DartController.h

Issue 9188009: Things to unfork. (Closed) Base URL: svn://svn.chromium.org/multivm/trunk/webkit
Patch Set: Created 8 years, 11 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 | Annotate | Revision Log
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 "DartApplicationLoader.h"
34 #include "ScriptSourceCode.h"
35
36 #include <dart_api.h>
37 #include <wtf/HashMap.h>
38 #include <wtf/Vector.h>
39 #include <wtf/text/WTFString.h>
40
41 struct NPObject;
42
43 namespace WebCore {
44
45 class DOMWindow;
46 class Frame;
47 class ScriptExecutionContext;
48
49 // VM state per single Dart <SCRIPT> tag.
50 class DartPerScriptState {
51 public:
52 PassRefPtr<DartApplicationLoader> dartApplicationLoader() { return m_dartApp licationLoader; }
53 Dart_Isolate isolate() { return m_isolate; }
54
55 DartPerScriptState(Document*, PassRefPtr<DartApplicationLoader>);
56 ~DartPerScriptState();
57
58 private:
59 RefPtr<DartApplicationLoader> m_dartApplicationLoader;
60 Dart_Isolate m_isolate;
61 };
62
63 // This class provides the linkage between a Frame and its attached
64 // Dart isolates. It is similar to ScriptController for JavaScript.
65 // The DartController is owned by its Frame.
66 class DartController {
67 public:
68 DartController(Frame*);
69 virtual ~DartController() {}
70
71 void evaluate(const ScriptSourceCode&);
72
73 // Exposes NPObject instance to Dart environment.
74 void bindToWindowObject(Frame*, const String& key, NPObject*);
75 NPObject* npObject(const String& key);
76
77 void clearWindowShell();
78
79 Dart_Handle callFunction(Dart_Handle function, int argc, Dart_Handle* argv);
80
81 Frame* frame() const { return m_frame; }
82
83 Dart_Handle spawnDomIsolate(DOMWindow* targetWindow, const String& entryPoin t);
84
85 static DartController* retrieve(Frame*);
86 static DartController* retrieve(ScriptExecutionContext*);
87
88 static void setDartVMFlags(const String&);
89
90 static void setupDOMEnabledIsolate(ScriptExecutionContext*);
91
92 private:
93 static void initVMIfNeeded();
94 static bool createPureIsolateCallback(void*, char** errorMsg);
95
96 bool isDartMimeType(const String& mimeType);
97 void loadScripts();
98
99 void didLeaveScriptContext(int recursion);
100
101 // The frame that owns this controller.
102 Frame* m_frame;
103
104 bool m_scriptsLoaded;
105
106 typedef Vector< OwnPtr<DartPerScriptState> > DartScriptsList;
107 // Dart VM states associated with scripts in this document.
108 DartScriptsList m_states;
109
110 typedef HashMap<String, NPObject*> NPObjectMap;
111 NPObjectMap m_npObjectMap;
112
113 friend class DartScriptRunner;
114 };
115
116 }
117
118 #endif // DartController_h
OLDNEW
« no previous file with comments | « Source/WebCore/bindings/dart/DartClassInfo.cpp ('k') | Source/WebCore/bindings/dart/DartController.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698