1 /* 2 * Copyright (C) 2016 The Android Open Source Project 3 * 4 * Licensed under the Apache License, Version 2.0 (the "License"); 5 * you may not use this file except in compliance with the License. 6 * You may obtain a copy of the License at 7 * 8 * http://www.apache.org/licenses/LICENSE-2.0 9 * 10 * Unless required by applicable law or agreed to in writing, software 11 * distributed under the License is distributed on an "AS IS" BASIS, 12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 * See the License for the specific language governing permissions and 14 * limitations under the License. 15 */ 16 17 package com.android.ahat.heapdump; 18 19 import java.util.Collections; 20 import java.util.List; 21 22 /** 23 * Generic PlaceHolder instance to take the place of a real AhatInstance for 24 * the purposes of displaying diffs. 25 * 26 * This should be created through a call to AhatInstance.newPlaceHolder(); 27 */ 28 class AhatPlaceHolderInstance extends AhatInstance { AhatPlaceHolderInstance(AhatInstance baseline)29 AhatPlaceHolderInstance(AhatInstance baseline) { 30 super(-1); 31 setBaseline(baseline); 32 baseline.setBaseline(this); 33 } 34 getSize()35 @Override public Size getSize() { 36 return Size.ZERO; 37 } 38 getExtraJavaSize()39 @Override long getExtraJavaSize() { 40 return 0; 41 } 42 getRetainedSize(AhatHeap heap)43 @Override public Size getRetainedSize(AhatHeap heap) { 44 return Size.ZERO; 45 } 46 getTotalRetainedSize()47 @Override public Size getTotalRetainedSize() { 48 return Size.ZERO; 49 } 50 getHeap()51 @Override public AhatHeap getHeap() { 52 return getBaseline().getHeap().getBaseline(); 53 } 54 getClassName()55 @Override public String getClassName() { 56 return getBaseline().getClassName(); 57 } 58 asString(int maxChars)59 @Override public String asString(int maxChars) { 60 return getBaseline().asString(maxChars); 61 } 62 toString()63 @Override public String toString() { 64 return getBaseline().toString(); 65 } 66 isPlaceHolder()67 @Override public boolean isPlaceHolder() { 68 return true; 69 } 70 71 @Override getReferences()72 Iterable<Reference> getReferences() { 73 List<Reference> refs = Collections.emptyList(); 74 return refs; 75 } 76 } 77