Bug 1885602 - Part 5: Implement navigating to the SUMO help topic from the menu heade...
[gecko.git] / dom / ipc / DocShellMessageUtils.cpp
blob011abe3246cd425ff7ebd933b46a37125958ccc9
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 #include "mozilla/dom/DocShellMessageUtils.h"
8 #include "mozilla/dom/DOMTypes.h"
9 #include "mozilla/ipc/IPDLParamTraits.h"
10 #include "nsSerializationHelper.h"
12 namespace IPC {
14 void ParamTraits<nsDocShellLoadState*>::Write(IPC::MessageWriter* aWriter,
15 nsDocShellLoadState* aParam) {
16 MOZ_RELEASE_ASSERT(aParam);
17 WriteParam(aWriter, aParam->Serialize(aWriter->GetActor()));
20 bool ParamTraits<nsDocShellLoadState*>::Read(
21 IPC::MessageReader* aReader, RefPtr<nsDocShellLoadState>* aResult) {
22 mozilla::dom::DocShellLoadStateInit loadState;
23 if (!ReadParam(aReader, &loadState)) {
24 return false;
27 // Assert if we somehow don't have a URI in our IPDL type, because we can't
28 // construct anything out of it. This mimics the assertion in the constructor
29 // for nsDocShellLoadState, but makes it clearer that the
30 // DocShellLoadStateInit IPC object can't be clearly converted into a
31 // nsDocShellLoadState.
32 if (!loadState.URI()) {
33 MOZ_ASSERT_UNREACHABLE("no URI in load state from IPC");
34 return false;
37 bool readSuccess = false;
38 RefPtr result =
39 new nsDocShellLoadState(loadState, aReader->GetActor(), &readSuccess);
40 if (readSuccess) {
41 *aResult = result.forget();
43 return readSuccess;
46 } // namespace IPC