OLD | NEW |
---|---|
(Empty) | |
1 /* | |
2 * Copyright (C) 2014 Google Inc. All rights reserved. | |
haraken
2014/08/17 16:05:27
Nit: Use the 3-line copyright.
// Copyright 2014
marja
2014/08/20 11:45:55
Done.
| |
3 * | |
4 * Redistribution and use in source and binary forms, with or without | |
5 * modification, are permitted provided that the following conditions | |
6 * are met: | |
7 * 1. Redistributions of source code must retain the above copyright | |
8 * notice, this list of conditions and the following disclaimer. | |
9 * 2. Redistributions in binary form must reproduce the above copyright | |
10 * notice, this list of conditions and the following disclaimer in the | |
11 * documentation and/or other materials provided with the distribution. | |
12 * | |
13 * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS'' | |
14 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, | |
15 * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR | |
16 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS | |
17 * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR | |
18 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF | |
19 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS | |
20 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN | |
21 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) | |
22 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF | |
23 * THE POSSIBILITY OF SUCH DAMAGE. | |
24 */ | |
25 | |
26 #ifndef V8ScriptStreamer_h | |
27 #define V8ScriptStreamer_h | |
28 | |
29 #include "wtf/RefCounted.h" | |
30 | |
31 #include <v8.h> | |
32 | |
33 namespace blink { | |
34 | |
35 class HTMLScriptRunner; | |
36 class PendingScript; | |
37 class ScriptResource; | |
38 class SourceStream; | |
39 | |
40 // V8ScriptStreamer streams incomplete script data to V8 so that it can be | |
41 // parsed while it's loaded. PendingScript holds a reference to | |
42 // V8ScriptStreamer. At the moment, V8ScriptStreamer is only used for parser | |
43 // blocking scripts; this means that the Document stays stable and no other | |
44 // scripts are executing while we're streaming. It is possible, though, that | |
45 // Document and the PendingScript are destroyed while the streaming is in | |
46 // progress, and V8ScriptStreamer handles it gracefully. | |
47 class V8ScriptStreamer : public RefCounted<V8ScriptStreamer> { | |
haraken
2014/08/17 16:05:27
(We might want to move V8ScriptStreamer to oilpan'
haraken
2014/08/17 16:05:27
V8ScriptStreamer => ScriptStreamer
We're planning
marja
2014/08/20 11:45:55
Acknowledged.
marja
2014/08/20 11:45:56
Done.
| |
48 public: | |
49 static bool startStreaming(PendingScript*, HTMLScriptRunner*); | |
haraken
2014/08/17 16:05:27
Add a comment about what startStreaming() does.
marja
2014/08/20 11:45:55
Done.
| |
50 | |
51 bool streamingInProgress() const { return !m_loadingDone || !m_v8Done; } | |
52 | |
53 v8::ScriptCompiler::StreamedSource* source() { return &m_source; } | |
54 | |
55 // Called when data arrives from the network. | |
56 void notifyAppendData(); | |
57 void notifyFinished(); | |
58 | |
59 // Called when we have streamed all data to V8 and it has processed it. | |
60 void streamingComplete(); | |
61 | |
62 // Cancel is called if the PendingScript is deleted and we don't need to | |
63 // stream the script any more. After calling cancel, PendingScript will drop | |
64 // its reference, and V8ScriptStreamer takes care of deleting itself. | |
65 void cancel(); | |
66 | |
67 unsigned cachedDataDataType() const { return m_cachedDataDataType; } | |
68 | |
69 private: | |
70 V8ScriptStreamer(PendingScript*, HTMLScriptRunner*); | |
haraken
2014/08/17 16:05:27
Why do both V8ScriptStreamer's constructor and sta
marja
2014/08/20 11:45:55
startStreaming is a static function which construc
| |
71 | |
72 // This pointer is weak, and the PendingScript can be deleted before | |
73 // V8ScriptStreamer. However, it'll notify V8ScriptStreamer of its deletion | |
74 // by calling cancel(). | |
75 PendingScript* m_script; | |
76 HTMLScriptRunner* m_runner; | |
77 SourceStream* m_stream; | |
78 v8::ScriptCompiler::StreamedSource m_source; | |
79 bool m_loadingDone; // Whether loading from the network is done. | |
80 bool m_v8Done; // Whether the V8 side processing is done. | |
81 unsigned m_cachedDataDataType; | |
82 }; | |
83 | |
84 } // namespace blink | |
85 | |
86 #endif // V8ScriptStreamer_h | |
OLD | NEW |