• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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 "ordered_event_handler.h"
17 #include "common_event_control_manager.h"
18 #include "event_log_wrapper.h"
19 
20 namespace OHOS {
21 namespace EventFwk {
OrderedEventHandler(const std::shared_ptr<EventRunner> & runner,const std::shared_ptr<CommonEventControlManager> & controlManager)22 OrderedEventHandler::OrderedEventHandler(
23     const std::shared_ptr<EventRunner> &runner, const std::shared_ptr<CommonEventControlManager> &controlManager)
24     : EventHandler(runner), controlManager_(controlManager)
25 {
26     EVENT_LOGD("OrderedEventHandler is created");
27 }
28 
~OrderedEventHandler()29 OrderedEventHandler::~OrderedEventHandler()
30 {
31     EVENT_LOGD("OrderedEventHandler is destroyed");
32 }
33 
ProcessEvent(const InnerEvent::Pointer & event)34 void OrderedEventHandler::ProcessEvent(const InnerEvent::Pointer &event)
35 {
36     if (!controlManager_) {
37         EVENT_LOGE("CommonEventControlManager ptr is nullptr");
38         return;
39     }
40     switch (event->GetInnerEventId()) {
41         case ORDERED_EVENT_START: {
42             EVENT_LOGI("ORDERED_EVENT_START");
43             controlManager_->ProcessNextOrderedEvent(true);
44             break;
45         }
46 
47         case ORDERED_EVENT_TIMEOUT: {
48             EVENT_LOGI("ORDERED_EVENT_TIMEOUT");
49             controlManager_->CurrentOrderedEventTimeout(true);
50             break;
51         }
52 
53         default: {
54             EVENT_LOGW("the eventId is not supported");
55             break;
56         }
57     }
58 }
59 }  // namespace EventFwk
60 }  // namespace OHOS
61