• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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 
16 #include "memory_caller_parcelable.h"
17 
18 namespace OHOS::HiviewDFX {
Marshalling(Parcel & outParcel) const19 bool MemoryCallerParcelable::Marshalling(Parcel& outParcel) const
20 {
21     if (!outParcel.WriteInt32(memoryCaller_.pid)) {
22         return false;
23     }
24     if (!outParcel.WriteString(memoryCaller_.resourceType)) {
25         return false;
26     }
27     if (!outParcel.WriteInt32(memoryCaller_.limitValue)) {
28         return false;
29     }
30     if (!outParcel.WriteBool(memoryCaller_.enabledDebugLog)) {
31         return false;
32     }
33     return true;
34 }
35 
Unmarshalling(Parcel & inParcel)36 MemoryCallerParcelable* MemoryCallerParcelable::Unmarshalling(Parcel& inParcel)
37 {
38     UCollectClient::MemoryCaller memoryCaller;
39     if (!inParcel.ReadInt32(memoryCaller.pid)) {
40         return nullptr;
41     }
42     if (!inParcel.ReadString(memoryCaller.resourceType)) {
43         return nullptr;
44     }
45     if (!inParcel.ReadInt32(memoryCaller.limitValue)) {
46         return nullptr;
47     }
48     if (!inParcel.ReadBool(memoryCaller.enabledDebugLog)) {
49         return nullptr;
50     }
51     return new(std::nothrow) MemoryCallerParcelable(memoryCaller);
52 }
53 
GetMemoryCaller() const54 UCollectClient::MemoryCaller MemoryCallerParcelable::GetMemoryCaller() const
55 {
56     return memoryCaller_;
57 }
58 } // namespace OHOS::HiviewDFX