1 : /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 : /* ***** BEGIN LICENSE BLOCK *****
3 : * Version: MPL 1.1/GPL 2.0/LGPL 2.1
4 : *
5 : * The contents of this file are subject to the Mozilla Public License Version
6 : * 1.1 (the "License"); you may not use this file except in compliance with
7 : * the License. You may obtain a copy of the License at
8 : * http://www.mozilla.org/MPL/
9 : *
10 : * Software distributed under the License is distributed on an "AS IS" basis,
11 : * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
12 : * for the specific language governing rights and limitations under the
13 : * License.
14 : *
15 : * The Original Code is mozilla.org code.
16 : *
17 : * The Initial Developer of the Original Code is
18 : * Netscape Communications Corporation.
19 : * Portions created by the Initial Developer are Copyright (C) 1998
20 : * the Initial Developer. All Rights Reserved.
21 : *
22 : * Contributor(s):
23 : * Pierre Phaneuf <pp@ludusdesign.com>
24 : * Gagan Saksena <gagan@netscape.com>
25 : * Darin Fisher <darin@netscape.com>
26 : *
27 : * Alternatively, the contents of this file may be used under the terms of
28 : * either the GNU General Public License Version 2 or later (the "GPL"), or
29 : * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
30 : * in which case the provisions of the GPL or the LGPL are applicable instead
31 : * of those above. If you wish to allow use of your version of this file only
32 : * under the terms of either the GPL or the LGPL, and not to allow others to
33 : * use your version of this file under the terms of the MPL, indicate your
34 : * decision by deleting the provisions above and replace them with the notice
35 : * and other provisions required by the GPL or the LGPL. If you do not delete
36 : * the provisions above, a recipient may use your version of this file under
37 : * the terms of any one of the MPL, the GPL or the LGPL.
38 : *
39 : * ***** END LICENSE BLOCK ***** */
40 :
41 : #include "IPCMessageUtils.h"
42 :
43 : #include "nsSimpleURI.h"
44 : #include "nscore.h"
45 : #include "nsCRT.h"
46 : #include "nsString.h"
47 : #include "nsReadableUtils.h"
48 : #include "prmem.h"
49 : #include "prprf.h"
50 : #include "nsURLHelper.h"
51 : #include "nsNetCID.h"
52 : #include "nsIObjectInputStream.h"
53 : #include "nsIObjectOutputStream.h"
54 : #include "nsEscape.h"
55 : #include "nsNetError.h"
56 : #include "nsIProgrammingLanguage.h"
57 : #include "mozilla/Util.h" // for DebugOnly
58 :
59 : static NS_DEFINE_CID(kThisSimpleURIImplementationCID,
60 : NS_THIS_SIMPLEURI_IMPLEMENTATION_CID);
61 : static NS_DEFINE_CID(kSimpleURICID, NS_SIMPLEURI_CID);
62 :
63 : ////////////////////////////////////////////////////////////////////////////////
64 : // nsSimpleURI methods:
65 :
66 3337 : nsSimpleURI::nsSimpleURI()
67 : : mMutable(true),
68 3337 : mIsRefValid(false)
69 : {
70 3337 : }
71 :
72 5888 : nsSimpleURI::~nsSimpleURI()
73 : {
74 11776 : }
75 :
76 35343 : NS_IMPL_ADDREF(nsSimpleURI)
77 35343 : NS_IMPL_RELEASE(nsSimpleURI)
78 36505 : NS_INTERFACE_TABLE_HEAD(nsSimpleURI)
79 36505 : NS_INTERFACE_TABLE5(nsSimpleURI, nsIURI, nsISerializable, nsIIPCSerializable, nsIClassInfo, nsIMutable)
80 36505 : NS_INTERFACE_TABLE_TO_MAP_SEGUE
81 12857 : if (aIID.Equals(kThisSimpleURIImplementationCID))
82 2103 : foundInterface = static_cast<nsIURI*>(this);
83 : else
84 10754 : NS_INTERFACE_MAP_ENTRY(nsISizeOf)
85 10754 : NS_INTERFACE_MAP_END
86 :
87 : ////////////////////////////////////////////////////////////////////////////////
88 : // nsISerializable methods:
89 :
90 : NS_IMETHODIMP
91 3 : nsSimpleURI::Read(nsIObjectInputStream* aStream)
92 : {
93 : nsresult rv;
94 :
95 : bool isMutable; // (because ReadBoolean doesn't support bool*)
96 3 : rv = aStream->ReadBoolean(&isMutable);
97 3 : if (NS_FAILED(rv)) return rv;
98 : if (isMutable != true && isMutable != false) {
99 : NS_WARNING("Unexpected boolean value");
100 : return NS_ERROR_UNEXPECTED;
101 : }
102 3 : mMutable = isMutable;
103 :
104 3 : rv = aStream->ReadCString(mScheme);
105 3 : if (NS_FAILED(rv)) return rv;
106 :
107 3 : rv = aStream->ReadCString(mPath);
108 3 : if (NS_FAILED(rv)) return rv;
109 :
110 : bool isRefValid;
111 3 : rv = aStream->ReadBoolean(&isRefValid);
112 3 : if (NS_FAILED(rv)) return rv;
113 : if (isRefValid != true && isRefValid != false) {
114 : NS_WARNING("Unexpected boolean value");
115 : return NS_ERROR_UNEXPECTED;
116 : }
117 3 : mIsRefValid = isRefValid;
118 :
119 3 : if (isRefValid) {
120 0 : rv = aStream->ReadCString(mRef);
121 0 : if (NS_FAILED(rv)) return rv;
122 : } else {
123 3 : mRef.Truncate(); // invariant: mRef should be empty when it's not valid
124 : }
125 :
126 3 : return NS_OK;
127 : }
128 :
129 : NS_IMETHODIMP
130 3 : nsSimpleURI::Write(nsIObjectOutputStream* aStream)
131 : {
132 : nsresult rv;
133 :
134 3 : rv = aStream->WriteBoolean(mMutable);
135 3 : if (NS_FAILED(rv)) return rv;
136 :
137 3 : rv = aStream->WriteStringZ(mScheme.get());
138 3 : if (NS_FAILED(rv)) return rv;
139 :
140 3 : rv = aStream->WriteStringZ(mPath.get());
141 3 : if (NS_FAILED(rv)) return rv;
142 :
143 3 : rv = aStream->WriteBoolean(mIsRefValid);
144 3 : if (NS_FAILED(rv)) return rv;
145 :
146 3 : if (mIsRefValid) {
147 0 : rv = aStream->WriteStringZ(mRef.get());
148 0 : if (NS_FAILED(rv)) return rv;
149 : }
150 :
151 3 : return NS_OK;
152 : }
153 :
154 : ////////////////////////////////////////////////////////////////////////////////
155 : // nsIIPCSerializable methods:
156 :
157 : bool
158 0 : nsSimpleURI::Read(const IPC::Message *aMsg, void **aIter)
159 : {
160 : bool isMutable, isRefValid;
161 0 : if (!ReadParam(aMsg, aIter, &isMutable) ||
162 0 : !ReadParam(aMsg, aIter, &mScheme) ||
163 0 : !ReadParam(aMsg, aIter, &mPath) ||
164 0 : !ReadParam(aMsg, aIter, &isRefValid))
165 0 : return false;
166 :
167 0 : mMutable = isMutable;
168 0 : mIsRefValid = isRefValid;
169 :
170 0 : if (mIsRefValid) {
171 0 : return ReadParam(aMsg, aIter, &mRef);
172 : }
173 0 : mRef.Truncate(); // invariant: mRef should be empty when it's not valid
174 :
175 0 : return true;
176 : }
177 :
178 : void
179 0 : nsSimpleURI::Write(IPC::Message *aMsg)
180 : {
181 0 : WriteParam(aMsg, bool(mMutable));
182 0 : WriteParam(aMsg, mScheme);
183 0 : WriteParam(aMsg, mPath);
184 0 : WriteParam(aMsg, mIsRefValid);
185 0 : if (mIsRefValid) {
186 0 : WriteParam(aMsg, mRef);
187 : }
188 0 : }
189 :
190 : ////////////////////////////////////////////////////////////////////////////////
191 : // nsIURI methods:
192 :
193 : NS_IMETHODIMP
194 6250 : nsSimpleURI::GetSpec(nsACString &result)
195 : {
196 6250 : result = mScheme + NS_LITERAL_CSTRING(":") + mPath;
197 6250 : if (mIsRefValid) {
198 1999 : result += NS_LITERAL_CSTRING("#") + mRef;
199 : } else {
200 4251 : NS_ABORT_IF_FALSE(mRef.IsEmpty(), "mIsRefValid/mRef invariant broken");
201 : }
202 6250 : return NS_OK;
203 : }
204 :
205 : // result may contain unescaped UTF-8 characters
206 : NS_IMETHODIMP
207 0 : nsSimpleURI::GetSpecIgnoringRef(nsACString &result)
208 : {
209 0 : result = mScheme + NS_LITERAL_CSTRING(":") + mPath;
210 0 : return NS_OK;
211 : }
212 :
213 : NS_IMETHODIMP
214 75 : nsSimpleURI::GetHasRef(bool *result)
215 : {
216 75 : *result = mIsRefValid;
217 75 : return NS_OK;
218 : }
219 :
220 : NS_IMETHODIMP
221 3159 : nsSimpleURI::SetSpec(const nsACString &aSpec)
222 : {
223 3159 : NS_ENSURE_STATE(mMutable);
224 :
225 6308 : const nsAFlatCString& flat = PromiseFlatCString(aSpec);
226 3154 : const char* specPtr = flat.get();
227 :
228 : // filter out unexpected chars "\r\n\t" if necessary
229 6308 : nsCAutoString filteredSpec;
230 : PRInt32 specLen;
231 3154 : if (net_FilterURIString(specPtr, filteredSpec)) {
232 42 : specPtr = filteredSpec.get();
233 42 : specLen = filteredSpec.Length();
234 : } else
235 3112 : specLen = flat.Length();
236 :
237 : // nsSimpleURI currently restricts the charset to US-ASCII
238 6308 : nsCAutoString spec;
239 3154 : NS_EscapeURL(specPtr, specLen, esc_OnlyNonASCII|esc_AlwaysCopy, spec);
240 :
241 3154 : PRInt32 colonPos = spec.FindChar(':');
242 3154 : if (colonPos < 0 || !net_IsValidScheme(spec.get(), colonPos))
243 5 : return NS_ERROR_MALFORMED_URI;
244 :
245 3149 : mScheme.Truncate();
246 6298 : mozilla::DebugOnly<PRInt32> n = spec.Left(mScheme, colonPos);
247 3149 : NS_ASSERTION(n == colonPos, "Left failed");
248 3149 : ToLowerCase(mScheme);
249 :
250 : // This sets both mPath and mRef.
251 3149 : return SetPath(Substring(spec, colonPos + 1));
252 : }
253 :
254 : NS_IMETHODIMP
255 630 : nsSimpleURI::GetScheme(nsACString &result)
256 : {
257 630 : result = mScheme;
258 630 : return NS_OK;
259 : }
260 :
261 : NS_IMETHODIMP
262 5 : nsSimpleURI::SetScheme(const nsACString &scheme)
263 : {
264 5 : NS_ENSURE_STATE(mMutable);
265 :
266 0 : const nsPromiseFlatCString &flat = PromiseFlatCString(scheme);
267 0 : if (!net_IsValidScheme(flat)) {
268 0 : NS_ERROR("the given url scheme contains invalid characters");
269 0 : return NS_ERROR_MALFORMED_URI;
270 : }
271 :
272 0 : mScheme = scheme;
273 0 : ToLowerCase(mScheme);
274 0 : return NS_OK;
275 : }
276 :
277 : NS_IMETHODIMP
278 91 : nsSimpleURI::GetPrePath(nsACString &result)
279 : {
280 91 : result = mScheme + NS_LITERAL_CSTRING(":");
281 91 : return NS_OK;
282 : }
283 :
284 : NS_IMETHODIMP
285 0 : nsSimpleURI::GetUserPass(nsACString &result)
286 : {
287 0 : return NS_ERROR_FAILURE;
288 : }
289 :
290 : NS_IMETHODIMP
291 5 : nsSimpleURI::SetUserPass(const nsACString &userPass)
292 : {
293 5 : NS_ENSURE_STATE(mMutable);
294 :
295 0 : return NS_ERROR_FAILURE;
296 : }
297 :
298 : NS_IMETHODIMP
299 0 : nsSimpleURI::GetUsername(nsACString &result)
300 : {
301 0 : return NS_ERROR_FAILURE;
302 : }
303 :
304 : NS_IMETHODIMP
305 5 : nsSimpleURI::SetUsername(const nsACString &userName)
306 : {
307 5 : NS_ENSURE_STATE(mMutable);
308 :
309 0 : return NS_ERROR_FAILURE;
310 : }
311 :
312 : NS_IMETHODIMP
313 0 : nsSimpleURI::GetPassword(nsACString &result)
314 : {
315 0 : return NS_ERROR_FAILURE;
316 : }
317 :
318 : NS_IMETHODIMP
319 5 : nsSimpleURI::SetPassword(const nsACString &password)
320 : {
321 5 : NS_ENSURE_STATE(mMutable);
322 :
323 0 : return NS_ERROR_FAILURE;
324 : }
325 :
326 : NS_IMETHODIMP
327 0 : nsSimpleURI::GetHostPort(nsACString &result)
328 : {
329 : // Note: Audit all callers before changing this to return an empty
330 : // string -- CAPS and UI code may depend on this throwing.
331 0 : return NS_ERROR_FAILURE;
332 : }
333 :
334 : NS_IMETHODIMP
335 5 : nsSimpleURI::SetHostPort(const nsACString &result)
336 : {
337 5 : NS_ENSURE_STATE(mMutable);
338 :
339 0 : return NS_ERROR_FAILURE;
340 : }
341 :
342 : NS_IMETHODIMP
343 155 : nsSimpleURI::GetHost(nsACString &result)
344 : {
345 : // Note: Audit all callers before changing this to return an empty
346 : // string -- CAPS and UI code depend on this throwing.
347 155 : return NS_ERROR_FAILURE;
348 : }
349 :
350 : NS_IMETHODIMP
351 5 : nsSimpleURI::SetHost(const nsACString &host)
352 : {
353 5 : NS_ENSURE_STATE(mMutable);
354 :
355 0 : return NS_ERROR_FAILURE;
356 : }
357 :
358 : NS_IMETHODIMP
359 150 : nsSimpleURI::GetPort(PRInt32 *result)
360 : {
361 : // Note: Audit all callers before changing this to return an empty
362 : // string -- CAPS and UI code may depend on this throwing.
363 150 : return NS_ERROR_FAILURE;
364 : }
365 :
366 : NS_IMETHODIMP
367 5 : nsSimpleURI::SetPort(PRInt32 port)
368 : {
369 5 : NS_ENSURE_STATE(mMutable);
370 :
371 0 : return NS_ERROR_FAILURE;
372 : }
373 :
374 : NS_IMETHODIMP
375 1386 : nsSimpleURI::GetPath(nsACString &result)
376 : {
377 1386 : result = mPath;
378 1386 : if (mIsRefValid) {
379 115 : result += NS_LITERAL_CSTRING("#") + mRef;
380 : }
381 :
382 1386 : return NS_OK;
383 : }
384 :
385 : NS_IMETHODIMP
386 3289 : nsSimpleURI::SetPath(const nsACString &path)
387 : {
388 3289 : NS_ENSURE_STATE(mMutable);
389 :
390 3284 : PRInt32 hashPos = path.FindChar('#');
391 3284 : if (hashPos < 0) {
392 2989 : mIsRefValid = false;
393 2989 : mRef.Truncate(); // invariant: mRef should be empty when it's not valid
394 2989 : mPath = path;
395 2989 : return NS_OK;
396 : }
397 :
398 295 : mPath = StringHead(path, hashPos);
399 295 : return SetRef(Substring(path, PRUint32(hashPos)));
400 : }
401 :
402 : NS_IMETHODIMP
403 199 : nsSimpleURI::GetRef(nsACString &result)
404 : {
405 199 : if (!mIsRefValid) {
406 199 : NS_ABORT_IF_FALSE(mRef.IsEmpty(), "mIsRefValid/mRef invariant broken");
407 199 : result.Truncate();
408 : } else {
409 0 : result = mRef;
410 : }
411 :
412 199 : return NS_OK;
413 : }
414 :
415 : // NOTE: SetRef("") removes our ref, whereas SetRef("#") sets it to the empty
416 : // string (and will result in .spec and .path having a terminal #).
417 : NS_IMETHODIMP
418 521 : nsSimpleURI::SetRef(const nsACString &aRef)
419 : {
420 521 : NS_ENSURE_STATE(mMutable);
421 :
422 516 : if (aRef.IsEmpty()) {
423 : // Empty string means to remove ref completely.
424 135 : mIsRefValid = false;
425 135 : mRef.Truncate(); // invariant: mRef should be empty when it's not valid
426 135 : return NS_OK;
427 : }
428 :
429 381 : mIsRefValid = true;
430 :
431 : // Gracefully skip initial hash
432 381 : if (aRef[0] == '#') {
433 345 : mRef = Substring(aRef, 1);
434 : } else {
435 36 : mRef = aRef;
436 : }
437 :
438 381 : return NS_OK;
439 : }
440 :
441 : NS_IMETHODIMP
442 1266 : nsSimpleURI::Equals(nsIURI* other, bool *result)
443 : {
444 1266 : return EqualsInternal(other, eHonorRef, result);
445 : }
446 :
447 : NS_IMETHODIMP
448 1484 : nsSimpleURI::EqualsExceptRef(nsIURI* other, bool *result)
449 : {
450 1484 : return EqualsInternal(other, eIgnoreRef, result);
451 : }
452 :
453 : /* virtual */ nsresult
454 2140 : nsSimpleURI::EqualsInternal(nsIURI* other,
455 : nsSimpleURI::RefHandlingEnum refHandlingMode,
456 : bool* result)
457 : {
458 2140 : NS_ENSURE_ARG_POINTER(other);
459 2129 : NS_PRECONDITION(result, "null pointer");
460 :
461 4258 : nsRefPtr<nsSimpleURI> otherUri;
462 : nsresult rv = other->QueryInterface(kThisSimpleURIImplementationCID,
463 2129 : getter_AddRefs(otherUri));
464 2129 : if (NS_FAILED(rv)) {
465 26 : *result = false;
466 26 : return NS_OK;
467 : }
468 :
469 2103 : *result = EqualsInternal(otherUri, refHandlingMode);
470 2103 : return NS_OK;
471 : }
472 :
473 : bool
474 2407 : nsSimpleURI::EqualsInternal(nsSimpleURI* otherUri, RefHandlingEnum refHandlingMode)
475 : {
476 2407 : bool result = (mScheme == otherUri->mScheme &&
477 2407 : mPath == otherUri->mPath);
478 :
479 2407 : if (result && refHandlingMode == eHonorRef) {
480 : result = (mIsRefValid == otherUri->mIsRefValid &&
481 1059 : (!mIsRefValid || mRef == otherUri->mRef));
482 : }
483 :
484 2407 : return result;
485 : }
486 :
487 : NS_IMETHODIMP
488 1274 : nsSimpleURI::SchemeIs(const char *i_Scheme, bool *o_Equals)
489 : {
490 1274 : NS_ENSURE_ARG_POINTER(o_Equals);
491 1274 : if (!i_Scheme) return NS_ERROR_NULL_POINTER;
492 :
493 1274 : const char *this_scheme = mScheme.get();
494 :
495 : // mScheme is guaranteed to be lower case.
496 1274 : if (*i_Scheme == *this_scheme || *i_Scheme == (*this_scheme - ('a' - 'A')) ) {
497 1101 : *o_Equals = PL_strcasecmp(this_scheme, i_Scheme) ? false : true;
498 : } else {
499 173 : *o_Equals = false;
500 : }
501 :
502 1274 : return NS_OK;
503 : }
504 :
505 : /* virtual */ nsSimpleURI*
506 154 : nsSimpleURI::StartClone(nsSimpleURI::RefHandlingEnum /* ignored */)
507 : {
508 154 : return new nsSimpleURI();
509 : }
510 :
511 : NS_IMETHODIMP
512 117 : nsSimpleURI::Clone(nsIURI** result)
513 : {
514 117 : return CloneInternal(eHonorRef, result);
515 : }
516 :
517 : NS_IMETHODIMP
518 109 : nsSimpleURI::CloneIgnoringRef(nsIURI** result)
519 : {
520 109 : return CloneInternal(eIgnoreRef, result);
521 : }
522 :
523 : nsresult
524 226 : nsSimpleURI::CloneInternal(nsSimpleURI::RefHandlingEnum refHandlingMode,
525 : nsIURI** result)
526 : {
527 452 : nsRefPtr<nsSimpleURI> url = StartClone(refHandlingMode);
528 226 : if (!url)
529 0 : return NS_ERROR_OUT_OF_MEMORY;
530 :
531 : // Note: |url| may well have mMutable false at this point, so
532 : // don't call any setter methods.
533 226 : url->mScheme = mScheme;
534 226 : url->mPath = mPath;
535 226 : if (refHandlingMode == eHonorRef) {
536 117 : url->mRef = mRef;
537 117 : url->mIsRefValid = mIsRefValid;
538 : }
539 :
540 226 : url.forget(result);
541 226 : return NS_OK;
542 : }
543 :
544 : NS_IMETHODIMP
545 0 : nsSimpleURI::Resolve(const nsACString &relativePath, nsACString &result)
546 : {
547 0 : result = relativePath;
548 0 : return NS_OK;
549 : }
550 :
551 : NS_IMETHODIMP
552 421 : nsSimpleURI::GetAsciiSpec(nsACString &result)
553 : {
554 842 : nsCAutoString buf;
555 421 : nsresult rv = GetSpec(buf);
556 421 : if (NS_FAILED(rv)) return rv;
557 421 : NS_EscapeURL(buf, esc_OnlyNonASCII|esc_AlwaysCopy, result);
558 421 : return NS_OK;
559 : }
560 :
561 : NS_IMETHODIMP
562 39 : nsSimpleURI::GetAsciiHost(nsACString &result)
563 : {
564 39 : result.Truncate();
565 39 : return NS_OK;
566 : }
567 :
568 : NS_IMETHODIMP
569 14 : nsSimpleURI::GetOriginCharset(nsACString &result)
570 : {
571 14 : result.Truncate();
572 14 : return NS_OK;
573 : }
574 :
575 : //----------------------------------------------------------------------------
576 : // nsSimpleURI::nsIClassInfo
577 : //----------------------------------------------------------------------------
578 :
579 : NS_IMETHODIMP
580 1027 : nsSimpleURI::GetInterfaces(PRUint32 *count, nsIID * **array)
581 : {
582 1027 : *count = 0;
583 1027 : *array = nsnull;
584 1027 : return NS_OK;
585 : }
586 :
587 : NS_IMETHODIMP
588 1691 : nsSimpleURI::GetHelperForLanguage(PRUint32 language, nsISupports **_retval)
589 : {
590 1691 : *_retval = nsnull;
591 1691 : return NS_OK;
592 : }
593 :
594 : NS_IMETHODIMP
595 0 : nsSimpleURI::GetContractID(char * *aContractID)
596 : {
597 : // Make sure to modify any subclasses as needed if this ever
598 : // changes.
599 0 : *aContractID = nsnull;
600 0 : return NS_OK;
601 : }
602 :
603 : NS_IMETHODIMP
604 0 : nsSimpleURI::GetClassDescription(char * *aClassDescription)
605 : {
606 0 : *aClassDescription = nsnull;
607 0 : return NS_OK;
608 : }
609 :
610 : NS_IMETHODIMP
611 0 : nsSimpleURI::GetClassID(nsCID * *aClassID)
612 : {
613 : // Make sure to modify any subclasses as needed if this ever
614 : // changes to not call the virtual GetClassIDNoAlloc.
615 0 : *aClassID = (nsCID*) nsMemory::Alloc(sizeof(nsCID));
616 0 : if (!*aClassID)
617 0 : return NS_ERROR_OUT_OF_MEMORY;
618 0 : return GetClassIDNoAlloc(*aClassID);
619 : }
620 :
621 : NS_IMETHODIMP
622 0 : nsSimpleURI::GetImplementationLanguage(PRUint32 *aImplementationLanguage)
623 : {
624 0 : *aImplementationLanguage = nsIProgrammingLanguage::CPLUSPLUS;
625 0 : return NS_OK;
626 : }
627 :
628 : NS_IMETHODIMP
629 1734 : nsSimpleURI::GetFlags(PRUint32 *aFlags)
630 : {
631 1734 : *aFlags = nsIClassInfo::MAIN_THREAD_ONLY;
632 1734 : return NS_OK;
633 : }
634 :
635 : NS_IMETHODIMP
636 2 : nsSimpleURI::GetClassIDNoAlloc(nsCID *aClassIDNoAlloc)
637 : {
638 2 : *aClassIDNoAlloc = kSimpleURICID;
639 2 : return NS_OK;
640 : }
641 :
642 : //----------------------------------------------------------------------------
643 : // nsSimpleURI::nsISimpleURI
644 : //----------------------------------------------------------------------------
645 : NS_IMETHODIMP
646 716 : nsSimpleURI::GetMutable(bool *value)
647 : {
648 716 : *value = mMutable;
649 716 : return NS_OK;
650 : }
651 :
652 : NS_IMETHODIMP
653 2476 : nsSimpleURI::SetMutable(bool value)
654 : {
655 2476 : NS_ENSURE_ARG(mMutable || !value);
656 :
657 2476 : mMutable = value;
658 2476 : return NS_OK;
659 : }
660 :
661 : //----------------------------------------------------------------------------
662 : // nsSimpleURI::nsISizeOf
663 : //----------------------------------------------------------------------------
664 :
665 : size_t
666 0 : nsSimpleURI::SizeOfExcludingThis(nsMallocSizeOfFun aMallocSizeOf) const
667 : {
668 0 : return mScheme.SizeOfExcludingThisIfUnshared(aMallocSizeOf) +
669 0 : mPath.SizeOfExcludingThisIfUnshared(aMallocSizeOf) +
670 0 : mRef.SizeOfExcludingThisIfUnshared(aMallocSizeOf);
671 : }
672 :
673 : size_t
674 0 : nsSimpleURI::SizeOfIncludingThis(nsMallocSizeOfFun aMallocSizeOf) const {
675 0 : return aMallocSizeOf(this) + SizeOfExcludingThis(aMallocSizeOf);
676 : }
677 :
|