1 /*
2  * Copyright (c) 2021 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 "bundle_plugin_example2.h"
17 
18 #include "bundle_event_source_example.h"
19 #include "pipeline.h"
20 #include "plugin_factory.h"
21 
22 namespace OHOS {
23 namespace HiviewDFX {
24 REGISTER_PROXY_WITH_LOADED(BundlePluginExample2);
BundlePluginExample2()25 BundlePluginExample2::BundlePluginExample2()
26 {
27     std::unique_lock<std::mutex> lock(BundleEventSourceExample::mutex_);
28     printf("BundlePluginExample2::BundlePluginExample2()\n");
29     BundleEventSourceExample::count.insert("BundlePluginExample2");
30 }
31 
~BundlePluginExample2()32 BundlePluginExample2::~BundlePluginExample2()
33 {
34     std::unique_lock<std::mutex> lock(BundleEventSourceExample::mutex_);
35     printf("BundlePluginExample2::~BundlePluginExample2()\n");
36     BundleEventSourceExample::count.erase("BundlePluginExample2");
37 }
38 
CanProcessEvent(std::shared_ptr<Event> event)39 bool BundlePluginExample2::CanProcessEvent(std::shared_ptr<Event> event)
40 {
41     return true;
42 }
43 
OnEvent(std::shared_ptr<Event> & event)44 bool BundlePluginExample2::OnEvent(std::shared_ptr<Event>& event)
45 {
46     printf("EventProcessorExample3 OnEvent 0 tid:%d sender:%s.\n", gettid(), event->sender_.c_str());
47     GetHiviewContext()->SetHiviewProperty("BE2_OnEvent", "received : " + event->eventName_, true);
48     return true;
49 }
OnLoad()50 void BundlePluginExample2::OnLoad()
51 {
52     SetVersion("BundlePluginExample2.0");
53     printf("BundlePluginExample2 OnLoad \n");
54     GetHiviewContext()->AppendPluginToPipeline(GetName(), "NormalPipeline");
55 }
56 
OnUnload()57 void BundlePluginExample2::OnUnload()
58 {
59     printf("BundlePluginExample2 OnUnload \n");
60 }
61 } // namespace HiviewDFX
62 } // namespace OHOS