sbMediacoreError.cpp
Go to the documentation of this file.
1 /*
2 //
3 // BEGIN SONGBIRD GPL
4 //
5 // This file is part of the Songbird web player.
6 //
7 // Copyright(c) 2005-2008 POTI, Inc.
8 // http://songbirdnest.com
9 //
10 // This file may be licensed under the terms of of the
11 // GNU General Public License Version 2 (the "GPL").
12 //
13 // Software distributed under the License is distributed
14 // on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, either
15 // express or implied. See the GPL for the specific language
16 // governing rights and limitations.
17 //
18 // You should have received a copy of the GPL along with this
19 // program. If not, go to http://www.gnu.org/licenses/gpl.html
20 // or write to the Free Software Foundation, Inc.,
21 // 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
22 //
23 // END SONGBIRD GPL
24 //
25 */
26 
31 #include "sbMediacoreError.h"
32 
37 #ifdef PR_LOGGING
38 static PRLogModuleInfo* gMediacoreError = nsnull;
39 #define TRACE(args) PR_LOG(gMediacoreError, PR_LOG_DEBUG, args)
40 #define LOG(args) PR_LOG(gMediacoreError, PR_LOG_WARN, args)
41 #else
42 #define TRACE(args) /* nothing */
43 #define LOG(args) /* nothing */
44 #endif
45 
48 
50 : mLock(nsnull)
51 , mCode(sbIMediacoreError::UNINITIALIZED)
52 {
53  MOZ_COUNT_CTOR(sbMediacoreError);
54 
55 #ifdef PR_LOGGING
56  if (!gMediacoreError)
57  gMediacoreError= PR_NewLogModule("sbMediacoreError");
58 #endif
59 
60  TRACE(("sbMediacoreError[0x%x] - Created", this));
61 }
62 
64 {
65  TRACE(("sbMediacoreError[0x%x] - Destroyed", this));
66  MOZ_COUNT_DTOR(sbMediacoreError);
67 
68  if(mLock) {
69  nsAutoLock::DestroyLock(mLock);
70  }
71 }
72 
73 nsresult
74 sbMediacoreError::Init(PRUint32 aCode,
75  const nsAString &aMessage)
76 {
77  TRACE(("sbMediacoreError[0x%x] - Init", this));
78 
79  mLock = nsAutoLock::NewLock("sbMediacoreError::mLock");
80  NS_ENSURE_TRUE(mLock, NS_ERROR_OUT_OF_MEMORY);
81 
82  mCode = aCode;
83  mMessage = aMessage;
84 
85  return NS_OK;
86 }
87 
88 NS_IMETHODIMP
89 sbMediacoreError::GetCode(PRUint32 *aCode)
90 {
91  TRACE(("sbMediacoreError[0x%x] - GetCode", this));
92 
93  NS_ENSURE_TRUE(mLock, NS_ERROR_NOT_INITIALIZED);
94  NS_ENSURE_ARG_POINTER(aCode);
95 
96  nsAutoLock lock(mLock);
97  *aCode = mCode;
98 
99  return NS_OK;
100 }
101 
102 NS_IMETHODIMP
103 sbMediacoreError::GetMessage(nsAString & aMessage)
104 {
105  TRACE(("sbMediacoreError[0x%x] - GetMessage", this));
106 
107  NS_ENSURE_TRUE(mLock, NS_ERROR_NOT_INITIALIZED);
108 
109  nsAutoLock lock(mLock);
110  aMessage = mMessage;
111 
112  return NS_OK;
113 }
nsresult Init(PRUint32 aCode, const nsAString &aMessage)
Songbird Mediacore Error Definition.
return NS_OK
NS_IMPL_THREADSAFE_ISUPPORTS1(sbMediacoreError, sbIMediacoreError) sbMediacoreError
#define TRACE(args)
virtual ~sbMediacoreError()