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

Side by Side Diff: Source/bindings/dart/DartApplicationLoader.h

Issue 26490003: Reapply "Move isolate loading to a separate loader isolate." (Closed) Base URL: svn://svn.chromium.org/multivm/trunk/webkit
Patch Set: Initialize flag properly Created 7 years, 2 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
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 12 matching lines...) Expand all
23 // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 23 // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
24 // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 24 // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
25 // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 25 // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
26 // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 26 // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
27 // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 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. 28 // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
29 29
30 #ifndef DartApplicationLoader_h 30 #ifndef DartApplicationLoader_h
31 #define DartApplicationLoader_h 31 #define DartApplicationLoader_h
32 32
33 #include "bindings/dart/DartAsyncLoader.h"
33 #include "bindings/v8/ScriptSourceCode.h" 34 #include "bindings/v8/ScriptSourceCode.h"
34 #include "core/html/HTMLScriptElement.h" 35 #include "core/html/HTMLScriptElement.h"
35 #include "core/html/VoidCallback.h" 36 #include "core/html/VoidCallback.h"
36 #include <dart_api.h> 37 #include <dart_api.h>
37 #include <wtf/HashMap.h> 38 #include <wtf/HashMap.h>
38 #include <wtf/HashSet.h> 39 #include <wtf/HashSet.h>
39 #include <wtf/text/StringHash.h> 40 #include <wtf/text/StringHash.h>
40 41
41 namespace WebCore { 42 namespace WebCore {
42 43
43 class KURL; 44 class KURL;
44 45
45 class DartApplicationLoader : public RefCounted<DartApplicationLoader> { 46 class DartApplicationLoader : public RefCounted<DartApplicationLoader> {
46 public: 47 public:
47 class ErrorEventDispatcher : public RefCounted<ErrorEventDispatcher> { 48 class ErrorEventDispatcher : public RefCounted<ErrorEventDispatcher> {
48 public: 49 public:
49 virtual ~ErrorEventDispatcher() { } 50 virtual ~ErrorEventDispatcher() { }
50 virtual void dispatchErrorEvent() = 0; 51 virtual void dispatchErrorEvent() = 0;
51 }; 52 };
52 53
53 DartApplicationLoader(Dart_Isolate, Document*, PassRefPtr<ErrorEventDispatch er>, PassRefPtr<VoidCallback> = 0, bool domEnabled = true); 54 DartApplicationLoader(Dart_Isolate, Document*, PassRefPtr<ErrorEventDispatch er>, PassRefPtr<DartAsyncLoader>, bool domEnabled = true);
54 55
55 void loadScriptResource(const String& url); 56 void load(const String& url, const String& source, int startLineNumber);
56 void load(const String& url, const String& source, WTF::OrdinalNumber startL ineNumber);
57 const String& mainLibraryURL() const { return m_libraryUrl; } 57 const String& mainLibraryURL() const { return m_libraryUrl; }
58 58
59 Document* document() { return m_originDocument; } 59 Document* document() { return m_originDocument; }
60 60
61 static void installLibraryTagHandlerForCurrentIsolate(); 61 static void installLibraryTagHandlerForCurrentIsolate();
62 62
63 private: 63 private:
64 void scriptLoadError(String failedUrl); 64 void scriptLoadError(String failedUrl);
65 void loadMainScript(const String& url, const String& source, WTF::OrdinalNum ber startLineNumber); 65 void loadMainScript(const String& url, const String& source, int startLineNu mber);
66 66
67 static Dart_Handle libraryTagHandlerCallback(Dart_LibraryTag, Dart_Handle li brary, Dart_Handle urlHandle); 67 static Dart_Handle libraryTagHandlerCallback(Dart_LibraryTag, Dart_Handle li brary, Dart_Handle urlHandle);
68 static Dart_Handle CanonicalizeUrl(Dart_Handle library, Dart_Handle urlHandl e, String url);
69 Dart_Handle libraryTagHandler(Dart_LibraryTag, Dart_Handle library, Dart_Han dle urlHandle, String url); 68 Dart_Handle libraryTagHandler(Dart_LibraryTag, Dart_Handle library, Dart_Han dle urlHandle, String url);
70 69
71 Dart_Isolate m_isolate; 70 Dart_Isolate m_isolate;
72 // Client must ensure that DartApplicationLoader doesn't outlive correspondi ng document. 71 // Client must ensure that DartApplicationLoader doesn't outlive correspondi ng document.
73 Document* m_originDocument; 72 Document* m_originDocument;
74 RefPtr<ErrorEventDispatcher> m_errorEventDispatcher; 73 RefPtr<ErrorEventDispatcher> m_errorEventDispatcher;
75 String m_libraryUrl; 74 String m_libraryUrl;
76 75
77 void loadScriptFromSnapshot(const String& url, const uint8_t* snapshot, intp tr_t snapshotSize); 76 void loadScriptFromSnapshot(const String& url, const uint8_t* snapshot, intp tr_t snapshotSize);
78 void loadLibrary(const String& url, const String& source); 77 void loadLibrary(const String& url, const String& source);
79 void loadSource(const String& url, const String& source);
80 void callEntryPoint(); 78 void callEntryPoint();
81 79
82 Dart_Handle topLevelLibrary(); 80 Dart_Handle topLevelLibrary();
83 81
84 void reportDartError(Dart_Handle); 82 void reportDartError(Dart_Handle);
85 83
86 typedef HashSet<String> UrlSet;
87 typedef HashMap<String, UrlSet*> UrlMultiMap;
88
89 void add(UrlMultiMap&, const String& key, const String& value);
90
91 // FIXME: we can get rid of imported libs and sources map.
92 UrlSet m_importedLibraries;
93 UrlMultiMap m_importersForSource;
94
95 bool m_mainScriptHasBeenLoaded;
96
97 bool m_scriptHasError; 84 bool m_scriptHasError;
98
99 RefPtr<VoidCallback> m_applicationLoadedCallback;
100 bool m_domEnabled; 85 bool m_domEnabled;
101 86
102 friend class ScriptLoadCallback; 87 RefPtr<DartAsyncLoader> m_asyncLoader;
103 }; 88 };
104 89
105 } 90 }
106 91
107 #endif // DartApplicationLoader_h 92 #endif // DartApplicationLoader_h
OLDNEW
« no previous file with comments | « LayoutTests/dart/script-onerror-expected.txt ('k') | Source/bindings/dart/DartApplicationLoader.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698