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

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

Issue 2838933003: [not-for-commit] kitsune changes + pending kouhei changes (Closed)
Patch Set: Created 3 years, 7 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
31 // We use PendingScript::Dispose() also as ClassicPendingScript's
32 // prefinalizer so that Dispose() is called before ResourceOwner's
33 // prefinalizer. https://crbug.com/711703
34 // If ResourceOwner's prefinalizer is called before Dispose(), it clears
35 // Resource(), leaving ClassicPendingScript in a half-broken state
36 // (e.g. Resource() is cleared but |streamer_| is not cleared).
37 USING_PRE_FINALIZER(ClassicPendingScript, Dispose);
38
39 public:
40 // For script from an external file.
41 static ClassicPendingScript* Create(ScriptElementBase*, ScriptResource*);
42 // For inline script.
43 static ClassicPendingScript* Create(ScriptElementBase*, const TextPosition&);
44
45 static ClassicPendingScript* CreateForTesting(ScriptResource*);
46
47 ~ClassicPendingScript() override;
48
49 void SetStreamer(ScriptStreamer*);
50 void StreamingFinished();
51
52 DECLARE_TRACE();
53
54 blink::ScriptType GetScriptType() const override {
55 return blink::ScriptType::kClassic;
56 }
57
58 ClassicScript* GetSource(const KURL& document_url,
59 bool& error_occurred) const override;
60 bool IsReady() const override;
61 bool IsExternal() const override { return GetResource(); }
62 bool ErrorOccurred() const override;
63 bool WasCanceled() const override;
64 void StartStreamingIfPossible(Document*, ScriptStreamer::Type) override;
65 KURL UrlForClassicScript() const override;
66 void RemoveFromMemoryCache() override;
67 void DisposeInternal() override;
68
69 // Supressing crashes on windows bots.
70 void Dispose();
71
72 private:
73 ClassicPendingScript(ScriptElementBase*,
74 ScriptResource*,
75 const TextPosition&,
76 bool is_for_testing = false);
77 ClassicPendingScript() = delete;
78
79 void CheckState() const override;
80
81 // ScriptResourceClient
82 void NotifyFinished(Resource*) override;
83 String DebugName() const override { return "PendingScript"; }
84 void NotifyAppendData(ScriptResource*) override;
85
86 // MemoryCoordinatorClient
87 void OnPurgeMemory() override;
88
89 bool integrity_failure_;
90
91 Member<ScriptStreamer> streamer_;
92
93 // This flag is used to skip non-null checks of |m_element| in unit
94 // tests, because |m_element| can be null in unit tests.
95 const bool is_for_testing_;
96 };
97
98 } // namespace blink
99
100 #endif // PendingScript_h
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698