Backed out changeset 1ecf6afb4dc7 for causing failures.
[gecko.git] / ipc / glue / URIUtils.h
blob7cb8687bbe8c449376dd1e7f09dfc2614b691b99
1 /* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
2 /* vim: set ts=8 sts=2 et sw=2 tw=80: */
3 /* This Source Code Form is subject to the terms of the Mozilla Public
4 * License, v. 2.0. If a copy of the MPL was not distributed with this
5 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
7 #ifndef mozilla_ipc_URIUtils_h
8 #define mozilla_ipc_URIUtils_h
10 #include "mozilla/ipc/URIParams.h"
11 #include "mozilla/ipc/IPDLParamTraits.h"
12 #include "nsCOMPtr.h"
13 #include "nsIURI.h"
15 namespace mozilla {
16 namespace ipc {
18 void SerializeURI(nsIURI* aURI, URIParams& aParams);
20 void SerializeURI(nsIURI* aURI, Maybe<URIParams>& aParams);
22 already_AddRefed<nsIURI> DeserializeURI(const URIParams& aParams);
24 already_AddRefed<nsIURI> DeserializeURI(const Maybe<URIParams>& aParams);
26 template <>
27 struct IPDLParamTraits<nsIURI*> {
28 static void Write(IPC::MessageWriter* aWriter, IProtocol* aActor,
29 nsIURI* aParam) {
30 Maybe<URIParams> params;
31 SerializeURI(aParam, params);
32 WriteIPDLParam(aWriter, aActor, params);
35 static bool Read(IPC::MessageReader* aReader, IProtocol* aActor,
36 RefPtr<nsIURI>* aResult) {
37 Maybe<URIParams> params;
38 if (!ReadIPDLParam(aReader, aActor, &params)) {
39 return false;
41 *aResult = DeserializeURI(params);
42 return true;
46 } // namespace ipc
47 } // namespace mozilla
49 #endif // mozilla_ipc_URIUtils_h