1 /* 2 * Copyright (c) 2025 Huawei Device Co., Ltd. 3 * Licensed under the Apache License, Version 2.0 (the "License"); 4 * you may not use this file except in compliance with the License. 5 * You may obtain a copy of the License at 6 * 7 * http://www.apache.org/licenses/LICENSE-2.0 8 * 9 * Unless required by applicable law or agreed to in writing, software 10 * distributed under the License is distributed on an "AS IS" BASIS, 11 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 * See the License for the specific language governing permissions and 13 * limitations under the License. 14 */ 15 #ifndef PAGE_TRACE_NODE_H 16 #define PAGE_TRACE_NODE_H 17 18 #include <cstdint> 19 #include <string> 20 21 #include "faultlog_util.h" 22 23 namespace OHOS { 24 namespace HiviewDFX { 25 class PageTraceNode { 26 public: 27 PageTraceNode() = default; PageTraceNode(int32_t pid,uint64_t ts,const std::string & url,const std::string & name)28 PageTraceNode(int32_t pid, uint64_t ts, const std::string& url, const std::string& name) 29 : pid_(pid), timestamp_(ts) 30 { 31 SetPageInfo(url, name); 32 } 33 SetPageInfo(const std::string & url,const std::string & name)34 void SetPageInfo(const std::string& url, const std::string& name) 35 { 36 pagePath_ = url + (name.empty() ? "" : ":" + name); 37 } 38 ToString()39 std::string ToString() const 40 { 41 return GetFormatedTimeHHMMSS(timestamp_, true) + " " + pagePath_; 42 } 43 44 int32_t pid_{0}; 45 uint64_t timestamp_{0}; 46 std::string pagePath_; 47 }; 48 } // HiviewDFX 49 } // OHOS 50 #endif // PAGE_TRACE_NODE_H 51