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