@@ -5,11 +5,12 @@ namespace frontend {
55namespace {
66class FileProvider : public capnproto ::FileSender::Server {
77 public:
8- FileProvider (std::unordered_map<util::SHA256_t, std::string,
9- util::SHA256_t::Hasher>& known_files)
10- : known_files_(known_files) {}
8+ explicit FileProvider (
9+ std::unordered_map<util::SHA256_t, std::string, util::SHA256_t::Hasher>
10+ known_files)
11+ : known_files_(std::move(known_files)) {}
1112
12- kj::Promise<void > requestFile (RequestFileContext context) {
13+ kj::Promise<void > requestFile (RequestFileContext context) override {
1314 std::string path = known_files_.at (context.getParams ().getHash ());
1415 return util::File::HandleRequestFile (path,
1516 context.getParams ().getReceiver ());
@@ -23,7 +24,7 @@ class FileProvider : public capnproto::FileSender::Server {
2324} // namespace
2425
2526void File::getContentsAsString (
26- std::function<void (const std::string&)> callback) {
27+ const std::function<void (const std::string&)>& callback) {
2728 auto pf = kj::newPromiseAndFulfiller<void >();
2829 frontend_.builder_ .AddPromise (std::move (pf.promise ));
2930 frontend_.finish_builder_ .AddPromise (
@@ -71,7 +72,7 @@ void File::getContentsToFile(const std::string& path, bool overwrite,
7172 " Get file" );
7273}
7374
74- Frontend::Frontend (std::string server, int port)
75+ Frontend::Frontend (const std::string& server, int port)
7576 : client_(server, port),
7677 frontend_context_ (
7778 client_.getMain<capnproto::MainServer>()
@@ -96,7 +97,7 @@ File* Frontend::provideFile(const std::string& path,
9697 hash.ToCapnp (req.initHash ());
9798 req.setDescription (description);
9899 req.setIsExecutable (is_executable);
99- files_.push_back (File::New (req.send (), * this , is_executable));
100+ files_.push_back (File::New (req.send (), this , is_executable));
100101 return files_.back ().get ();
101102}
102103
@@ -105,16 +106,16 @@ Execution* Frontend::addExecution(const std::string& description) {
105106 req.setDescription (description);
106107 executions_.push_back (std::make_unique<Execution>(
107108 description, req.send ().then ([](auto r) { return r.getExecution (); }),
108- files_, builder_, finish_builder_, * this ));
109+ & files_, & builder_, & finish_builder_, this ));
109110 return executions_.back ().get ();
110111}
111112
112113ExecutionGroup* Frontend::addExecutionGroup (const std::string& description) {
113114 auto req = frontend_context_.addExecutionGroupRequest ();
114115 req.setDescription (description);
115116 groups_.push_back (std::make_unique<ExecutionGroup>(
116- description, req.send ().then ([](auto r) { return r.getGroup (); }), files_,
117- builder_, finish_builder_, * this ));
117+ description, req.send ().then ([](auto r) { return r.getGroup (); }),
118+ &files_, & builder_, & finish_builder_, this ));
118119 return groups_.back ().get ();
119120}
120121
@@ -139,8 +140,8 @@ Execution* ExecutionGroup::addExecution(const std::string& description) {
139140 req.setDescription (description);
140141 executions_.push_back (std::make_unique<Execution>(
141142 description_ + " of group " + description,
142- req.send ().then ([](auto r) { return r.getExecution (); }), files_,
143- builder_, finish_builder_, frontend_));
143+ req.send ().then ([](auto r) { return r.getExecution (); }), & files_,
144+ & builder_, & finish_builder_, & frontend_));
144145 return executions_.back ().get ();
145146}
146147
@@ -260,25 +261,25 @@ void Execution::setExtraTime(float extra_time) {
260261File* Execution::stdout (bool is_executable) {
261262 auto req = execution_.stdoutRequest ();
262263 req.setIsExecutable (is_executable);
263- files_.push_back (File::New (req.send (), frontend_, is_executable));
264+ files_.push_back (File::New (req.send (), & frontend_, is_executable));
264265 return files_.back ().get ();
265266}
266267
267268File* Execution::stderr (bool is_executable) {
268269 auto req = execution_.stderrRequest ();
269270 req.setIsExecutable (is_executable);
270- files_.push_back (File::New (req.send (), frontend_, is_executable));
271+ files_.push_back (File::New (req.send (), & frontend_, is_executable));
271272 return files_.back ().get ();
272273}
273274File* Execution::output (const std::string& name, bool is_executable) {
274275 auto req = execution_.outputRequest ();
275276 req.setIsExecutable (is_executable);
276277 req.setName (name);
277- files_.push_back (File::New (req.send (), frontend_, is_executable));
278+ files_.push_back (File::New (req.send (), & frontend_, is_executable));
278279 return files_.back ().get ();
279280}
280281
281- void Execution::notifyStart (std::function<void ()> callback) {
282+ void Execution::notifyStart (const std::function<void ()>& callback) {
282283 finish_builder_.AddPromise (
283284 execution_.notifyStartRequest ()
284285 .send ()
@@ -288,8 +289,8 @@ void Execution::notifyStart(std::function<void()> callback) {
288289 " Notify start " + description_);
289290}
290291
291- void Execution::getResult (std::function<void (Result)> callback,
292- std::function<void()> errored) {
292+ void Execution::getResult (const std::function<void (Result)>& callback,
293+ const std::function<void()>& errored) {
293294 auto promise = kj::newPromiseAndFulfiller<void >();
294295 builder_.AddPromise (std::move (promise.promise ));
295296 auto ff = promise.fulfiller .get ();
0 commit comments