| 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 #include <deque> | 5 #include <deque> |
| 6 | 6 |
| 7 #include "content/browser/child_process_security_policy_impl.h" | 7 #include "content/browser/child_process_security_policy_impl.h" |
| 8 #include "content/browser/media/webrtc_identity_store.h" | 8 #include "content/browser/media/webrtc_identity_store.h" |
| 9 #include "content/browser/renderer_host/media/webrtc_identity_service_host.h" | 9 #include "content/browser/renderer_host/media/webrtc_identity_service_host.h" |
| 10 #include "content/common/media/webrtc_identity_messages.h" | 10 #include "content/common/media/webrtc_identity_messages.h" |
| (...skipping 15 matching lines...) Expand all Loading... |
| 26 const int FAKE_SEQUENCE_NUMBER = 1; | 26 const int FAKE_SEQUENCE_NUMBER = 1; |
| 27 | 27 |
| 28 class MockWebRTCIdentityStore : public WebRTCIdentityStore { | 28 class MockWebRTCIdentityStore : public WebRTCIdentityStore { |
| 29 public: | 29 public: |
| 30 MockWebRTCIdentityStore() : WebRTCIdentityStore(base::FilePath(), NULL) {} | 30 MockWebRTCIdentityStore() : WebRTCIdentityStore(base::FilePath(), NULL) {} |
| 31 | 31 |
| 32 virtual base::Closure RequestIdentity( | 32 virtual base::Closure RequestIdentity( |
| 33 const GURL& origin, | 33 const GURL& origin, |
| 34 const std::string& identity_name, | 34 const std::string& identity_name, |
| 35 const std::string& common_name, | 35 const std::string& common_name, |
| 36 const CompletionCallback& callback) OVERRIDE { | 36 const CompletionCallback& callback) override { |
| 37 EXPECT_TRUE(callback_.is_null()); | 37 EXPECT_TRUE(callback_.is_null()); |
| 38 | 38 |
| 39 callback_ = callback; | 39 callback_ = callback; |
| 40 return base::Bind(&MockWebRTCIdentityStore::OnCancel, | 40 return base::Bind(&MockWebRTCIdentityStore::OnCancel, |
| 41 base::Unretained(this)); | 41 base::Unretained(this)); |
| 42 } | 42 } |
| 43 | 43 |
| 44 bool HasPendingRequest() const { return !callback_.is_null(); } | 44 bool HasPendingRequest() const { return !callback_.is_null(); } |
| 45 | 45 |
| 46 void RunCompletionCallback(int error, | 46 void RunCompletionCallback(int error, |
| (...skipping 13 matching lines...) Expand all Loading... |
| 60 | 60 |
| 61 class WebRTCIdentityServiceHostForTest : public WebRTCIdentityServiceHost { | 61 class WebRTCIdentityServiceHostForTest : public WebRTCIdentityServiceHost { |
| 62 public: | 62 public: |
| 63 explicit WebRTCIdentityServiceHostForTest(WebRTCIdentityStore* identity_store) | 63 explicit WebRTCIdentityServiceHostForTest(WebRTCIdentityStore* identity_store) |
| 64 : WebRTCIdentityServiceHost(FAKE_RENDERER_ID, identity_store) { | 64 : WebRTCIdentityServiceHost(FAKE_RENDERER_ID, identity_store) { |
| 65 ChildProcessSecurityPolicyImpl* policy = | 65 ChildProcessSecurityPolicyImpl* policy = |
| 66 ChildProcessSecurityPolicyImpl::GetInstance(); | 66 ChildProcessSecurityPolicyImpl::GetInstance(); |
| 67 policy->Add(FAKE_RENDERER_ID); | 67 policy->Add(FAKE_RENDERER_ID); |
| 68 } | 68 } |
| 69 | 69 |
| 70 virtual bool Send(IPC::Message* message) OVERRIDE { | 70 virtual bool Send(IPC::Message* message) override { |
| 71 messages_.push_back(*message); | 71 messages_.push_back(*message); |
| 72 delete message; | 72 delete message; |
| 73 return true; | 73 return true; |
| 74 } | 74 } |
| 75 | 75 |
| 76 virtual bool OnMessageReceived(const IPC::Message& message) OVERRIDE { | 76 virtual bool OnMessageReceived(const IPC::Message& message) override { |
| 77 return WebRTCIdentityServiceHost::OnMessageReceived(message); | 77 return WebRTCIdentityServiceHost::OnMessageReceived(message); |
| 78 } | 78 } |
| 79 | 79 |
| 80 IPC::Message GetLastMessage() { return messages_.back(); } | 80 IPC::Message GetLastMessage() { return messages_.back(); } |
| 81 | 81 |
| 82 int GetNumberOfMessages() { return messages_.size(); } | 82 int GetNumberOfMessages() { return messages_.size(); } |
| 83 | 83 |
| 84 void ClearMessages() { messages_.clear(); } | 84 void ClearMessages() { messages_.clear(); } |
| 85 | 85 |
| 86 private: | 86 private: |
| (...skipping 95 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 182 } | 182 } |
| 183 | 183 |
| 184 // Verifies that we do not crash if we try to cancel a completed request. | 184 // Verifies that we do not crash if we try to cancel a completed request. |
| 185 TEST_F(WebRTCIdentityServiceHostTest, TestCancelAfterRequestCompleted) { | 185 TEST_F(WebRTCIdentityServiceHostTest, TestCancelAfterRequestCompleted) { |
| 186 SendRequestToHost(); | 186 SendRequestToHost(); |
| 187 store_->RunCompletionCallback(net::OK, FAKE_CERTIFICATE, FAKE_PRIVATE_KEY); | 187 store_->RunCompletionCallback(net::OK, FAKE_CERTIFICATE, FAKE_PRIVATE_KEY); |
| 188 SendCancelRequestToHost(); | 188 SendCancelRequestToHost(); |
| 189 } | 189 } |
| 190 | 190 |
| 191 } // namespace content | 191 } // namespace content |
| OLD | NEW |