1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 1.2 +++ b/netwerk/base/src/nsSimpleURI.cpp Wed Dec 31 06:09:35 2014 +0100 1.3 @@ -0,0 +1,649 @@ 1.4 +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ 1.5 +/* This Source Code Form is subject to the terms of the Mozilla Public 1.6 + * License, v. 2.0. If a copy of the MPL was not distributed with this 1.7 + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ 1.8 + 1.9 +#include "mozilla/DebugOnly.h" 1.10 + 1.11 +#undef LOG 1.12 +#include "IPCMessageUtils.h" 1.13 + 1.14 +#include "nsSimpleURI.h" 1.15 +#include "nscore.h" 1.16 +#include "nsString.h" 1.17 +#include "plstr.h" 1.18 +#include "nsURLHelper.h" 1.19 +#include "nsNetCID.h" 1.20 +#include "nsIObjectInputStream.h" 1.21 +#include "nsIObjectOutputStream.h" 1.22 +#include "nsEscape.h" 1.23 +#include "nsError.h" 1.24 +#include "nsIProgrammingLanguage.h" 1.25 +#include "nsIIPCSerializableURI.h" 1.26 +#include "mozilla/MemoryReporting.h" 1.27 +#include "mozilla/ipc/URIUtils.h" 1.28 + 1.29 +using namespace mozilla::ipc; 1.30 + 1.31 +static NS_DEFINE_CID(kThisSimpleURIImplementationCID, 1.32 + NS_THIS_SIMPLEURI_IMPLEMENTATION_CID); 1.33 +static NS_DEFINE_CID(kSimpleURICID, NS_SIMPLEURI_CID); 1.34 + 1.35 +//////////////////////////////////////////////////////////////////////////////// 1.36 +// nsSimpleURI methods: 1.37 + 1.38 +nsSimpleURI::nsSimpleURI() 1.39 + : mMutable(true), 1.40 + mIsRefValid(false) 1.41 +{ 1.42 +} 1.43 + 1.44 +nsSimpleURI::~nsSimpleURI() 1.45 +{ 1.46 +} 1.47 + 1.48 +NS_IMPL_ADDREF(nsSimpleURI) 1.49 +NS_IMPL_RELEASE(nsSimpleURI) 1.50 +NS_INTERFACE_TABLE_HEAD(nsSimpleURI) 1.51 +NS_INTERFACE_TABLE(nsSimpleURI, nsIURI, nsISerializable, nsIClassInfo, 1.52 + nsIMutable, nsIIPCSerializableURI) 1.53 +NS_INTERFACE_TABLE_TO_MAP_SEGUE 1.54 + if (aIID.Equals(kThisSimpleURIImplementationCID)) 1.55 + foundInterface = static_cast<nsIURI*>(this); 1.56 + else 1.57 + NS_INTERFACE_MAP_ENTRY(nsISizeOf) 1.58 +NS_INTERFACE_MAP_END 1.59 + 1.60 +//////////////////////////////////////////////////////////////////////////////// 1.61 +// nsISerializable methods: 1.62 + 1.63 +NS_IMETHODIMP 1.64 +nsSimpleURI::Read(nsIObjectInputStream* aStream) 1.65 +{ 1.66 + nsresult rv; 1.67 + 1.68 + bool isMutable; 1.69 + rv = aStream->ReadBoolean(&isMutable); 1.70 + if (NS_FAILED(rv)) return rv; 1.71 + mMutable = isMutable; 1.72 + 1.73 + rv = aStream->ReadCString(mScheme); 1.74 + if (NS_FAILED(rv)) return rv; 1.75 + 1.76 + rv = aStream->ReadCString(mPath); 1.77 + if (NS_FAILED(rv)) return rv; 1.78 + 1.79 + bool isRefValid; 1.80 + rv = aStream->ReadBoolean(&isRefValid); 1.81 + if (NS_FAILED(rv)) return rv; 1.82 + mIsRefValid = isRefValid; 1.83 + 1.84 + if (isRefValid) { 1.85 + rv = aStream->ReadCString(mRef); 1.86 + if (NS_FAILED(rv)) return rv; 1.87 + } else { 1.88 + mRef.Truncate(); // invariant: mRef should be empty when it's not valid 1.89 + } 1.90 + 1.91 + return NS_OK; 1.92 +} 1.93 + 1.94 +NS_IMETHODIMP 1.95 +nsSimpleURI::Write(nsIObjectOutputStream* aStream) 1.96 +{ 1.97 + nsresult rv; 1.98 + 1.99 + rv = aStream->WriteBoolean(mMutable); 1.100 + if (NS_FAILED(rv)) return rv; 1.101 + 1.102 + rv = aStream->WriteStringZ(mScheme.get()); 1.103 + if (NS_FAILED(rv)) return rv; 1.104 + 1.105 + rv = aStream->WriteStringZ(mPath.get()); 1.106 + if (NS_FAILED(rv)) return rv; 1.107 + 1.108 + rv = aStream->WriteBoolean(mIsRefValid); 1.109 + if (NS_FAILED(rv)) return rv; 1.110 + 1.111 + if (mIsRefValid) { 1.112 + rv = aStream->WriteStringZ(mRef.get()); 1.113 + if (NS_FAILED(rv)) return rv; 1.114 + } 1.115 + 1.116 + return NS_OK; 1.117 +} 1.118 + 1.119 +//////////////////////////////////////////////////////////////////////////////// 1.120 +// nsIIPCSerializableURI methods: 1.121 + 1.122 +void 1.123 +nsSimpleURI::Serialize(URIParams& aParams) 1.124 +{ 1.125 + SimpleURIParams params; 1.126 + 1.127 + params.scheme() = mScheme; 1.128 + params.path() = mPath; 1.129 + if (mIsRefValid) { 1.130 + params.ref() = mRef; 1.131 + } 1.132 + else { 1.133 + params.ref().SetIsVoid(true); 1.134 + } 1.135 + params.isMutable() = mMutable; 1.136 + 1.137 + aParams = params; 1.138 +} 1.139 + 1.140 +bool 1.141 +nsSimpleURI::Deserialize(const URIParams& aParams) 1.142 +{ 1.143 + if (aParams.type() != URIParams::TSimpleURIParams) { 1.144 + NS_ERROR("Received unknown parameters from the other process!"); 1.145 + return false; 1.146 + } 1.147 + 1.148 + const SimpleURIParams& params = aParams.get_SimpleURIParams(); 1.149 + 1.150 + mScheme = params.scheme(); 1.151 + mPath = params.path(); 1.152 + if (params.ref().IsVoid()) { 1.153 + mRef.Truncate(); 1.154 + mIsRefValid = false; 1.155 + } 1.156 + else { 1.157 + mRef = params.ref(); 1.158 + mIsRefValid = true; 1.159 + } 1.160 + mMutable = params.isMutable(); 1.161 + 1.162 + return true; 1.163 +} 1.164 + 1.165 +//////////////////////////////////////////////////////////////////////////////// 1.166 +// nsIURI methods: 1.167 + 1.168 +NS_IMETHODIMP 1.169 +nsSimpleURI::GetSpec(nsACString &result) 1.170 +{ 1.171 + result = mScheme + NS_LITERAL_CSTRING(":") + mPath; 1.172 + if (mIsRefValid) { 1.173 + result += NS_LITERAL_CSTRING("#") + mRef; 1.174 + } else { 1.175 + NS_ABORT_IF_FALSE(mRef.IsEmpty(), "mIsRefValid/mRef invariant broken"); 1.176 + } 1.177 + return NS_OK; 1.178 +} 1.179 + 1.180 +// result may contain unescaped UTF-8 characters 1.181 +NS_IMETHODIMP 1.182 +nsSimpleURI::GetSpecIgnoringRef(nsACString &result) 1.183 +{ 1.184 + result = mScheme + NS_LITERAL_CSTRING(":") + mPath; 1.185 + return NS_OK; 1.186 +} 1.187 + 1.188 +NS_IMETHODIMP 1.189 +nsSimpleURI::GetHasRef(bool *result) 1.190 +{ 1.191 + *result = mIsRefValid; 1.192 + return NS_OK; 1.193 +} 1.194 + 1.195 +NS_IMETHODIMP 1.196 +nsSimpleURI::SetSpec(const nsACString &aSpec) 1.197 +{ 1.198 + NS_ENSURE_STATE(mMutable); 1.199 + 1.200 + const nsAFlatCString& flat = PromiseFlatCString(aSpec); 1.201 + const char* specPtr = flat.get(); 1.202 + 1.203 + // filter out unexpected chars "\r\n\t" if necessary 1.204 + nsAutoCString filteredSpec; 1.205 + int32_t specLen; 1.206 + if (net_FilterURIString(specPtr, filteredSpec)) { 1.207 + specPtr = filteredSpec.get(); 1.208 + specLen = filteredSpec.Length(); 1.209 + } else 1.210 + specLen = flat.Length(); 1.211 + 1.212 + // nsSimpleURI currently restricts the charset to US-ASCII 1.213 + nsAutoCString spec; 1.214 + NS_EscapeURL(specPtr, specLen, esc_OnlyNonASCII|esc_AlwaysCopy, spec); 1.215 + 1.216 + int32_t colonPos = spec.FindChar(':'); 1.217 + if (colonPos < 0 || !net_IsValidScheme(spec.get(), colonPos)) 1.218 + return NS_ERROR_MALFORMED_URI; 1.219 + 1.220 + mScheme.Truncate(); 1.221 + mozilla::DebugOnly<int32_t> n = spec.Left(mScheme, colonPos); 1.222 + NS_ASSERTION(n == colonPos, "Left failed"); 1.223 + ToLowerCase(mScheme); 1.224 + 1.225 + // This sets both mPath and mRef. 1.226 + return SetPath(Substring(spec, colonPos + 1)); 1.227 +} 1.228 + 1.229 +NS_IMETHODIMP 1.230 +nsSimpleURI::GetScheme(nsACString &result) 1.231 +{ 1.232 + result = mScheme; 1.233 + return NS_OK; 1.234 +} 1.235 + 1.236 +NS_IMETHODIMP 1.237 +nsSimpleURI::SetScheme(const nsACString &scheme) 1.238 +{ 1.239 + NS_ENSURE_STATE(mMutable); 1.240 + 1.241 + const nsPromiseFlatCString &flat = PromiseFlatCString(scheme); 1.242 + if (!net_IsValidScheme(flat)) { 1.243 + NS_ERROR("the given url scheme contains invalid characters"); 1.244 + return NS_ERROR_MALFORMED_URI; 1.245 + } 1.246 + 1.247 + mScheme = scheme; 1.248 + ToLowerCase(mScheme); 1.249 + return NS_OK; 1.250 +} 1.251 + 1.252 +NS_IMETHODIMP 1.253 +nsSimpleURI::GetPrePath(nsACString &result) 1.254 +{ 1.255 + result = mScheme + NS_LITERAL_CSTRING(":"); 1.256 + return NS_OK; 1.257 +} 1.258 + 1.259 +NS_IMETHODIMP 1.260 +nsSimpleURI::GetUserPass(nsACString &result) 1.261 +{ 1.262 + return NS_ERROR_FAILURE; 1.263 +} 1.264 + 1.265 +NS_IMETHODIMP 1.266 +nsSimpleURI::SetUserPass(const nsACString &userPass) 1.267 +{ 1.268 + NS_ENSURE_STATE(mMutable); 1.269 + 1.270 + return NS_ERROR_FAILURE; 1.271 +} 1.272 + 1.273 +NS_IMETHODIMP 1.274 +nsSimpleURI::GetUsername(nsACString &result) 1.275 +{ 1.276 + return NS_ERROR_FAILURE; 1.277 +} 1.278 + 1.279 +NS_IMETHODIMP 1.280 +nsSimpleURI::SetUsername(const nsACString &userName) 1.281 +{ 1.282 + NS_ENSURE_STATE(mMutable); 1.283 + 1.284 + return NS_ERROR_FAILURE; 1.285 +} 1.286 + 1.287 +NS_IMETHODIMP 1.288 +nsSimpleURI::GetPassword(nsACString &result) 1.289 +{ 1.290 + return NS_ERROR_FAILURE; 1.291 +} 1.292 + 1.293 +NS_IMETHODIMP 1.294 +nsSimpleURI::SetPassword(const nsACString &password) 1.295 +{ 1.296 + NS_ENSURE_STATE(mMutable); 1.297 + 1.298 + return NS_ERROR_FAILURE; 1.299 +} 1.300 + 1.301 +NS_IMETHODIMP 1.302 +nsSimpleURI::GetHostPort(nsACString &result) 1.303 +{ 1.304 + // Note: Audit all callers before changing this to return an empty 1.305 + // string -- CAPS and UI code may depend on this throwing. 1.306 + return NS_ERROR_FAILURE; 1.307 +} 1.308 + 1.309 +NS_IMETHODIMP 1.310 +nsSimpleURI::SetHostPort(const nsACString &result) 1.311 +{ 1.312 + NS_ENSURE_STATE(mMutable); 1.313 + 1.314 + return NS_ERROR_FAILURE; 1.315 +} 1.316 + 1.317 +NS_IMETHODIMP 1.318 +nsSimpleURI::GetHost(nsACString &result) 1.319 +{ 1.320 + // Note: Audit all callers before changing this to return an empty 1.321 + // string -- CAPS and UI code depend on this throwing. 1.322 + return NS_ERROR_FAILURE; 1.323 +} 1.324 + 1.325 +NS_IMETHODIMP 1.326 +nsSimpleURI::SetHost(const nsACString &host) 1.327 +{ 1.328 + NS_ENSURE_STATE(mMutable); 1.329 + 1.330 + return NS_ERROR_FAILURE; 1.331 +} 1.332 + 1.333 +NS_IMETHODIMP 1.334 +nsSimpleURI::GetPort(int32_t *result) 1.335 +{ 1.336 + // Note: Audit all callers before changing this to return an empty 1.337 + // string -- CAPS and UI code may depend on this throwing. 1.338 + return NS_ERROR_FAILURE; 1.339 +} 1.340 + 1.341 +NS_IMETHODIMP 1.342 +nsSimpleURI::SetPort(int32_t port) 1.343 +{ 1.344 + NS_ENSURE_STATE(mMutable); 1.345 + 1.346 + return NS_ERROR_FAILURE; 1.347 +} 1.348 + 1.349 +NS_IMETHODIMP 1.350 +nsSimpleURI::GetPath(nsACString &result) 1.351 +{ 1.352 + result = mPath; 1.353 + if (mIsRefValid) { 1.354 + result += NS_LITERAL_CSTRING("#") + mRef; 1.355 + } 1.356 + 1.357 + return NS_OK; 1.358 +} 1.359 + 1.360 +NS_IMETHODIMP 1.361 +nsSimpleURI::SetPath(const nsACString &path) 1.362 +{ 1.363 + NS_ENSURE_STATE(mMutable); 1.364 + 1.365 + int32_t hashPos = path.FindChar('#'); 1.366 + if (hashPos < 0) { 1.367 + mIsRefValid = false; 1.368 + mRef.Truncate(); // invariant: mRef should be empty when it's not valid 1.369 + mPath = path; 1.370 + return NS_OK; 1.371 + } 1.372 + 1.373 + mPath = StringHead(path, hashPos); 1.374 + return SetRef(Substring(path, uint32_t(hashPos))); 1.375 +} 1.376 + 1.377 +NS_IMETHODIMP 1.378 +nsSimpleURI::GetRef(nsACString &result) 1.379 +{ 1.380 + if (!mIsRefValid) { 1.381 + NS_ABORT_IF_FALSE(mRef.IsEmpty(), "mIsRefValid/mRef invariant broken"); 1.382 + result.Truncate(); 1.383 + } else { 1.384 + result = mRef; 1.385 + } 1.386 + 1.387 + return NS_OK; 1.388 +} 1.389 + 1.390 +// NOTE: SetRef("") removes our ref, whereas SetRef("#") sets it to the empty 1.391 +// string (and will result in .spec and .path having a terminal #). 1.392 +NS_IMETHODIMP 1.393 +nsSimpleURI::SetRef(const nsACString &aRef) 1.394 +{ 1.395 + NS_ENSURE_STATE(mMutable); 1.396 + 1.397 + if (aRef.IsEmpty()) { 1.398 + // Empty string means to remove ref completely. 1.399 + mIsRefValid = false; 1.400 + mRef.Truncate(); // invariant: mRef should be empty when it's not valid 1.401 + return NS_OK; 1.402 + } 1.403 + 1.404 + mIsRefValid = true; 1.405 + 1.406 + // Gracefully skip initial hash 1.407 + if (aRef[0] == '#') { 1.408 + mRef = Substring(aRef, 1); 1.409 + } else { 1.410 + mRef = aRef; 1.411 + } 1.412 + 1.413 + return NS_OK; 1.414 +} 1.415 + 1.416 +NS_IMETHODIMP 1.417 +nsSimpleURI::Equals(nsIURI* other, bool *result) 1.418 +{ 1.419 + return EqualsInternal(other, eHonorRef, result); 1.420 +} 1.421 + 1.422 +NS_IMETHODIMP 1.423 +nsSimpleURI::EqualsExceptRef(nsIURI* other, bool *result) 1.424 +{ 1.425 + return EqualsInternal(other, eIgnoreRef, result); 1.426 +} 1.427 + 1.428 +/* virtual */ nsresult 1.429 +nsSimpleURI::EqualsInternal(nsIURI* other, 1.430 + nsSimpleURI::RefHandlingEnum refHandlingMode, 1.431 + bool* result) 1.432 +{ 1.433 + NS_ENSURE_ARG_POINTER(other); 1.434 + NS_PRECONDITION(result, "null pointer"); 1.435 + 1.436 + nsRefPtr<nsSimpleURI> otherUri; 1.437 + nsresult rv = other->QueryInterface(kThisSimpleURIImplementationCID, 1.438 + getter_AddRefs(otherUri)); 1.439 + if (NS_FAILED(rv)) { 1.440 + *result = false; 1.441 + return NS_OK; 1.442 + } 1.443 + 1.444 + *result = EqualsInternal(otherUri, refHandlingMode); 1.445 + return NS_OK; 1.446 +} 1.447 + 1.448 +bool 1.449 +nsSimpleURI::EqualsInternal(nsSimpleURI* otherUri, RefHandlingEnum refHandlingMode) 1.450 +{ 1.451 + bool result = (mScheme == otherUri->mScheme && 1.452 + mPath == otherUri->mPath); 1.453 + 1.454 + if (result && refHandlingMode == eHonorRef) { 1.455 + result = (mIsRefValid == otherUri->mIsRefValid && 1.456 + (!mIsRefValid || mRef == otherUri->mRef)); 1.457 + } 1.458 + 1.459 + return result; 1.460 +} 1.461 + 1.462 +NS_IMETHODIMP 1.463 +nsSimpleURI::SchemeIs(const char *i_Scheme, bool *o_Equals) 1.464 +{ 1.465 + NS_ENSURE_ARG_POINTER(o_Equals); 1.466 + if (!i_Scheme) return NS_ERROR_NULL_POINTER; 1.467 + 1.468 + const char *this_scheme = mScheme.get(); 1.469 + 1.470 + // mScheme is guaranteed to be lower case. 1.471 + if (*i_Scheme == *this_scheme || *i_Scheme == (*this_scheme - ('a' - 'A')) ) { 1.472 + *o_Equals = PL_strcasecmp(this_scheme, i_Scheme) ? false : true; 1.473 + } else { 1.474 + *o_Equals = false; 1.475 + } 1.476 + 1.477 + return NS_OK; 1.478 +} 1.479 + 1.480 +/* virtual */ nsSimpleURI* 1.481 +nsSimpleURI::StartClone(nsSimpleURI::RefHandlingEnum /* ignored */) 1.482 +{ 1.483 + return new nsSimpleURI(); 1.484 +} 1.485 + 1.486 +NS_IMETHODIMP 1.487 +nsSimpleURI::Clone(nsIURI** result) 1.488 +{ 1.489 + return CloneInternal(eHonorRef, result); 1.490 +} 1.491 + 1.492 +NS_IMETHODIMP 1.493 +nsSimpleURI::CloneIgnoringRef(nsIURI** result) 1.494 +{ 1.495 + return CloneInternal(eIgnoreRef, result); 1.496 +} 1.497 + 1.498 +nsresult 1.499 +nsSimpleURI::CloneInternal(nsSimpleURI::RefHandlingEnum refHandlingMode, 1.500 + nsIURI** result) 1.501 +{ 1.502 + nsRefPtr<nsSimpleURI> url = StartClone(refHandlingMode); 1.503 + if (!url) 1.504 + return NS_ERROR_OUT_OF_MEMORY; 1.505 + 1.506 + // Note: |url| may well have mMutable false at this point, so 1.507 + // don't call any setter methods. 1.508 + url->mScheme = mScheme; 1.509 + url->mPath = mPath; 1.510 + if (refHandlingMode == eHonorRef) { 1.511 + url->mRef = mRef; 1.512 + url->mIsRefValid = mIsRefValid; 1.513 + } 1.514 + 1.515 + url.forget(result); 1.516 + return NS_OK; 1.517 +} 1.518 + 1.519 +NS_IMETHODIMP 1.520 +nsSimpleURI::Resolve(const nsACString &relativePath, nsACString &result) 1.521 +{ 1.522 + result = relativePath; 1.523 + return NS_OK; 1.524 +} 1.525 + 1.526 +NS_IMETHODIMP 1.527 +nsSimpleURI::GetAsciiSpec(nsACString &result) 1.528 +{ 1.529 + nsAutoCString buf; 1.530 + nsresult rv = GetSpec(buf); 1.531 + if (NS_FAILED(rv)) return rv; 1.532 + NS_EscapeURL(buf, esc_OnlyNonASCII|esc_AlwaysCopy, result); 1.533 + return NS_OK; 1.534 +} 1.535 + 1.536 +NS_IMETHODIMP 1.537 +nsSimpleURI::GetAsciiHost(nsACString &result) 1.538 +{ 1.539 + result.Truncate(); 1.540 + return NS_OK; 1.541 +} 1.542 + 1.543 +NS_IMETHODIMP 1.544 +nsSimpleURI::GetOriginCharset(nsACString &result) 1.545 +{ 1.546 + result.Truncate(); 1.547 + return NS_OK; 1.548 +} 1.549 + 1.550 +//---------------------------------------------------------------------------- 1.551 +// nsSimpleURI::nsIClassInfo 1.552 +//---------------------------------------------------------------------------- 1.553 + 1.554 +NS_IMETHODIMP 1.555 +nsSimpleURI::GetInterfaces(uint32_t *count, nsIID * **array) 1.556 +{ 1.557 + *count = 0; 1.558 + *array = nullptr; 1.559 + return NS_OK; 1.560 +} 1.561 + 1.562 +NS_IMETHODIMP 1.563 +nsSimpleURI::GetHelperForLanguage(uint32_t language, nsISupports **_retval) 1.564 +{ 1.565 + *_retval = nullptr; 1.566 + return NS_OK; 1.567 +} 1.568 + 1.569 +NS_IMETHODIMP 1.570 +nsSimpleURI::GetContractID(char * *aContractID) 1.571 +{ 1.572 + // Make sure to modify any subclasses as needed if this ever 1.573 + // changes. 1.574 + *aContractID = nullptr; 1.575 + return NS_OK; 1.576 +} 1.577 + 1.578 +NS_IMETHODIMP 1.579 +nsSimpleURI::GetClassDescription(char * *aClassDescription) 1.580 +{ 1.581 + *aClassDescription = nullptr; 1.582 + return NS_OK; 1.583 +} 1.584 + 1.585 +NS_IMETHODIMP 1.586 +nsSimpleURI::GetClassID(nsCID * *aClassID) 1.587 +{ 1.588 + // Make sure to modify any subclasses as needed if this ever 1.589 + // changes to not call the virtual GetClassIDNoAlloc. 1.590 + *aClassID = (nsCID*) nsMemory::Alloc(sizeof(nsCID)); 1.591 + if (!*aClassID) 1.592 + return NS_ERROR_OUT_OF_MEMORY; 1.593 + return GetClassIDNoAlloc(*aClassID); 1.594 +} 1.595 + 1.596 +NS_IMETHODIMP 1.597 +nsSimpleURI::GetImplementationLanguage(uint32_t *aImplementationLanguage) 1.598 +{ 1.599 + *aImplementationLanguage = nsIProgrammingLanguage::CPLUSPLUS; 1.600 + return NS_OK; 1.601 +} 1.602 + 1.603 +NS_IMETHODIMP 1.604 +nsSimpleURI::GetFlags(uint32_t *aFlags) 1.605 +{ 1.606 + *aFlags = nsIClassInfo::MAIN_THREAD_ONLY; 1.607 + return NS_OK; 1.608 +} 1.609 + 1.610 +NS_IMETHODIMP 1.611 +nsSimpleURI::GetClassIDNoAlloc(nsCID *aClassIDNoAlloc) 1.612 +{ 1.613 + *aClassIDNoAlloc = kSimpleURICID; 1.614 + return NS_OK; 1.615 +} 1.616 + 1.617 +//---------------------------------------------------------------------------- 1.618 +// nsSimpleURI::nsISimpleURI 1.619 +//---------------------------------------------------------------------------- 1.620 +NS_IMETHODIMP 1.621 +nsSimpleURI::GetMutable(bool *value) 1.622 +{ 1.623 + *value = mMutable; 1.624 + return NS_OK; 1.625 +} 1.626 + 1.627 +NS_IMETHODIMP 1.628 +nsSimpleURI::SetMutable(bool value) 1.629 +{ 1.630 + NS_ENSURE_ARG(mMutable || !value); 1.631 + 1.632 + mMutable = value; 1.633 + return NS_OK; 1.634 +} 1.635 + 1.636 +//---------------------------------------------------------------------------- 1.637 +// nsSimpleURI::nsISizeOf 1.638 +//---------------------------------------------------------------------------- 1.639 + 1.640 +size_t 1.641 +nsSimpleURI::SizeOfExcludingThis(mozilla::MallocSizeOf aMallocSizeOf) const 1.642 +{ 1.643 + return mScheme.SizeOfExcludingThisIfUnshared(aMallocSizeOf) + 1.644 + mPath.SizeOfExcludingThisIfUnshared(aMallocSizeOf) + 1.645 + mRef.SizeOfExcludingThisIfUnshared(aMallocSizeOf); 1.646 +} 1.647 + 1.648 +size_t 1.649 +nsSimpleURI::SizeOfIncludingThis(mozilla::MallocSizeOf aMallocSizeOf) const { 1.650 + return aMallocSizeOf(this) + SizeOfExcludingThis(aMallocSizeOf); 1.651 +} 1.652 +