PageLoadEventUtils.h (1480B)
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/. */ 6 7 #ifndef mozilla_dom_page_load_event_utils_h__ 8 #define mozilla_dom_page_load_event_utils_h__ 9 10 #include "ipc/IPCMessageUtils.h" 11 #include "mozilla/PageloadEvent.h" 12 13 namespace IPC { 14 15 // Helper functions for serializing the parts of PageLoadExtra that come from 16 // the content process before we send it over to the parent process. 17 template <> 18 struct ParamTraits<mozilla::performance::pageload_event::PageloadEventData> { 19 typedef mozilla::performance::pageload_event::PageloadEventData paramType; 20 21 static void Write(MessageWriter* aWriter, const paramType& aParam) { 22 #define WRITE_METRIC_PARAM(name, type) WriteParam(aWriter, aParam.name); 23 FOR_EACH_PAGELOAD_METRIC(WRITE_METRIC_PARAM) 24 #undef WRITE_METRIC_PARAM 25 WriteParam(aWriter, aParam.mDomain); 26 } 27 28 static bool Read(MessageReader* aReader, paramType* aResult) { 29 bool ok = true; 30 #define READ_METRIC_PARAM(name, type) \ 31 ok = ok && ReadParam(aReader, &aResult->name); 32 FOR_EACH_PAGELOAD_METRIC(READ_METRIC_PARAM) 33 #undef READ_METRIC_PARAM 34 ok = ok && ReadParam(aReader, &aResult->mDomain); 35 return ok; 36 } 37 }; 38 39 } // namespace IPC 40 41 #endif // mozilla_dom_page_load_event_utils_h__