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_example3.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(BundlePluginExample3);
BundlePluginExample3()25 BundlePluginExample3::BundlePluginExample3()
26 {
27 std::unique_lock<std::mutex> lock(BundleEventSourceExample::mutex_);
28 printf("BundlePluginExample3::BundlePluginExample3()\n");
29 BundleEventSourceExample::count.insert("BundlePluginExample3");
30 }
31
~BundlePluginExample3()32 BundlePluginExample3::~BundlePluginExample3()
33 {
34 std::unique_lock<std::mutex> lock(BundleEventSourceExample::mutex_);
35 printf("BundlePluginExample3::~BundlePluginExample3()\n");
36 BundleEventSourceExample::count.erase("BundlePluginExample3");
37 }
38
CanProcessEvent(std::shared_ptr<Event> event)39 bool BundlePluginExample3::CanProcessEvent(std::shared_ptr<Event> event)
40 {
41 return true;
42 }
43
OnEvent(std::shared_ptr<Event> & event)44 bool BundlePluginExample3::OnEvent(std::shared_ptr<Event>& event)
45 {
46 printf("BundlePluginExample3 OnEvent 0 tid:%d sender:%s.\n", gettid(), event->sender_.c_str());
47 event->SetValue("BundlePluginExample3", "Done");
48 return true;
49 }
50
OnLoad()51 void BundlePluginExample3::OnLoad()
52 {
53 SetVersion("BundlePluginExample3.0");
54 printf("BundlePluginExample3 OnLoad\n");
55 }
56
OnUnload()57 void BundlePluginExample3::OnUnload()
58 {
59 printf("BundlePluginExample3 OnUnload \n");
60 }
61
OnEventListeningCallback(const Event & msg)62 void BundlePluginExample3::OnEventListeningCallback(const Event &msg)
63 {
64 printf("BundlePluginExample3 OnEventListeningCallback \n");
65 GetHiviewContext()->SetHiviewProperty("BE3_Listening", "received : " + msg.eventName_, true);
66 }
67 } // namespace HiviewDFX
68 } // namespace OHOS