#ifndef PendingScript_h
#define PendingScript_h
#include "core/fetch/ResourceClient.h"
#include "core/fetch/ResourceOwner.h"
#include "core/fetch/ScriptResource.h"
#include "wtf/PassRefPtr.h"
#include "wtf/RefPtr.h"
#include "wtf/text/TextPosition.h"
namespace WebCore {
class Element;
class ScriptResource;
class PendingScript : public ResourceOwner<ScriptResource> {
public:
PendingScript()
: m_watchingForLoad(false)
, m_startingPosition(TextPosition::belowRangePosition())
{
}
PendingScript(Element* element, ScriptResource* resource)
: m_watchingForLoad(false)
, m_element(element)
{
setScriptResource(resource);
}
PendingScript(const PendingScript& other)
: ResourceOwner(other)
, m_watchingForLoad(other.m_watchingForLoad)
, m_element(other.m_element)
, m_startingPosition(other.m_startingPosition)
{
setScriptResource(other.resource());
}
~PendingScript();
PendingScript& operator=(const PendingScript& other)
{
if (this == &other)
return *this;
m_watchingForLoad = other.m_watchingForLoad;
m_element = other.m_element;
m_startingPosition = other.m_startingPosition;
this->ResourceOwner<ScriptResource, ResourceClient>::operator=(other);
return *this;
}
TextPosition startingPosition() const { return m_startingPosition; }
void setStartingPosition(const TextPosition& position) { m_startingPosition = position; }
bool watchingForLoad() const { return m_watchingForLoad; }
void setWatchingForLoad(bool b) { m_watchingForLoad = b; }
Element* element() const { return m_element.get(); }
void setElement(Element* element) { m_element = element; }
PassRefPtr<Element> releaseElementAndClear();
void setScriptResource(ScriptResource*);
virtual void notifyFinished(Resource*);
private:
bool m_watchingForLoad;
RefPtr<Element> m_element;
TextPosition m_startingPosition;
};
}
#endif