sapling/eden/fs/store/DiffContext.cpp
Chad Austin fc07c3b6e6 add an ObjectFetchContext interface
Summary:
Add a fetch context interface to ObjectStore that allows tracing cache
hits, backing store fetches, and fetch durations in the context of a
diff or checkout operation.

Reviewed By: simpkins

Differential Revision: D19135625

fbshipit-source-id: d0d8f134b1c89f7ba4971a404a46a69a1704ba5c
2020-02-05 13:15:01 -08:00

64 lines
1.7 KiB
C++

/*
* Copyright (c) Facebook, Inc. and its affiliates.
*
* This software may be used and distributed according to the terms of the
* GNU General Public License version 2.
*/
#include "eden/fs/store/DiffContext.h"
#include <thrift/lib/cpp2/async/ResponseChannel.h>
#include "eden/fs/model/git/GitIgnoreStack.h"
#include "eden/fs/model/git/TopLevelIgnores.h"
#include "eden/fs/store/IObjectStore.h"
using apache::thrift::ResponseChannelRequest;
namespace facebook {
namespace eden {
DiffContext::DiffContext(
DiffCallback* cb,
bool listIgnored,
const ObjectStore* os,
std::unique_ptr<TopLevelIgnores> topLevelIgnores,
LoadFileFunction loadFileContentsFromPath,
ResponseChannelRequest* request)
: callback{cb},
store{os},
listIgnored{listIgnored},
topLevelIgnores_(std::move(topLevelIgnores)),
loadFileContentsFromPath_{loadFileContentsFromPath},
request_{request} {}
DiffContext::DiffContext(DiffCallback* cb, const ObjectStore* os)
: callback{cb},
store{os},
listIgnored{true},
topLevelIgnores_{std::unique_ptr<TopLevelIgnores>()},
loadFileContentsFromPath_{nullptr},
request_{nullptr} {};
DiffContext::~DiffContext() = default;
const GitIgnoreStack* DiffContext::getToplevelIgnore() const {
return topLevelIgnores_->getStack();
}
DiffContext::LoadFileFunction DiffContext::getLoadFileContentsFromPath() const {
return loadFileContentsFromPath_;
}
bool DiffContext::isCancelled() const {
// If request_ is null we do not have an associated thrift
// request that can be cancelled, so we are always still active
if (request_ && !request_->isActive()) {
return true;
}
return false;
}
} // namespace eden
} // namespace facebook