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

Side by Side Diff: Source/WebCore/bindings/dart/DartApplicationLoader.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 DartApplicationLoader_h
31 #define DartApplicationLoader_h
32
33 #include "ScriptSourceCode.h"
34
35 #include <dart_api.h>
36 #include <wtf/HashMap.h>
37 #include <wtf/HashSet.h>
38 #include <wtf/text/StringHash.h>
39
40 namespace WebCore {
41
42 class Document;
43 class KURL;
44 class ScriptSourceCode;
45
46 // FIXME: move into a file on its own when source reinjection is implemented.
47 class DartApplicationLoader : public ThreadSafeRefCounted<DartApplicationLoader> {
48 public:
49 DartApplicationLoader(Document*);
50 void loadScriptResource(const String& url);
51 void load(const String& url, const String& source);
52 void triggerImport(const String& libraryUrl, const String& importedUrl, Dart _LibraryTag);
53 Dart_Handle reinject(Dart_Handle library, const String& libraryUrl, const St ring& importedUrl, Dart_LibraryTag);
54 void reinjectSources();
55 bool isLoadingMainIsolate() const { return m_libraryUrl.isNull(); }
56 const String& mainLibraryURL() const { return m_libraryUrl; }
57
58 private:
59
60 void importBuiltinLibrary(const String& url, const String& source);
61 void reinjectLibrary(const ScriptSourceCode&);
62 void scriptLoadError(const KURL&);
63
64 static Dart_Handle reinjectTagHandler(Dart_LibraryTag, Dart_Handle, Dart_Han dle);
65
66 // Client must ensure that DartApplicationLoader doesn't outlive correspondi ng document.
67 Document* m_document;
68 String m_libraryUrl;
69
70 void loadScript(const String& url, const String& source);
71 void loadLibrary(const String& url, const String& source);
72 void loadSource(const String& url, const String& source);
73 void callEntryPoint();
74
75 Dart_Handle topLevelLibrary();
76 Dart_Handle domLibrary();
77
78 typedef HashSet<String> UrlSet;
79 typedef HashMap<String, UrlSet*> UrlMultiMap;
80
81 void add(UrlMultiMap&, const String& key, const String& value);
82
83 UrlSet m_importedLibraries;
84 UrlMultiMap m_importersForSource;
85
86 // Sources of resources loaded from the URL.
87 // We save them verbatim to be able to reinject them later.
88 HashMap<String, String> m_sources;
89
90 bool m_mainScriptHasBeenLoaded;
91
92 friend class ScriptLoadCallback;
93 };
94
95 // FIXME: consolidate when we have multiple isolates.
96 // FIXME: merge with DartUtilities' per isolate data.
97 typedef HashMap<Dart_Isolate, DartApplicationLoader*> IsolateToDartApplicationLo aderMap;
98
99 IsolateToDartApplicationLoaderMap& isolateToDartApplicationLoaderMap();
100 }
101
102 #endif // DartApplicationLoader_h
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698