Chromium Code Reviews| Index: extensions/browser/content_verify_job.cc |
| diff --git a/extensions/browser/content_verify_job.cc b/extensions/browser/content_verify_job.cc |
| new file mode 100644 |
| index 0000000000000000000000000000000000000000..8a72e3bc94c3cc49139b9d49430afa4966156ecf |
| --- /dev/null |
| +++ b/extensions/browser/content_verify_job.cc |
| @@ -0,0 +1,61 @@ |
| +// Copyright 2014 The Chromium Authors. All rights reserved. |
| +// Use of this source code is governed by a BSD-style license that can be |
| +// found in the LICENSE file. |
| + |
| +#include "extensions/browser/content_verify_job.h" |
| + |
| +#include <algorithm> |
| + |
| +#include "base/stl_util.h" |
| +#include "base/task_runner_util.h" |
| +#include "content/public/browser/browser_thread.h" |
| + |
| +namespace extensions { |
| + |
| +namespace { |
| + |
| +ContentVerifyJob::TestDelegate* g_test_delegate = NULL; |
| + |
| +} // namespace |
| + |
| +ContentVerifyJob::ContentVerifyJob(const std::string& extension_id, |
| + const FailureCallback& failure_callback) |
| + : extension_id_(extension_id), failure_callback_(failure_callback) { |
| +} |
| + |
| +ContentVerifyJob::~ContentVerifyJob() { |
| +} |
| + |
| +void ContentVerifyJob::Start() { |
| +} |
| + |
| +void ContentVerifyJob::BytesRead(int count, const char* data) { |
| + if (g_test_delegate) { |
| + FailureReason reason = |
| + g_test_delegate->BytesRead(extension_id_, count, data); |
| + if (reason != NONE) |
| + return DispatchFailureCallback(reason); |
|
Yoyo Zhou
2014/05/07 02:25:59
Why are we returning from a void?
asargent_no_longer_on_chrome
2014/05/07 06:56:42
Just a shorthand for:
if (reason != NONE) {
Dis
|
| + } |
| +} |
| + |
| +void ContentVerifyJob::DoneReading() { |
| + if (g_test_delegate) { |
| + FailureReason reason = g_test_delegate->DoneReading(extension_id_); |
| + if (reason != NONE) |
| + return DispatchFailureCallback(reason); |
| + } |
| +} |
| + |
| +// static |
| +void ContentVerifyJob::SetDelegateForTests(TestDelegate* delegate) { |
| + g_test_delegate = delegate; |
| +} |
| + |
| +void ContentVerifyJob::DispatchFailureCallback(FailureReason reason) { |
| + if (!failure_callback_.is_null()) { |
| + failure_callback_.Run(reason); |
| + failure_callback_.Reset(); |
| + } |
| +} |
| + |
| +} // namespace extensions |