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

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

Issue 2549143009: Create PendingScriptClient as a separate client interface for PendingScript. (Closed)
Patch Set: . Created 4 years 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
1 /* 1 /*
2 * Copyright (C) 2010 Google, Inc. All Rights Reserved. 2 * Copyright (C) 2010 Google, Inc. 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 5 * modification, are permitted provided that the following conditions
6 * are met: 6 * are met:
7 * 1. Redistributions of source code must retain the above copyright 7 * 1. Redistributions of source code must retain the above copyright
8 * notice, this list of conditions and the following disclaimer. 8 * notice, this list of conditions and the following disclaimer.
9 * 2. Redistributions in binary form must reproduce the above copyright 9 * 2. Redistributions in binary form must reproduce the above copyright
10 * notice, this list of conditions and the following disclaimer in the 10 * notice, this list of conditions and the following disclaimer in the
(...skipping 20 matching lines...) Expand all
31 #include "core/fetch/ResourceOwner.h" 31 #include "core/fetch/ResourceOwner.h"
32 #include "core/loader/resource/ScriptResource.h" 32 #include "core/loader/resource/ScriptResource.h"
33 #include "platform/MemoryCoordinator.h" 33 #include "platform/MemoryCoordinator.h"
34 #include "platform/heap/Handle.h" 34 #include "platform/heap/Handle.h"
35 #include "wtf/Noncopyable.h" 35 #include "wtf/Noncopyable.h"
36 #include "wtf/text/TextPosition.h" 36 #include "wtf/text/TextPosition.h"
37 37
38 namespace blink { 38 namespace blink {
39 39
40 class Element; 40 class Element;
41 class PendingScript;
41 class ScriptSourceCode; 42 class ScriptSourceCode;
42 43
44 class CORE_EXPORT PendingScriptClient : public GarbageCollectedMixin {
45 public:
46 virtual ~PendingScriptClient() {}
47
48 // Invoked when the pending script has finished loading. This could be during
49 // |watchForLoad| (if the pending script was already ready), or when the
50 // resource loads (if script streaming is not occurring), or when script
51 // streaming finishes.
52 virtual void pendingScriptFinished(PendingScript*) = 0;
53
54 DEFINE_INLINE_VIRTUAL_TRACE() {}
55 };
56
43 // A container for an external script which may be loaded and executed. 57 // A container for an external script which may be loaded and executed.
44 // 58 //
45 // TODO(kochi): The comment below is from pre-oilpan age and may not be correct 59 // TODO(kochi): The comment below is from pre-oilpan age and may not be correct
46 // now. 60 // now.
47 // A RefPtr alone does not prevent the underlying Resource from purging its data 61 // A RefPtr alone does not prevent the underlying Resource from purging its data
48 // buffer. This class holds a dummy client open for its lifetime in order to 62 // buffer. This class holds a dummy client open for its lifetime in order to
49 // guarantee that the data buffer will not be purged. 63 // guarantee that the data buffer will not be purged.
50 class CORE_EXPORT PendingScript final 64 class CORE_EXPORT PendingScript final
51 : public GarbageCollectedFinalized<PendingScript>, 65 : public GarbageCollectedFinalized<PendingScript>,
52 public ResourceOwner<ScriptResource>, 66 public ResourceOwner<ScriptResource>,
(...skipping 11 matching lines...) Expand all
64 m_startingPosition = position; 78 m_startingPosition = position;
65 } 79 }
66 void markParserBlockingLoadStartTime(); 80 void markParserBlockingLoadStartTime();
67 // Returns the time the load of this script started blocking the parser, or 81 // Returns the time the load of this script started blocking the parser, or
68 // zero if this script hasn't yet blocked the parser, in 82 // zero if this script hasn't yet blocked the parser, in
69 // monotonicallyIncreasingTime. 83 // monotonicallyIncreasingTime.
70 double parserBlockingLoadStartTime() const { 84 double parserBlockingLoadStartTime() const {
71 return m_parserBlockingLoadStartTime; 85 return m_parserBlockingLoadStartTime;
72 } 86 }
73 87
74 void watchForLoad(ScriptResourceClient*); 88 void watchForLoad(PendingScriptClient*);
75 void stopWatchingForLoad(); 89 void stopWatchingForLoad();
76 90
77 Element* element() const { return m_element.get(); } 91 Element* element() const { return m_element.get(); }
78 void setElement(Element*); 92 void setElement(Element*);
79 93
80 void setScriptResource(ScriptResource*); 94 void setScriptResource(ScriptResource*);
81 95
82 void notifyFinished(Resource*) override;
83 String debugName() const override { return "PendingScript"; }
84 void notifyAppendData(ScriptResource*) override;
85
86 DECLARE_TRACE(); 96 DECLARE_TRACE();
87 97
88 ScriptSourceCode getSource(const KURL& documentURL, 98 ScriptSourceCode getSource(const KURL& documentURL,
89 bool& errorOccurred) const; 99 bool& errorOccurred) const;
90 100
91 void setStreamer(ScriptStreamer*); 101 void setStreamer(ScriptStreamer*);
92 void streamingFinished(); 102 void streamingFinished();
93 103
94 bool isReady() const; 104 bool isReady() const;
95 bool errorOccurred() const; 105 bool errorOccurred() const;
96 106
97 void dispose(); 107 void dispose();
98 108
99 private: 109 private:
100 PendingScript(Element*, ScriptResource*); 110 PendingScript(Element*, ScriptResource*);
101 PendingScript() = delete; 111 PendingScript() = delete;
102 112
113 // ScriptResourceClient
114 void notifyFinished(Resource*) override;
115 String debugName() const override { return "PendingScript"; }
116 void notifyAppendData(ScriptResource*) override;
117
118 // MemoryCoordinatorClient
103 void onMemoryStateChange(MemoryState) override; 119 void onMemoryStateChange(MemoryState) override;
104 120
105 bool m_watchingForLoad; 121 bool m_watchingForLoad;
106 Member<Element> m_element; 122 Member<Element> m_element;
107 TextPosition m_startingPosition; // Only used for inline script tags. 123 TextPosition m_startingPosition; // Only used for inline script tags.
108 bool m_integrityFailure; 124 bool m_integrityFailure;
109 double m_parserBlockingLoadStartTime; 125 double m_parserBlockingLoadStartTime;
110 126
111 Member<ScriptStreamer> m_streamer; 127 Member<ScriptStreamer> m_streamer;
112 Member<ScriptResourceClient> m_client; 128 Member<PendingScriptClient> m_client;
113 }; 129 };
114 130
115 } // namespace blink 131 } // namespace blink
116 132
117 #endif // PendingScript_h 133 #endif // PendingScript_h
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698