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 = { |
48 "", "", base::Time(), "", test_mode, | 48 key, "", base::Time(), "", LOAD_NORMAL, "", "", |
49 NULL, 0, OK}; | 49 base::Time(), "", test_mode, nullptr, nullptr, 0, OK}; |
50 | 50 |
51 return transaction; | 51 return transaction; |
52 } | 52 } |
53 | 53 |
54 // Helper class, for use with DiskBasedCertCache::GetCertificate, that will | 54 // Helper class, for use with DiskBasedCertCache::GetCertificate, that will |
55 // store the returned certificate handle and allow users to WaitForResult of | 55 // store the returned certificate handle and allow users to WaitForResult of |
56 // DiskBasedCertCache::GetCertificate. | 56 // DiskBasedCertCache::GetCertificate. |
57 class TestGetCallback { | 57 class TestGetCallback { |
58 public: | 58 public: |
59 TestGetCallback() : cert_handle_(NULL) {} | 59 TestGetCallback() : cert_handle_(NULL) {} |
(...skipping 466 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
526 | 526 |
527 cache.GetCertificate(kCert1.cache_key, get_callback2.callback()); | 527 cache.GetCertificate(kCert1.cache_key, get_callback2.callback()); |
528 get_callback2.WaitForResult(); | 528 get_callback2.WaitForResult(); |
529 EXPECT_TRUE(X509Certificate::IsSameOSCert(get_callback2.cert_handle(), | 529 EXPECT_TRUE(X509Certificate::IsSameOSCert(get_callback2.cert_handle(), |
530 cert->os_cert_handle())); | 530 cert->os_cert_handle())); |
531 EXPECT_EQ(1U, cache.mem_cache_hits_for_testing()); | 531 EXPECT_EQ(1U, cache.mem_cache_hits_for_testing()); |
532 ASSERT_NO_FATAL_FAILURE(CheckCertCached(&backend, kCert1)); | 532 ASSERT_NO_FATAL_FAILURE(CheckCertCached(&backend, kCert1)); |
533 } | 533 } |
534 | 534 |
535 } // namespace net | 535 } // namespace net |
OLD | NEW |