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 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
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 |
67 // checked as well. | 67 // checked as well. |
68 void BytesRead(int count, const char* data); | 68 void BytesRead(int count, const char* data); |
69 | 69 |
70 // Call once when finished adding bytes via BytesRead. | 70 // Call once when finished adding bytes via BytesRead. |
71 void DoneReading(); | 71 void DoneReading(); |
72 | 72 |
73 class TestDelegate { | 73 class TestDelegate { |
74 public: | 74 public: |
| 75 virtual ~TestDelegate() {} |
| 76 |
75 // These methods will be called inside BytesRead/DoneReading respectively. | 77 // These methods will be called inside BytesRead/DoneReading respectively. |
76 // If either return something other than NONE, then the failure callback | 78 // If either return something other than NONE, then the failure callback |
77 // will be dispatched with that reason. | 79 // will be dispatched with that reason. |
78 virtual FailureReason BytesRead(const std::string& extension_id, | 80 virtual FailureReason BytesRead(const std::string& extension_id, |
79 int count, | 81 int count, |
80 const char* data) = 0; | 82 const char* data) = 0; |
81 virtual FailureReason DoneReading(const std::string& extension_id) = 0; | 83 virtual FailureReason DoneReading(const std::string& extension_id) = 0; |
82 }; | 84 }; |
83 | 85 |
84 class TestObserver { | 86 class TestObserver { |
85 public: | 87 public: |
86 virtual void JobStarted(const std::string& extension_id, | 88 virtual void JobStarted(const std::string& extension_id, |
87 const base::FilePath& relative_path) = 0; | 89 const base::FilePath& relative_path) = 0; |
88 | 90 |
89 virtual void JobFinished(const std::string& extension_id, | 91 virtual void JobFinished(const std::string& extension_id, |
90 const base::FilePath& relative_path, | 92 const base::FilePath& relative_path, |
91 bool failed) = 0; | 93 FailureReason failure_reason) = 0; |
92 }; | 94 }; |
93 | 95 |
94 // Note: having interleaved delegates is not supported. | 96 // Note: having interleaved delegates is not supported. |
95 static void SetDelegateForTests(TestDelegate* delegate); | 97 static void SetDelegateForTests(TestDelegate* delegate); |
96 | 98 |
97 static void SetObserverForTests(TestObserver* observer); | 99 static void SetObserverForTests(TestObserver* observer); |
98 | 100 |
99 private: | 101 private: |
100 virtual ~ContentVerifyJob(); | 102 virtual ~ContentVerifyJob(); |
101 friend class base::RefCountedThreadSafe<ContentVerifyJob>; | 103 friend class base::RefCountedThreadSafe<ContentVerifyJob>; |
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
146 | 148 |
147 // For ensuring methods on called on the right thread. | 149 // For ensuring methods on called on the right thread. |
148 base::ThreadChecker thread_checker_; | 150 base::ThreadChecker thread_checker_; |
149 | 151 |
150 DISALLOW_COPY_AND_ASSIGN(ContentVerifyJob); | 152 DISALLOW_COPY_AND_ASSIGN(ContentVerifyJob); |
151 }; | 153 }; |
152 | 154 |
153 } // namespace extensions | 155 } // namespace extensions |
154 | 156 |
155 #endif // EXTENSIONS_BROWSER_CONTENT_VERIFY_JOB_H_ | 157 #endif // EXTENSIONS_BROWSER_CONTENT_VERIFY_JOB_H_ |
OLD | NEW |