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

Side by Side Diff: third_party/WebKit/Source/core/dom/ClassicPendingScript.h

Issue 2653923008: Reland of Split PendingScript into PendingScript and ClassicPendingScript (Closed)
Patch Set: Crash fix by adding Dispose() as ClassicPendingScript prefinalizer Created 3 years, 8 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 2017 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4
5 #ifndef ClassicPendingScript_h
6 #define ClassicPendingScript_h
7
8 #include "bindings/core/v8/ScriptStreamer.h"
9 #include "core/dom/ClassicScript.h"
10 #include "core/dom/PendingScript.h"
11 #include "core/loader/resource/ScriptResource.h"
12 #include "platform/MemoryCoordinator.h"
13 #include "platform/loader/fetch/ResourceOwner.h"
14
15 namespace blink {
16
17 // PendingScript for a classic script
18 // https://html.spec.whatwg.org/#classic-script.
19 //
20 // TODO(kochi): The comment below is from pre-oilpan age and may not be correct
21 // now.
22 // A RefPtr alone does not prevent the underlying Resource from purging its data
23 // buffer. This class holds a dummy client open for its lifetime in order to
24 // guarantee that the data buffer will not be purged.
25 class CORE_EXPORT ClassicPendingScript final
26 : public PendingScript,
27 public ResourceOwner<ScriptResource>,
28 public MemoryCoordinatorClient {
29 USING_GARBAGE_COLLECTED_MIXIN(ClassicPendingScript);
30 USING_PRE_FINALIZER(ClassicPendingScript, Dispose);
hiroshige 2017/04/19 01:01:40 I also register Dispose() as ClassicPendingScript.
31
32 public:
33 // For script from an external file.
34 static ClassicPendingScript* Create(ScriptElementBase*, ScriptResource*);
35 // For inline script.
36 static ClassicPendingScript* Create(ScriptElementBase*, const TextPosition&);
37
38 static ClassicPendingScript* CreateForTesting(ScriptResource*);
39
40 ~ClassicPendingScript() override;
41
42 void SetStreamer(ScriptStreamer*);
43 void StreamingFinished();
44
45 DECLARE_TRACE();
46
47 blink::ScriptType GetScriptType() const override {
48 return blink::ScriptType::kClassic;
49 }
50
51 ClassicScript* GetSource(const KURL& document_url,
52 bool& error_occurred) const override;
53 bool IsReady() const override;
54 KURL Url() const override;
55 bool IsExternal() const override { return GetResource(); }
56 bool ErrorOccurred() const override;
57 bool WasCanceled() const override;
58 void StartStreamingIfPossible(Document*, ScriptStreamer::Type) override;
59 void RemoveFromMemoryCache() override;
60 void DisposeInternal() override;
61
62 private:
63 ClassicPendingScript(ScriptElementBase*,
64 ScriptResource*,
65 const TextPosition&,
66 bool is_for_testing = false);
67 ClassicPendingScript() = delete;
68
69 void CheckState() const override;
70
71 // ScriptResourceClient
72 void NotifyFinished(Resource*) override;
73 String DebugName() const override { return "PendingScript"; }
74 void NotifyAppendData(ScriptResource*) override;
75
76 // MemoryCoordinatorClient
77 void OnPurgeMemory() override;
78
79 bool integrity_failure_;
80
81 Member<ScriptStreamer> streamer_;
82
83 // This flag is used to skip non-null checks of |m_element| in unit
84 // tests, because |m_element| can be null in unit tests.
85 const bool is_for_testing_;
86 };
87
88 } // namespace blink
89
90 #endif // PendingScript_h
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698