forked from nodejs/node
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtarget_agent.h
More file actions
75 lines (61 loc) Β· 2.32 KB
/
target_agent.h
File metadata and controls
75 lines (61 loc) Β· 2.32 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
#ifndef SRC_INSPECTOR_TARGET_AGENT_H_
#define SRC_INSPECTOR_TARGET_AGENT_H_
#include <string_view>
#include <unordered_map>
#include <vector>
#include "inspector/worker_inspector.h"
#include "node/inspector/protocol/Target.h"
namespace node {
namespace inspector {
class TargetInspector;
namespace protocol {
struct TargetInfo {
std::string target_id;
std::string type;
std::string title;
std::string url;
std::shared_ptr<MainThreadHandle> worker;
bool attached;
};
class TargetAgent : public Target::Backend,
public std::enable_shared_from_this<TargetAgent> {
public:
void Wire(UberDispatcher* dispatcher);
void createAndAttachIfNecessary(std::shared_ptr<MainThreadHandle> worker,
const std::string& title,
const std::string& url);
DispatchResponse setAutoAttach(bool auto_attach,
bool wait_for_debugger_on_start) override;
void listenWorker(std::weak_ptr<WorkerManager> worker_manager);
void reset();
static std::unordered_map<int, std::shared_ptr<MainThreadHandle>>
target_session_id_worker_map_;
bool isThisThread(MainThreadHandle* worker) { return worker == main_thread_; }
private:
int getNextTargetId();
int getNextSessionId();
void targetCreated(const std::string_view target_id,
const std::string_view type,
const std::string_view title,
const std::string_view url);
void attachedToTarget(std::shared_ptr<MainThreadHandle> worker,
const std::string& target_id,
const std::string& type,
const std::string& title,
const std::string& url);
std::shared_ptr<Target::Frontend> frontend_;
std::weak_ptr<WorkerManager> worker_manager_;
static int next_session_id_;
int next_target_id_ = 1;
std::unique_ptr<WorkerManagerEventHandle> worker_event_handle_ = nullptr;
bool auto_attach_ = false;
// TODO(islandryu): If false, implement it so that each thread does not wait
// for the worker to execute.
bool wait_for_debugger_on_start_ = true;
std::vector<TargetInfo> targets_;
MainThreadHandle* main_thread_;
};
} // namespace protocol
} // namespace inspector
} // namespace node
#endif // SRC_INSPECTOR_TARGET_AGENT_H_