OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #ifndef EXTENSIONS_BROWSER_CONTENT_VERIFY_JOB_H_ | 5 #ifndef EXTENSIONS_BROWSER_CONTENT_VERIFY_JOB_H_ |
6 #define EXTENSIONS_BROWSER_CONTENT_VERIFY_JOB_H_ | 6 #define EXTENSIONS_BROWSER_CONTENT_VERIFY_JOB_H_ |
7 | 7 |
8 #include <string> | 8 #include <string> |
9 | 9 |
10 #include "base/callback.h" | 10 #include "base/callback.h" |
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
69 public: | 69 public: |
70 // These methods will be called inside BytesRead/DoneReading respectively. | 70 // These methods will be called inside BytesRead/DoneReading respectively. |
71 // If either return something other than NONE, then the failure callback | 71 // If either return something other than NONE, then the failure callback |
72 // will be dispatched with that reason. | 72 // will be dispatched with that reason. |
73 virtual FailureReason BytesRead(const std::string& extension_id, | 73 virtual FailureReason BytesRead(const std::string& extension_id, |
74 int count, | 74 int count, |
75 const char* data) = 0; | 75 const char* data) = 0; |
76 virtual FailureReason DoneReading(const std::string& extension_id) = 0; | 76 virtual FailureReason DoneReading(const std::string& extension_id) = 0; |
77 }; | 77 }; |
78 | 78 |
| 79 class TestObserver { |
| 80 public: |
| 81 virtual void JobStarted(const std::string& extension_id, |
| 82 const base::FilePath& relative_path) = 0; |
| 83 |
| 84 virtual void JobFinished(const std::string& extension_id, |
| 85 const base::FilePath& relative_path, |
| 86 bool failed) = 0; |
| 87 }; |
| 88 |
79 static void SetDelegateForTests(TestDelegate* delegate); | 89 static void SetDelegateForTests(TestDelegate* delegate); |
| 90 static void SetObserverForTests(TestObserver* observer); |
80 | 91 |
81 private: | 92 private: |
82 DISALLOW_COPY_AND_ASSIGN(ContentVerifyJob); | 93 DISALLOW_COPY_AND_ASSIGN(ContentVerifyJob); |
83 | 94 |
84 virtual ~ContentVerifyJob(); | 95 virtual ~ContentVerifyJob(); |
85 friend class base::RefCountedThreadSafe<ContentVerifyJob>; | 96 friend class base::RefCountedThreadSafe<ContentVerifyJob>; |
86 | 97 |
87 // Called each time we're done adding bytes for the current block, and are | 98 // Called each time we're done adding bytes for the current block, and are |
88 // ready to finish the hash operation for those bytes and make sure it | 99 // ready to finish the hash operation for those bytes and make sure it |
89 // matches what was expected for that block. Returns true if everything is | 100 // matches what was expected for that block. Returns true if everything is |
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
128 // Set to true if we detected a mismatch and called the failure callback. | 139 // Set to true if we detected a mismatch and called the failure callback. |
129 bool failed_; | 140 bool failed_; |
130 | 141 |
131 // For ensuring methods on called on the right thread. | 142 // For ensuring methods on called on the right thread. |
132 base::ThreadChecker thread_checker_; | 143 base::ThreadChecker thread_checker_; |
133 }; | 144 }; |
134 | 145 |
135 } // namespace extensions | 146 } // namespace extensions |
136 | 147 |
137 #endif // EXTENSIONS_BROWSER_CONTENT_VERIFY_JOB_H_ | 148 #endif // EXTENSIONS_BROWSER_CONTENT_VERIFY_JOB_H_ |
OLD | NEW |