sbMediacoreFactoryWrapper.cpp
Go to the documentation of this file.
1 /*
2  *=BEGIN SONGBIRD GPL
3  *
4  * This file is part of the Songbird web player.
5  *
6  * Copyright(c) 2005-2010 POTI, Inc.
7  * http://www.songbirdnest.com
8  *
9  * This file may be licensed under the terms of of the
10  * GNU General Public License Version 2 (the ``GPL'').
11  *
12  * Software distributed under the License is distributed
13  * on an ``AS IS'' basis, WITHOUT WARRANTY OF ANY KIND, either
14  * express or implied. See the GPL for the specific language
15  * governing rights and limitations.
16  *
17  * You should have received a copy of the GPL along with this
18  * program. If not, go to http://www.gnu.org/licenses/gpl.html
19  * or write to the Free Software Foundation, Inc.,
20  * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
21  *
22  *=END SONGBIRD GPL
23  */
24 
30 
31 #include <nsThreadUtils.h>
33 
38 #ifdef PR_LOGGING
39 static PRLogModuleInfo* gMediacoreFactoryWrapper = nsnull;
40 #define TRACE(args) PR_LOG(gMediacoreFactoryWrapper, PR_LOG_DEBUG, args)
41 #define LOG(args) PR_LOG(gMediacoreFactoryWrapper, PR_LOG_WARN, args)
42 #else
43 #define TRACE(args) /* nothing */
44 #define LOG(args) /* nothing */
45 #endif
46 
51 
53 {
54 #ifdef PR_LOGGING
55  if (!gMediacoreFactoryWrapper)
56  gMediacoreFactoryWrapper = PR_NewLogModule("sbMediacoreFactoryWrapper");
57 #endif
58 
59  TRACE(("sbMediacoreFactoryWrapper[0x%x] - Created", this));
60 }
61 
63 {
64  TRACE(("sbMediacoreFactoryWrapper[0x%x] - Destroyed", this));
65 }
66 
67 nsresult
69 {
71  NS_ENSURE_SUCCESS(rv, rv);
72 
73  return NS_OK;
74 }
75 
76 //
77 // sbIMediacoreFactoryWrapper
78 //
79 
80 NS_IMETHODIMP
81 sbMediacoreFactoryWrapper::Initialize(const nsAString &aFactoryName,
82  const nsAString &aContractID,
83  sbIMediacoreCapabilities *aCapabilities,
85 {
86  NS_ENSURE_FALSE(aFactoryName.IsEmpty(), NS_ERROR_INVALID_ARG);
87  NS_ENSURE_FALSE(aContractID.IsEmpty(), NS_ERROR_INVALID_ARG);
88  NS_ENSURE_ARG_POINTER(aCapabilities);
89  NS_ENSURE_ARG_POINTER(aListener);
90 
91  SetName(aFactoryName);
92  SetContractID(aContractID);
93 
94  mCapabilities = aCapabilities;
95 
96  nsCOMPtr<nsIThread> target;
97  nsresult rv = NS_GetMainThread(getter_AddRefs(target));
98  NS_ENSURE_SUCCESS(rv, rv);
99 
100  rv = do_GetProxyForObject(target,
102  aListener,
103  NS_PROXY_SYNC | NS_PROXY_ALWAYS,
104  getter_AddRefs(mListener));
105  NS_ENSURE_SUCCESS(rv, rv);
106 
107  return NS_OK;
108 }
109 
110 //
111 // sbIMediacoreFactory
112 //
113 
114 /*virtual*/ nsresult
116 {
117  return NS_OK;
118 }
119 
120 /*virtual*/ nsresult
122  sbIMediacoreCapabilities **aCapabilities)
123 {
124  NS_ENSURE_STATE(mCapabilities);
125  NS_ADDREF(*aCapabilities = mCapabilities);
126  return NS_OK;
127 }
128 
129 /*virtual*/ nsresult
130 sbMediacoreFactoryWrapper::OnCreate(const nsAString &aInstanceName,
131  sbIMediacore **_retval)
132 {
133  NS_ENSURE_STATE(mListener);
134  nsresult rv = mListener->OnCreate(aInstanceName, _retval);
135  NS_ENSURE_SUCCESS(rv, rv);
136  return NS_OK;
137 }
return NS_OK
nsresult SetContractID(const nsAString &aContractID)
Songbird Mediacore Factory Wrapper Definition.
nsCOMPtr< sbIMediacoreCapabilities > mCapabilities
virtual nsresult OnGetCapabilities(sbIMediacoreCapabilities **aCapabilities)
nsresult SetName(const nsAString &aName)
nsresult do_GetProxyForObject(nsIEventTarget *aTarget, REFNSIID aIID, nsISupports *aObj, PRInt32 aProxyType, void **aProxyObject)
Factory Wrapper Interface for use by JavaScript implementations of Mediacores.
virtual nsresult OnCreate(const nsAString &aInstanceName, sbIMediacore **_retval)
Factory Wrapper Listener Interface for use by JavaScript implementations of Mediacores.
#define TRACE(args)
NS_IMPL_ISUPPORTS_INHERITED2(sbMediacoreFactoryWrapper, sbBaseMediacoreFactory, sbIMediacoreFactoryWrapper, sbIMediacoreFactory)
nsCOMPtr< sbIMediacoreFactoryWrapperListener > mListener
NS_DECL_ISUPPORTS_INHERITED NS_DECL_SBIMEDIACOREFACTORYWRAPPER sbMediacoreFactoryWrapper()