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 #include "net/ssl/channel_id_service.h" | 5 #include "net/ssl/channel_id_service.h" |
6 | 6 |
7 #include <memory> | 7 #include <memory> |
8 #include <string> | 8 #include <string> |
9 #include <vector> | 9 #include <vector> |
10 | 10 |
11 #include "base/bind.h" | 11 #include "base/bind.h" |
12 #include "base/location.h" | 12 #include "base/location.h" |
13 #include "base/macros.h" | 13 #include "base/macros.h" |
14 #include "base/memory/ptr_util.h" | |
15 #include "base/run_loop.h" | 14 #include "base/run_loop.h" |
16 #include "base/single_thread_task_runner.h" | 15 #include "base/single_thread_task_runner.h" |
17 #include "base/strings/string_number_conversions.h" | 16 #include "base/strings/string_number_conversions.h" |
18 #include "base/task_runner.h" | 17 #include "base/task_runner.h" |
19 #include "base/threading/thread_task_runner_handle.h" | 18 #include "base/threading/thread_task_runner_handle.h" |
20 #include "crypto/ec_private_key.h" | 19 #include "crypto/ec_private_key.h" |
21 #include "net/base/net_errors.h" | 20 #include "net/base/net_errors.h" |
22 #include "net/base/test_completion_callback.h" | 21 #include "net/base/test_completion_callback.h" |
23 #include "net/cert/asn1_util.h" | 22 #include "net/cert/asn1_util.h" |
24 #include "net/cert/x509_certificate.h" | 23 #include "net/cert/x509_certificate.h" |
(...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
93 // CallGetChannelIDCallbackWithResult. | 92 // CallGetChannelIDCallbackWithResult. |
94 return ERR_IO_PENDING; | 93 return ERR_IO_PENDING; |
95 } | 94 } |
96 | 95 |
97 void MockChannelIDStoreWithAsyncGet::CallGetChannelIDCallbackWithResult( | 96 void MockChannelIDStoreWithAsyncGet::CallGetChannelIDCallbackWithResult( |
98 int err, | 97 int err, |
99 crypto::ECPrivateKey* key) { | 98 crypto::ECPrivateKey* key) { |
100 if (err == OK) | 99 if (err == OK) |
101 channel_id_count_ = 1; | 100 channel_id_count_ = 1; |
102 base::ThreadTaskRunnerHandle::Get()->PostTask( | 101 base::ThreadTaskRunnerHandle::Get()->PostTask( |
103 FROM_HERE, | 102 FROM_HERE, base::Bind(callback_, err, server_identifier_, |
104 base::Bind(callback_, err, server_identifier_, | 103 base::Passed(key ? key->Copy() : nullptr))); |
105 base::Passed(base::WrapUnique(key ? key->Copy() : nullptr)))); | |
106 } | 104 } |
107 | 105 |
108 class ChannelIDServiceTest : public testing::Test { | 106 class ChannelIDServiceTest : public testing::Test { |
109 public: | 107 public: |
110 ChannelIDServiceTest() | 108 ChannelIDServiceTest() |
111 : service_(new ChannelIDService(new DefaultChannelIDStore(NULL), | 109 : service_(new ChannelIDService(new DefaultChannelIDStore(NULL), |
112 base::ThreadTaskRunnerHandle::Get())) {} | 110 base::ThreadTaskRunnerHandle::Get())) {} |
113 | 111 |
114 protected: | 112 protected: |
115 std::unique_ptr<ChannelIDService> service_; | 113 std::unique_ptr<ChannelIDService> service_; |
(...skipping 507 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
623 EXPECT_EQ(1u, service_->inflight_joins()); | 621 EXPECT_EQ(1u, service_->inflight_joins()); |
624 EXPECT_TRUE(key1); | 622 EXPECT_TRUE(key1); |
625 EXPECT_TRUE(KeysEqual(key1.get(), key2.get())); | 623 EXPECT_TRUE(KeysEqual(key1.get(), key2.get())); |
626 EXPECT_FALSE(request1.is_active()); | 624 EXPECT_FALSE(request1.is_active()); |
627 EXPECT_FALSE(request2.is_active()); | 625 EXPECT_FALSE(request2.is_active()); |
628 } | 626 } |
629 | 627 |
630 } // namespace | 628 } // namespace |
631 | 629 |
632 } // namespace net | 630 } // namespace net |
OLD | NEW |