OLD | NEW |
1 // Copyright (c) 2014 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 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 #include "net/http/disk_based_cert_cache.h" | 5 #include "net/http/disk_based_cert_cache.h" |
6 | 6 |
7 #include "base/bind.h" | 7 #include "base/bind.h" |
8 #include "base/callback_helpers.h" | 8 #include "base/callback_helpers.h" |
9 #include "net/base/completion_callback.h" | 9 #include "net/base/completion_callback.h" |
10 #include "net/base/io_buffer.h" | 10 #include "net/base/io_buffer.h" |
(...skipping 26 matching lines...) Expand all Loading... |
37 | 37 |
38 // MockTransactions are required to use the MockDiskCache backend. | 38 // MockTransactions are required to use the MockDiskCache backend. |
39 // |key| is a cache key, and is equivalent to the key that will be | 39 // |key| is a cache key, and is equivalent to the key that will be |
40 // used to store or retrieve certificates in the cache. |test_mode| | 40 // used to store or retrieve certificates in the cache. |test_mode| |
41 // is an integer that is used to indicate properties of the test | 41 // is an integer that is used to indicate properties of the test |
42 // transaction, mostly whether or not it is synchronous. | 42 // transaction, mostly whether or not it is synchronous. |
43 // For testing the DiskBasedCertCache, other data members of the struct | 43 // For testing the DiskBasedCertCache, other data members of the struct |
44 // are irrelevant. Only one MockTransaction per certificate can be used | 44 // are irrelevant. Only one MockTransaction per certificate can be used |
45 // at a time. | 45 // at a time. |
46 MockTransaction CreateMockTransaction(const char* key, int test_mode) { | 46 MockTransaction CreateMockTransaction(const char* key, int test_mode) { |
47 MockTransaction transaction = {key, "", base::Time(), "", LOAD_NORMAL, | 47 MockTransaction transaction = {key, |
48 "", "", base::Time(), "", test_mode, | 48 "", |
49 NULL, 0, OK}; | 49 base::Time(), |
| 50 "", |
| 51 LOAD_NORMAL, |
| 52 "", |
| 53 "", |
| 54 base::Time(), |
| 55 "", |
| 56 test_mode, |
| 57 nullptr, |
| 58 nullptr, |
| 59 0, |
| 60 OK}; |
50 | 61 |
51 return transaction; | 62 return transaction; |
52 } | 63 } |
53 | 64 |
54 // Helper class, for use with DiskBasedCertCache::GetCertificate, that will | 65 // Helper class, for use with DiskBasedCertCache::GetCertificate, that will |
55 // store the returned certificate handle and allow users to WaitForResult of | 66 // store the returned certificate handle and allow users to WaitForResult of |
56 // DiskBasedCertCache::GetCertificate. | 67 // DiskBasedCertCache::GetCertificate. |
57 class TestGetCallback { | 68 class TestGetCallback { |
58 public: | 69 public: |
59 TestGetCallback() : cert_handle_(NULL) {} | 70 TestGetCallback() : cert_handle_(NULL) {} |
(...skipping 466 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
526 | 537 |
527 cache.GetCertificate(kCert1.cache_key, get_callback2.callback()); | 538 cache.GetCertificate(kCert1.cache_key, get_callback2.callback()); |
528 get_callback2.WaitForResult(); | 539 get_callback2.WaitForResult(); |
529 EXPECT_TRUE(X509Certificate::IsSameOSCert(get_callback2.cert_handle(), | 540 EXPECT_TRUE(X509Certificate::IsSameOSCert(get_callback2.cert_handle(), |
530 cert->os_cert_handle())); | 541 cert->os_cert_handle())); |
531 EXPECT_EQ(1U, cache.mem_cache_hits_for_testing()); | 542 EXPECT_EQ(1U, cache.mem_cache_hits_for_testing()); |
532 ASSERT_NO_FATAL_FAILURE(CheckCertCached(&backend, kCert1)); | 543 ASSERT_NO_FATAL_FAILURE(CheckCertCached(&backend, kCert1)); |
533 } | 544 } |
534 | 545 |
535 } // namespace net | 546 } // namespace net |
OLD | NEW |