webengine/osswebengine/WebKitTools/DumpRenderTree/WorkQueueItem.h
changeset 0 dd21522fd290
equal deleted inserted replaced
-1:000000000000 0:dd21522fd290
       
     1 /*
       
     2  * Copyright (C) 2007 Apple Inc.  All rights reserved.
       
     3  *
       
     4  * Redistribution and use in source and binary forms, with or without
       
     5  * modification, are permitted provided that the following conditions
       
     6  * are met:
       
     7  *
       
     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. 
       
    16  *
       
    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.
       
    27  */
       
    28 
       
    29 #ifndef WorkQueueItem_h
       
    30 #define WorkQueueItem_h
       
    31 
       
    32 #include <JavaScriptCore/JSRetainPtr.h>
       
    33 #include <JavaScriptCore/JSBase.h>
       
    34 
       
    35 class WorkQueueItem {
       
    36 public:
       
    37     virtual ~WorkQueueItem() { }
       
    38     virtual void invoke() const = 0;
       
    39 };
       
    40 
       
    41 class LoadItem : public WorkQueueItem {
       
    42 public:
       
    43     LoadItem(const JSStringRef url, const JSStringRef target)
       
    44         : m_url(url)
       
    45         , m_target(target)
       
    46     {
       
    47     }
       
    48 
       
    49     const JSStringRef url() const { return m_url.get(); }
       
    50     const JSStringRef target() const { return m_target.get(); }
       
    51 
       
    52     virtual void invoke() const;
       
    53 
       
    54 private:
       
    55     JSRetainPtr<JSStringRef> m_url;
       
    56     JSRetainPtr<JSStringRef> m_target;
       
    57 };
       
    58 
       
    59 class ReloadItem : public WorkQueueItem {
       
    60 public:
       
    61     virtual void invoke() const;
       
    62 };
       
    63 
       
    64 class ScriptItem : public WorkQueueItem {
       
    65 public:
       
    66     ScriptItem(const JSStringRef script)
       
    67         : m_script(script)
       
    68     {
       
    69     }
       
    70 
       
    71     const JSStringRef script() const { return m_script.get(); }
       
    72 
       
    73     virtual void invoke() const;
       
    74 
       
    75 private:
       
    76     JSRetainPtr<JSStringRef> m_script;
       
    77 };
       
    78 
       
    79 class BackForwardItem : public WorkQueueItem {
       
    80 public:
       
    81     virtual void invoke() const;
       
    82 
       
    83 protected:
       
    84     BackForwardItem(int howFar)
       
    85         : m_howFar(howFar)
       
    86     {
       
    87     }
       
    88 
       
    89     int m_howFar;
       
    90 };
       
    91 
       
    92 class BackItem : public BackForwardItem {
       
    93 public:
       
    94     BackItem(unsigned howFar)
       
    95         : BackForwardItem(-howFar)
       
    96     {
       
    97     }
       
    98 };
       
    99 
       
   100 class ForwardItem : public BackForwardItem {
       
   101 public:
       
   102     ForwardItem(unsigned howFar)
       
   103         : BackForwardItem(howFar)
       
   104     {
       
   105     }
       
   106 };
       
   107 
       
   108 #endif // !defined(WorkQueueItem_h)