2 * Copyright (C) 2007, 2009 Apple Inc. All rights reserved.
4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions
8 * 1. Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer.
10 * 2. Redistributions in binary form must reproduce the above copyright
11 * notice, this list of conditions and the following disclaimer in the
12 * documentation and/or other materials provided with the distribution.
13 * 3. Neither the name of Apple Computer, Inc. ("Apple") nor the names of
14 * its contributors may be used to endorse or promote products derived
15 * from this software without specific prior written permission.
17 * THIS SOFTWARE IS PROVIDED BY APPLE AND ITS CONTRIBUTORS "AS IS" AND ANY
18 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
19 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
20 * DISCLAIMED. IN NO EVENT SHALL APPLE OR ITS CONTRIBUTORS BE LIABLE FOR ANY
21 * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
22 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
23 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
24 * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
25 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
26 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
29 #ifndef WorkQueueItem_h
30 #define WorkQueueItem_h
32 #include <JavaScriptCore/JSRetainPtr.h>
33 #include <JavaScriptCore/JSBase.h>
37 virtual ~WorkQueueItem() { }
38 virtual bool invoke() const = 0; // Returns true if this started a load.
41 class LoadItem : public WorkQueueItem {
43 LoadItem(const JSStringRef url, const JSStringRef target)
50 virtual bool invoke() const;
52 JSRetainPtr<JSStringRef> m_url;
53 JSRetainPtr<JSStringRef> m_target;
56 class LoadHTMLStringItem : public WorkQueueItem {
58 LoadHTMLStringItem(const JSStringRef content, const JSStringRef baseURL)
64 LoadHTMLStringItem(const JSStringRef content, const JSStringRef baseURL, const JSStringRef unreachableURL)
67 , m_unreachableURL(unreachableURL)
72 virtual bool invoke() const;
74 JSRetainPtr<JSStringRef> m_content;
75 JSRetainPtr<JSStringRef> m_baseURL;
76 JSRetainPtr<JSStringRef> m_unreachableURL;
79 class ReloadItem : public WorkQueueItem {
81 virtual bool invoke() const;
84 class ScriptItem : public WorkQueueItem {
86 ScriptItem(const JSStringRef script)
92 virtual bool invoke() const;
95 JSRetainPtr<JSStringRef> m_script;
98 class LoadingScriptItem : public ScriptItem {
100 LoadingScriptItem(const JSStringRef script)
106 virtual bool invoke() const { return ScriptItem::invoke(); }
109 class NonLoadingScriptItem : public ScriptItem {
111 NonLoadingScriptItem(const JSStringRef script)
117 virtual bool invoke() const { ScriptItem::invoke(); return false; }
120 class BackForwardItem : public WorkQueueItem {
122 BackForwardItem(int howFar)
128 virtual bool invoke() const;
133 class BackItem : public BackForwardItem {
135 BackItem(unsigned howFar)
136 : BackForwardItem(-howFar)
141 class ForwardItem : public BackForwardItem {
143 ForwardItem(unsigned howFar)
144 : BackForwardItem(howFar)
149 #endif // !defined(WorkQueueItem_h)