sbHTTPMediaItemDownloadJob.cpp
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-2010 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 //------------------------------------------------------------------------------
28 //------------------------------------------------------------------------------
29 //
30 // HTTP media item download job.
31 //
32 //------------------------------------------------------------------------------
33 //------------------------------------------------------------------------------
34 
40 //------------------------------------------------------------------------------
41 //
42 // HTTP media item download job imported services.
43 //
44 //------------------------------------------------------------------------------
45 
46 // Self imports.
48 
49 // Mozilla imports.
50 #include <nsAutoPtr.h>
51 
52 
53 //------------------------------------------------------------------------------
54 //
55 // HTTP media item download job logging services.
56 //
57 //------------------------------------------------------------------------------
58 
66 #include "prlog.h"
67 #ifdef PR_LOGGING
68 static PRLogModuleInfo* gHTTPMediaItemDownloadJobLog = nsnull;
69 #define TRACE(args) PR_LOG(gHTTPMediaItemDownloadJobLog, PR_LOG_DEBUG, args)
70 #define LOG(args) PR_LOG(gHTTPMediaItemDownloadJobLog, PR_LOG_WARN, args)
71 #ifdef __GNUC__
72 #define __FUNCTION__ __PRETTY_FUNCTION__
73 #endif /* __GNUC__ */
74 #else
75 #define TRACE(args) /* nothing */
76 #define LOG(args) /* nothing */
77 #endif /* PR_LOGGING */
78 
79 
80 //------------------------------------------------------------------------------
81 //
82 // HTTP media item download job nsISupports implementation.
83 //
84 //------------------------------------------------------------------------------
85 
88 
89 
90 //------------------------------------------------------------------------------
91 //
92 // HTTP media item download job public services.
93 //
94 //------------------------------------------------------------------------------
95 
96 //-------------------------------------
97 //
98 // New
99 //
100 
101 /* static */ nsresult
103  sbIMediaItem* aMediaItem,
104  sbILibrary* aTargetLibrary)
105 {
106  // Validate arguments.
107  NS_ENSURE_ARG_POINTER(aJob);
108  NS_ENSURE_ARG_POINTER(aMediaItem);
109 
110  // Function variables.
111  nsresult rv;
112 
113  // Create and initialize a new HTTP media item download job.
114  nsRefPtr<sbHTTPMediaItemDownloadJob>
115  job = new sbHTTPMediaItemDownloadJob(aMediaItem, aTargetLibrary);
116  NS_ENSURE_TRUE(job, NS_ERROR_OUT_OF_MEMORY);
117  rv = job->Initialize();
118  NS_ENSURE_SUCCESS(rv, rv);
119 
120  // Return results.
121  job.forget(aJob);
122 
123  return NS_OK;
124 }
125 
126 
127 //-------------------------------------
128 //
129 // ~sbHTTPMediaItemDownloadJob
130 //
131 
133 {
134  TRACE(("%s[%.8x]", __FUNCTION__, this));
135 }
136 
137 
138 //------------------------------------------------------------------------------
139 //
140 // HTTP media item download job private services.
141 //
142 //------------------------------------------------------------------------------
143 
144 //-------------------------------------
145 //
146 // sbHTTPMediaItemDownloadJob
147 //
148 
149 sbHTTPMediaItemDownloadJob::sbHTTPMediaItemDownloadJob
150  (sbIMediaItem* aMediaItem,
151  sbILibrary* aTargetLibrary) :
152  sbBaseMediaItemDownloadJob(aMediaItem, aTargetLibrary)
153 {
154  // Initialize logging.
155 #ifdef PR_LOGGING
156  if (!gHTTPMediaItemDownloadJobLog) {
157  gHTTPMediaItemDownloadJobLog =
158  PR_NewLogModule("sbHTTPMediaItemDownloadJob");
159  }
160 #endif
161 
162  TRACE(("%s[%.8x]", __FUNCTION__, this));
163 }
164 
NS_IMPL_ISUPPORTS_INHERITED0(sbHTTPMediaItemDownloadJob, sbBaseMediaItemDownloadJob) nsresult sbHTTPMediaItemDownloadJob
return NS_OK
#define TRACE(args)
Media library abstraction.
Definition: sbILibrary.idl:82
HTTP Media Item Download Job Definitions.
Interface that defines a single item of media in the system.