blob: ee9eddab96157dc6455ecf995e0653a50aabac02 [file] [log] [blame]
Andreas Gampe04bbb5b2017-01-19 17:49:03 +00001/*
2 * Copyright (C) 2017 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#include "runtime_callbacks.h"
18
19#include <algorithm>
20
Andreas Gampe0f01b582017-01-18 15:22:37 -080021#include "class_linker.h"
Andreas Gampe04bbb5b2017-01-19 17:49:03 +000022#include "thread.h"
23
24namespace art {
25
26void RuntimeCallbacks::AddThreadLifecycleCallback(ThreadLifecycleCallback* cb) {
27 thread_callbacks_.push_back(cb);
28}
29
30void RuntimeCallbacks::RemoveThreadLifecycleCallback(ThreadLifecycleCallback* cb) {
31 auto it = std::find(thread_callbacks_.begin(), thread_callbacks_.end(), cb);
32 if (it != thread_callbacks_.end()) {
33 thread_callbacks_.erase(it);
34 }
35}
36
37void RuntimeCallbacks::ThreadStart(Thread* self) {
38 for (ThreadLifecycleCallback* cb : thread_callbacks_) {
39 cb->ThreadStart(self);
40 }
41}
42
43void RuntimeCallbacks::ThreadDeath(Thread* self) {
44 for (ThreadLifecycleCallback* cb : thread_callbacks_) {
45 cb->ThreadDeath(self);
46 }
47}
48
Andreas Gampe0f01b582017-01-18 15:22:37 -080049void RuntimeCallbacks::AddClassLoadCallback(ClassLoadCallback* cb) {
50 class_callbacks_.push_back(cb);
51}
52
53void RuntimeCallbacks::RemoveClassLoadCallback(ClassLoadCallback* cb) {
54 auto it = std::find(class_callbacks_.begin(), class_callbacks_.end(), cb);
55 if (it != class_callbacks_.end()) {
56 class_callbacks_.erase(it);
57 }
58}
59
60void RuntimeCallbacks::ClassLoad(Handle<mirror::Class> klass) {
61 for (ClassLoadCallback* cb : class_callbacks_) {
62 cb->ClassLoad(klass);
63 }
64}
65
66void RuntimeCallbacks::ClassPrepare(Handle<mirror::Class> temp_klass, Handle<mirror::Class> klass) {
67 for (ClassLoadCallback* cb : class_callbacks_) {
68 cb->ClassPrepare(temp_klass, klass);
69 }
70}
71
Andreas Gampe04bbb5b2017-01-19 17:49:03 +000072} // namespace art