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 <stdint.h> | 8 #include <stdint.h> |
9 | 9 |
10 #include <memory> | 10 #include <memory> |
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
42 MISSING_ALL_HASHES, | 42 MISSING_ALL_HASHES, |
43 | 43 |
44 // Failed because this file wasn't found in the list of expected hashes. | 44 // Failed because this file wasn't found in the list of expected hashes. |
45 NO_HASHES_FOR_FILE, | 45 NO_HASHES_FOR_FILE, |
46 | 46 |
47 // Some of the content read did not match the expected hash. | 47 // Some of the content read did not match the expected hash. |
48 HASH_MISMATCH, | 48 HASH_MISMATCH, |
49 | 49 |
50 FAILURE_REASON_MAX | 50 FAILURE_REASON_MAX |
51 }; | 51 }; |
52 typedef base::Callback<void(FailureReason)> FailureCallback; | 52 using FailureCallback = base::OnceCallback<void(FailureReason)>; |
53 | 53 |
54 // The |failure_callback| will be called at most once if there was a failure. | 54 // The |failure_callback| will be called at most once if there was a failure. |
55 ContentVerifyJob(ContentHashReader* hash_reader, | 55 ContentVerifyJob(ContentHashReader* hash_reader, |
56 const FailureCallback& failure_callback); | 56 FailureCallback failure_callback); |
57 | 57 |
58 // This begins the process of getting expected hashes, so it should be called | 58 // This begins the process of getting expected hashes, so it should be called |
59 // as early as possible. | 59 // as early as possible. |
60 void Start(); | 60 void Start(); |
61 | 61 |
62 // Call this to add more bytes to verify. If at any point the read bytes | 62 // Call this to add more bytes to verify. If at any point the read bytes |
63 // don't match the expected hashes, this will dispatch the failure | 63 // don't match the expected hashes, this will dispatch the failure |
64 // callback. The failure callback will only be run once even if more bytes | 64 // callback. The failure callback will only be run once even if more bytes |
65 // are read. Make sure to call DoneReading so that any final bytes that were | 65 // are read. Make sure to call DoneReading so that any final bytes that were |
66 // read that didn't align exactly on a block size boundary get their hash | 66 // read that didn't align exactly on a block size boundary get their hash |
(...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
148 | 148 |
149 // For ensuring methods on called on the right thread. | 149 // For ensuring methods on called on the right thread. |
150 base::ThreadChecker thread_checker_; | 150 base::ThreadChecker thread_checker_; |
151 | 151 |
152 DISALLOW_COPY_AND_ASSIGN(ContentVerifyJob); | 152 DISALLOW_COPY_AND_ASSIGN(ContentVerifyJob); |
153 }; | 153 }; |
154 | 154 |
155 } // namespace extensions | 155 } // namespace extensions |
156 | 156 |
157 #endif // EXTENSIONS_BROWSER_CONTENT_VERIFY_JOB_H_ | 157 #endif // EXTENSIONS_BROWSER_CONTENT_VERIFY_JOB_H_ |
OLD | NEW |