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 <string> | 7 #include <string> |
8 #include <vector> | 8 #include <vector> |
9 | 9 |
10 #include "base/bind.h" | 10 #include "base/bind.h" |
(...skipping 19 matching lines...) Expand all Loading... |
30 | 30 |
31 // Simple task runner that refuses to actually post any tasks. This simulates | 31 // Simple task runner that refuses to actually post any tasks. This simulates |
32 // a TaskRunner that has been shutdown, by returning false for any attempt to | 32 // a TaskRunner that has been shutdown, by returning false for any attempt to |
33 // add new tasks. | 33 // add new tasks. |
34 class FailingTaskRunner : public base::TaskRunner { | 34 class FailingTaskRunner : public base::TaskRunner { |
35 public: | 35 public: |
36 FailingTaskRunner() {} | 36 FailingTaskRunner() {} |
37 | 37 |
38 virtual bool PostDelayedTask(const tracked_objects::Location& from_here, | 38 virtual bool PostDelayedTask(const tracked_objects::Location& from_here, |
39 const base::Closure& task, | 39 const base::Closure& task, |
40 base::TimeDelta delay) OVERRIDE { | 40 base::TimeDelta delay) override { |
41 return false; | 41 return false; |
42 } | 42 } |
43 | 43 |
44 virtual bool RunsTasksOnCurrentThread() const OVERRIDE { return true; } | 44 virtual bool RunsTasksOnCurrentThread() const override { return true; } |
45 | 45 |
46 protected: | 46 protected: |
47 virtual ~FailingTaskRunner() {} | 47 virtual ~FailingTaskRunner() {} |
48 | 48 |
49 private: | 49 private: |
50 DISALLOW_COPY_AND_ASSIGN(FailingTaskRunner); | 50 DISALLOW_COPY_AND_ASSIGN(FailingTaskRunner); |
51 }; | 51 }; |
52 | 52 |
53 class MockChannelIDStoreWithAsyncGet | 53 class MockChannelIDStoreWithAsyncGet |
54 : public DefaultChannelIDStore { | 54 : public DefaultChannelIDStore { |
55 public: | 55 public: |
56 MockChannelIDStoreWithAsyncGet() | 56 MockChannelIDStoreWithAsyncGet() |
57 : DefaultChannelIDStore(NULL), channel_id_count_(0) {} | 57 : DefaultChannelIDStore(NULL), channel_id_count_(0) {} |
58 | 58 |
59 virtual int GetChannelID(const std::string& server_identifier, | 59 virtual int GetChannelID(const std::string& server_identifier, |
60 base::Time* expiration_time, | 60 base::Time* expiration_time, |
61 std::string* private_key_result, | 61 std::string* private_key_result, |
62 std::string* cert_result, | 62 std::string* cert_result, |
63 const GetChannelIDCallback& callback) OVERRIDE; | 63 const GetChannelIDCallback& callback) override; |
64 | 64 |
65 virtual void SetChannelID(const std::string& server_identifier, | 65 virtual void SetChannelID(const std::string& server_identifier, |
66 base::Time creation_time, | 66 base::Time creation_time, |
67 base::Time expiration_time, | 67 base::Time expiration_time, |
68 const std::string& private_key, | 68 const std::string& private_key, |
69 const std::string& cert) OVERRIDE { | 69 const std::string& cert) override { |
70 channel_id_count_ = 1; | 70 channel_id_count_ = 1; |
71 } | 71 } |
72 | 72 |
73 virtual int GetChannelIDCount() OVERRIDE { return channel_id_count_; } | 73 virtual int GetChannelIDCount() override { return channel_id_count_; } |
74 | 74 |
75 void CallGetChannelIDCallbackWithResult(int err, | 75 void CallGetChannelIDCallbackWithResult(int err, |
76 base::Time expiration_time, | 76 base::Time expiration_time, |
77 const std::string& private_key, | 77 const std::string& private_key, |
78 const std::string& cert); | 78 const std::string& cert); |
79 | 79 |
80 private: | 80 private: |
81 GetChannelIDCallback callback_; | 81 GetChannelIDCallback callback_; |
82 std::string server_identifier_; | 82 std::string server_identifier_; |
83 int channel_id_count_; | 83 int channel_id_count_; |
(...skipping 681 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
765 EXPECT_EQ(der_cert1, der_cert2); | 765 EXPECT_EQ(der_cert1, der_cert2); |
766 EXPECT_FALSE(private_key1.empty()); | 766 EXPECT_FALSE(private_key1.empty()); |
767 EXPECT_EQ(private_key1, private_key2); | 767 EXPECT_EQ(private_key1, private_key2); |
768 EXPECT_FALSE(request_handle1.is_active()); | 768 EXPECT_FALSE(request_handle1.is_active()); |
769 EXPECT_FALSE(request_handle2.is_active()); | 769 EXPECT_FALSE(request_handle2.is_active()); |
770 } | 770 } |
771 | 771 |
772 } // namespace | 772 } // namespace |
773 | 773 |
774 } // namespace net | 774 } // namespace net |
OLD | NEW |