forked from nodejs/node
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathstorage_agent.cc
More file actions
32 lines (28 loc) · 1.05 KB
/
Copy pathstorage_agent.cc
File metadata and controls
32 lines (28 loc) · 1.05 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
#include "inspector/storage_agent.h"
#include <string>
#include "env-inl.h"
#include "node_url.h"
namespace node {
namespace inspector {
namespace protocol {
StorageAgent::StorageAgent(Environment* env) : env_(env) {}
StorageAgent::~StorageAgent() {}
void StorageAgent::Wire(protocol::UberDispatcher* dispatcher) {
frontend_ =
std::make_unique<protocol::Storage::Frontend>(dispatcher->channel());
protocol::Storage::Dispatcher::wire(dispatcher, this);
}
DispatchResponse StorageAgent::getStorageKey(
std::optional<protocol::String> frameId, protocol::String* storageKey) {
auto local_storage_file = env_->options()->localstorage_file;
*storageKey = node::url::FromFilePath(to_absolute_path(local_storage_file));
return protocol::DispatchResponse::Success();
}
std::string StorageAgent::to_absolute_path(const std::filesystem::path& input) {
std::filesystem::path abs =
std::filesystem::weakly_canonical(std::filesystem::absolute(input));
return abs.generic_string();
}
} // namespace protocol
} // namespace inspector
} // namespace node