• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (c) 2023 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 "agent/overlay_impl.h"
17 
18 #include "base/pt_events.h"
19 #include "protocol_channel.h"
20 
21 #include "ecmascript/napi/include/dfx_jsnapi.h"
22 
23 namespace panda::ecmascript::tooling {
Dispatch(const DispatchRequest & request)24 void OverlayImpl::DispatcherImpl::Dispatch(const DispatchRequest &request)
25 {
26     Method method = GetMethodEnum(request.GetMethod());
27     LOG_DEBUGGER(INFO) << "dispatch [" << request.GetMethod() << "] to OverlayImpl";
28     switch (method) {
29         case Method::DISABLE:
30             Disable(request);
31             break;
32         default:
33             SendResponse(request, DispatchResponse::Fail("Unknown method: " + request.GetMethod()));
34             break;
35     }
36 }
37 
GetMethodEnum(const std::string & method)38 OverlayImpl::DispatcherImpl::Method OverlayImpl::DispatcherImpl::GetMethodEnum(const std::string& method)
39 {
40     if (method == "disable") {
41         return Method::DISABLE;
42     } else {
43         return Method::UNKNOWN;
44     }
45 }
46 
Disable(const DispatchRequest & request)47 void OverlayImpl::DispatcherImpl::Disable(const DispatchRequest &request)
48 {
49     DispatchResponse response = DispatchResponse::Ok();
50     SendResponse(request, response);
51 }
52 }  // namespace panda::ecmascript::tooling