blob: 185b9bf24fff0da106c06b51afc6aff88fdd8fbc [file] [log] [blame]
Richard Uhlerb730b782015-07-15 16:01:58 -07001/*
2 * Copyright (C) 2015 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
17package com.android.ahat;
18
19import com.android.tools.perflib.heap.Instance;
20import com.android.tools.perflib.heap.RootObj;
21import java.io.IOException;
22import java.util.ArrayList;
23import java.util.HashSet;
24import java.util.List;
25import java.util.Set;
26
27class RootsHandler extends AhatHandler {
28 public RootsHandler(AhatSnapshot snapshot) {
29 super(snapshot);
30 }
31
32 @Override
33 public void handle(Doc doc, Query query) throws IOException {
34 doc.title("Roots");
35
36 Set<Instance> rootset = new HashSet<Instance>();
37 for (RootObj root : mSnapshot.getGCRoots()) {
38 Instance inst = root.getReferredInstance();
39 if (inst != null) {
40 rootset.add(inst);
41 }
42 }
43
44 List<Instance> roots = new ArrayList<Instance>();
45 for (Instance inst : rootset) {
46 roots.add(inst);
47 }
48 DominatedList.render(mSnapshot, doc, roots, query);
49 }
50}
51