sbRequestItem.h
Go to the documentation of this file.
1 /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
2 /* vim: set sw=2 :miv */
3 /*
4  *=BEGIN SONGBIRD GPL
5  *
6  * This file is part of the Songbird web player.
7  *
8  * Copyright(c) 2005-2011 POTI, Inc.
9  * http://www.songbirdnest.com
10  *
11  * This file may be licensed under the terms of of the
12  * GNU General Public License Version 2 (the ``GPL'').
13  *
14  * Software distributed under the License is distributed
15  * on an ``AS IS'' basis, WITHOUT WARRANTY OF ANY KIND, either
16  * express or implied. See the GPL for the specific language
17  * governing rights and limitations.
18  *
19  * You should have received a copy of the GPL along with this
20  * program. If not, go to http://www.gnu.org/licenses/gpl.html
21  * or write to the Free Software Foundation, Inc.,
22  * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
23  *
24  *=END SONGBIRD GPL
25  */
26 
27 #ifndef SBREQUESTITEM_H_
28 #define SBREQUESTITEM_H_
29 
30 // Mozilla includes
31 #include <nsCOMPtr.h>
32 
33 // Mozilla interfaces
34 #include <nsIClassInfo.h>
35 
45 {
46 public:
47 
48  friend class sbRequestThreadQueue;
49 
50  NS_IMETHOD_(nsrefcnt) AddRef(void);
51  NS_IMETHOD_(nsrefcnt) Release(void);
52 
56  PRUint32 GetRequestId() const
57  {
58  return mRequestId;
59  }
60 
65  PRUint32 GetType() const
66  {
67  return mType;
68  }
69 
73  void SetType(PRUint32 aType)
74  {
75  mType = aType;
76  }
77 
81  PRUint32 GetBatchId() const
82  {
83  return mBatchId;
84  }
85 
90  PRUint32 GetBatchIndex() const
91  {
92  return mBatchIndex;
93  }
94 
98  void SetBatchIndex(PRInt32 aBatchIndex)
99  {
100  mBatchIndex = aBatchIndex;
101  }
102 
103 
107  PRInt64 GetTimeStamp() const
108  {
109  return mTimeStamp;
110  }
111 
115  bool GetIsCountable() const
116  {
117  return mIsCountable;
118  }
119 
124  bool GetIsProcessed() const
125  {
126  return mIsProcessed;
127  }
128 
132  void SetIsProcessed(bool aIsProcessed)
133  {
134  mIsProcessed = aIsProcessed;
135  }
136 
137  static sbRequestItem * New(PRUint32 aType, bool aIsCountable = false)
138  {
139  sbRequestItem * requestItem;
140  NS_NEWXPCOM(requestItem, sbRequestItem);
141  if (requestItem) {
142  requestItem->SetType(aType);
143  requestItem->SetIsCountable(aIsCountable);
144  }
145  return requestItem;
146  }
147 
148 protected:
152  sbRequestItem();
153 
154  virtual ~sbRequestItem();
155  // Protected interface to be used by the request queue and derived classes
156 
160  void SetIsCountable(bool aIsCountable)
161  {
162  mIsCountable = aIsCountable;
163  }
164 
165 private:
166 
170  PRUint32 mRequestId;
171 
176  PRUint32 mType;
177 
181  PRUint32 mBatchId;
182 
187  PRUint32 mBatchIndex;
188 
192  PRInt64 mTimeStamp;
193 
197  bool mIsCountable;
198 
202  bool mIsProcessed;
203 
207  nsAutoRefCnt mRefCnt;
211  static PRInt32 sLastRequestId;
212 };
213 
214 #endif
virtual ~sbRequestItem()
bool GetIsProcessed() const
PRUint32 GetType() const
Definition: sbRequestItem.h:65
void SetIsProcessed(bool aIsProcessed)
static sbRequestItem * New(PRUint32 aType, bool aIsCountable=false)
void SetIsCountable(bool aIsCountable)
PRUint32 GetBatchIndex() const
Definition: sbRequestItem.h:90
PRUint32 GetRequestId() const
Definition: sbRequestItem.h:56
NS_IMETHOD_(nsrefcnt) AddRef(void)
bool GetIsCountable() const
PRInt64 GetTimeStamp() const
PRUint32 GetBatchId() const
Definition: sbRequestItem.h:81
void SetType(PRUint32 aType)
Definition: sbRequestItem.h:73
void SetBatchIndex(PRInt32 aBatchIndex)
Definition: sbRequestItem.h:98