#ifdef UNSAFE_BUFFERS_BUILD
#pragma allow_unsafe_buffers
#endif
#include "extensions/browser/content_verifier/content_verify_job.h"
#include <algorithm>
#include "base/functional/bind.h"
#include "base/lazy_instance.h"
#include "base/memory/raw_ptr.h"
#include "base/metrics/histogram_functions.h"
#include "base/metrics/histogram_macros.h"
#include "base/task/thread_pool.h"
#include "base/timer/elapsed_timer.h"
#include "build/buildflag.h"
#include "content/public/browser/browser_thread.h"
#include "crypto/secure_hash.h"
#include "crypto/sha2.h"
#include "extensions/browser/content_hash_reader.h"
#include "extensions/browser/content_verifier/content_hash.h"
#include "extensions/browser/content_verifier/content_verifier.h"
#include "extensions/common/constants.h"
#if BUILDFLAG(IS_MAC)
#include "extensions/common/extension_features.h"
#endif
namespace extensions {
namespace {
bool g_ignore_verification_for_tests = …;
base::LazyInstance<scoped_refptr<ContentVerifyJob::TestObserver>>::Leaky
g_content_verify_job_test_observer = …;
scoped_refptr<ContentVerifyJob::TestObserver> GetTestObserver() { … }
class ScopedElapsedTimer { … };
bool IsIgnorableReadError(MojoResult read_result) { … }
}
ContentVerifyJob::ContentVerifyJob(const ExtensionId& extension_id,
const base::FilePath& extension_root,
const base::FilePath& relative_path)
: … { … }
ContentVerifyJob::~ContentVerifyJob() = default;
void ContentVerifyJob::Start(ContentVerifier* verifier,
const base::Version& extension_version,
int manifest_version,
FailureCallback failure_callback) { … }
void ContentVerifyJob::DidCreateContentHashOnIO(
scoped_refptr<const ContentHash> content_hash) { … }
void ContentVerifyJob::StartWithContentHash(
scoped_refptr<const ContentHash> content_hash) { … }
void ContentVerifyJob::BytesRead(const char* data,
int count,
MojoResult read_result) { … }
void ContentVerifyJob::DoneReading() { … }
void ContentVerifyJob::OnDoneReadingAndHashesReady() { … }
void ContentVerifyJob::OnHashMismatch() { … }
void ContentVerifyJob::BytesReadImpl(const char* data,
int count,
MojoResult read_result) { … }
bool ContentVerifyJob::FinishBlock() { … }
void ContentVerifyJob::SetIgnoreVerificationForTests(bool value) { … }
void ContentVerifyJob::SetObserverForTests(
scoped_refptr<TestObserver> observer) { … }
void ContentVerifyJob::DispatchFailureCallback(FailureReason reason) { … }
void ContentVerifyJob::ReportJobFinished(FailureReason reason) { … }
}