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 60 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
71 public: | 71 public: |
72 // These methods will be called inside BytesRead/DoneReading respectively. | 72 // These methods will be called inside BytesRead/DoneReading respectively. |
73 // If either return something other than NONE, then the failure callback | 73 // If either return something other than NONE, then the failure callback |
74 // will be dispatched with that reason. | 74 // will be dispatched with that reason. |
75 virtual FailureReason BytesRead(const std::string& extension_id, | 75 virtual FailureReason BytesRead(const std::string& extension_id, |
76 int count, | 76 int count, |
77 const char* data) = 0; | 77 const char* data) = 0; |
78 virtual FailureReason DoneReading(const std::string& extension_id) = 0; | 78 virtual FailureReason DoneReading(const std::string& extension_id) = 0; |
79 }; | 79 }; |
80 | 80 |
| 81 class TestObserver { |
| 82 public: |
| 83 virtual void JobStarted(const std::string& extension_id, |
| 84 const base::FilePath& relative_path) = 0; |
| 85 |
| 86 virtual void JobFinished(const std::string& extension_id, |
| 87 const base::FilePath& relative_path, |
| 88 bool failed) = 0; |
| 89 }; |
| 90 |
81 static void SetDelegateForTests(TestDelegate* delegate); | 91 static void SetDelegateForTests(TestDelegate* delegate); |
| 92 static void SetObserverForTests(TestObserver* observer); |
82 | 93 |
83 private: | 94 private: |
84 DISALLOW_COPY_AND_ASSIGN(ContentVerifyJob); | 95 DISALLOW_COPY_AND_ASSIGN(ContentVerifyJob); |
85 | 96 |
86 virtual ~ContentVerifyJob(); | 97 virtual ~ContentVerifyJob(); |
87 friend class base::RefCountedThreadSafe<ContentVerifyJob>; | 98 friend class base::RefCountedThreadSafe<ContentVerifyJob>; |
88 | 99 |
89 // Called each time we're done adding bytes for the current block, and are | 100 // Called each time we're done adding bytes for the current block, and are |
90 // ready to finish the hash operation for those bytes and make sure it | 101 // ready to finish the hash operation for those bytes and make sure it |
91 // matches what was expected for that block. Returns true if everything is | 102 // 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... |
130 // Set to true if we detected a mismatch and called the failure callback. | 141 // Set to true if we detected a mismatch and called the failure callback. |
131 bool failed_; | 142 bool failed_; |
132 | 143 |
133 // For ensuring methods on called on the right thread. | 144 // For ensuring methods on called on the right thread. |
134 base::ThreadChecker thread_checker_; | 145 base::ThreadChecker thread_checker_; |
135 }; | 146 }; |
136 | 147 |
137 } // namespace extensions | 148 } // namespace extensions |
138 | 149 |
139 #endif // EXTENSIONS_BROWSER_CONTENT_VERIFY_JOB_H_ | 150 #endif // EXTENSIONS_BROWSER_CONTENT_VERIFY_JOB_H_ |
OLD | NEW |