OLD | NEW |
1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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 COMPONENTS_COMPONENT_UPDATER_TEST_URL_REQUEST_POST_INTERCEPTOR_H_ | 5 #ifndef COMPONENTS_COMPONENT_UPDATER_TEST_URL_REQUEST_POST_INTERCEPTOR_H_ |
6 #define COMPONENTS_COMPONENT_UPDATER_TEST_URL_REQUEST_POST_INTERCEPTOR_H_ | 6 #define COMPONENTS_COMPONENT_UPDATER_TEST_URL_REQUEST_POST_INTERCEPTOR_H_ |
7 | 7 |
| 8 #include <stdint.h> |
8 #include <map> | 9 #include <map> |
9 #include <queue> | 10 #include <queue> |
10 #include <string> | 11 #include <string> |
11 #include <utility> | 12 #include <utility> |
12 #include <vector> | 13 #include <vector> |
13 | 14 |
14 #include "base/basictypes.h" | 15 #include "base/macros.h" |
15 #include "base/memory/ref_counted.h" | 16 #include "base/memory/ref_counted.h" |
16 #include "base/synchronization/lock.h" | 17 #include "base/synchronization/lock.h" |
17 #include "url/gurl.h" | 18 #include "url/gurl.h" |
18 | 19 |
19 namespace base { | 20 namespace base { |
20 class FilePath; | 21 class FilePath; |
21 class SequencedTaskRunner; | 22 class SequencedTaskRunner; |
22 } | 23 } |
23 | 24 |
24 namespace net { | 25 namespace net { |
25 class URLRequest; | 26 class URLRequest; |
26 } | 27 } |
27 | 28 |
28 namespace component_updater { | 29 namespace component_updater { |
29 | 30 |
30 // component 1 has extension id "jebgalgnebhfojomionfpkfelancnnkf", and | 31 // component 1 has extension id "jebgalgnebhfojomionfpkfelancnnkf", and |
31 // the RSA public key the following hash: | 32 // the RSA public key the following hash: |
32 const uint8 jebg_hash[] = {0x94, 0x16, 0x0b, 0x6d, 0x41, 0x75, 0xe9, 0xec, | 33 const uint8_t jebg_hash[] = {0x94, 0x16, 0x0b, 0x6d, 0x41, 0x75, 0xe9, 0xec, |
33 0x8e, 0xd5, 0xfa, 0x54, 0xb0, 0xd2, 0xdd, 0xa5, | 34 0x8e, 0xd5, 0xfa, 0x54, 0xb0, 0xd2, 0xdd, 0xa5, |
34 0x6e, 0x05, 0x6b, 0xe8, 0x73, 0x47, 0xf6, 0xc4, | 35 0x6e, 0x05, 0x6b, 0xe8, 0x73, 0x47, 0xf6, 0xc4, |
35 0x11, 0x9f, 0xbc, 0xb3, 0x09, 0xb3, 0x5b, 0x40}; | 36 0x11, 0x9f, 0xbc, 0xb3, 0x09, 0xb3, 0x5b, 0x40}; |
36 // component 2 has extension id "abagagagagagagagagagagagagagagag", and | 37 // component 2 has extension id "abagagagagagagagagagagagagagagag", and |
37 // the RSA public key the following hash: | 38 // the RSA public key the following hash: |
38 const uint8 abag_hash[] = {0x01, 0x06, 0x06, 0x06, 0x06, 0x06, 0x06, 0x06, | 39 const uint8_t abag_hash[] = {0x01, 0x06, 0x06, 0x06, 0x06, 0x06, 0x06, 0x06, |
39 0x06, 0x06, 0x06, 0x06, 0x06, 0x06, 0x06, 0x06, | 40 0x06, 0x06, 0x06, 0x06, 0x06, 0x06, 0x06, 0x06, |
40 0x06, 0x06, 0x06, 0x06, 0x06, 0x06, 0x06, 0x06, | 41 0x06, 0x06, 0x06, 0x06, 0x06, 0x06, 0x06, 0x06, |
41 0x06, 0x06, 0x06, 0x06, 0x06, 0x06, 0x06, 0x01}; | 42 0x06, 0x06, 0x06, 0x06, 0x06, 0x06, 0x06, 0x01}; |
42 // component 3 has extension id "ihfokbkgjpifnbbojhneepfflplebdkc", and | 43 // component 3 has extension id "ihfokbkgjpifnbbojhneepfflplebdkc", and |
43 // the RSA public key the following hash: | 44 // the RSA public key the following hash: |
44 const uint8 ihfo_hash[] = {0x87, 0x5e, 0xa1, 0xa6, 0x9f, 0x85, 0xd1, 0x1e, | 45 const uint8_t ihfo_hash[] = {0x87, 0x5e, 0xa1, 0xa6, 0x9f, 0x85, 0xd1, 0x1e, |
45 0x97, 0xd4, 0x4f, 0x55, 0xbf, 0xb4, 0x13, 0xa2, | 46 0x97, 0xd4, 0x4f, 0x55, 0xbf, 0xb4, 0x13, 0xa2, |
46 0xe7, 0xc5, 0xc8, 0xf5, 0x60, 0x19, 0x78, 0x1b, | 47 0xe7, 0xc5, 0xc8, 0xf5, 0x60, 0x19, 0x78, 0x1b, |
47 0x6d, 0xe9, 0x4c, 0xeb, 0x96, 0x05, 0x42, 0x17}; | 48 0x6d, 0xe9, 0x4c, 0xeb, 0x96, 0x05, 0x42, 0x17}; |
48 | 49 |
49 // Intercepts requests to a file path, counts them, and captures the body of | 50 // Intercepts requests to a file path, counts them, and captures the body of |
50 // the requests. Optionally, for each request, it can return a canned response | 51 // the requests. Optionally, for each request, it can return a canned response |
51 // from a given file. The class maintains a queue of expectations, and returns | 52 // from a given file. The class maintains a queue of expectations, and returns |
52 // one and only one response for each request that matches and it is | 53 // one and only one response for each request that matches and it is |
53 // intercepted. | 54 // intercepted. |
54 class URLRequestPostInterceptor { | 55 class URLRequestPostInterceptor { |
55 public: | 56 public: |
56 // Allows a generic string maching interface when setting up expectations. | 57 // Allows a generic string maching interface when setting up expectations. |
57 class RequestMatcher { | 58 class RequestMatcher { |
(...skipping 116 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
174 | 175 |
175 private: | 176 private: |
176 const std::string expected_; | 177 const std::string expected_; |
177 | 178 |
178 DISALLOW_COPY_AND_ASSIGN(PartialMatch); | 179 DISALLOW_COPY_AND_ASSIGN(PartialMatch); |
179 }; | 180 }; |
180 | 181 |
181 } // namespace component_updater | 182 } // namespace component_updater |
182 | 183 |
183 #endif // COMPONENTS_COMPONENT_UPDATER_TEST_URL_REQUEST_POST_INTERCEPTOR_H_ | 184 #endif // COMPONENTS_COMPONENT_UPDATER_TEST_URL_REQUEST_POST_INTERCEPTOR_H_ |
OLD | NEW |