Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(8)

Unified Diff: extensions/browser/content_verify_job.cc

Issue 266963003: Beginning of support for extension content verification (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: merged latest trunk Created 6 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « extensions/browser/content_verify_job.h ('k') | extensions/browser/extension_protocols.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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..399f3636eeffebfebfe27418ec6c23a9c082e179
--- /dev/null
+++ b/extensions/browser/content_verify_job.cc
@@ -0,0 +1,69 @@
+// 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) {
+ // It's ok for this object to be constructed on a different thread from where
+ // it's used.
+ thread_checker_.DetachFromThread();
+}
+
+ContentVerifyJob::~ContentVerifyJob() {
+}
+
+void ContentVerifyJob::Start() {
+ DCHECK(thread_checker_.CalledOnValidThread());
+}
+
+void ContentVerifyJob::BytesRead(int count, const char* data) {
+ DCHECK(thread_checker_.CalledOnValidThread());
+ if (g_test_delegate) {
+ FailureReason reason =
+ g_test_delegate->BytesRead(extension_id_, count, data);
+ if (reason != NONE)
+ return DispatchFailureCallback(reason);
+ }
+}
+
+void ContentVerifyJob::DoneReading() {
+ DCHECK(thread_checker_.CalledOnValidThread());
+ if (g_test_delegate) {
+ FailureReason reason = g_test_delegate->DoneReading(extension_id_);
+ if (reason != NONE) {
+ DispatchFailureCallback(reason);
+ return;
+ }
+ }
+}
+
+// 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
« no previous file with comments | « extensions/browser/content_verify_job.h ('k') | extensions/browser/extension_protocols.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698