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 "content/browser/renderer_host/websocket_dispatcher_host.h" | 5 #include "content/browser/renderer_host/websocket_dispatcher_host.h" |
6 | 6 |
7 #include <algorithm> | 7 #include <algorithm> |
8 #include <vector> | 8 #include <vector> |
9 | 9 |
10 #include "base/bind.h" | 10 #include "base/bind.h" |
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
53 WebSocketDispatcherHostTest() | 53 WebSocketDispatcherHostTest() |
54 : weak_ptr_factory_(this) { | 54 : weak_ptr_factory_(this) { |
55 dispatcher_host_ = new WebSocketDispatcherHost( | 55 dispatcher_host_ = new WebSocketDispatcherHost( |
56 kMagicRenderProcessId, | 56 kMagicRenderProcessId, |
57 base::Bind(&WebSocketDispatcherHostTest::OnGetRequestContext, | 57 base::Bind(&WebSocketDispatcherHostTest::OnGetRequestContext, |
58 base::Unretained(this)), | 58 base::Unretained(this)), |
59 base::Bind(&WebSocketDispatcherHostTest::CreateWebSocketHost, | 59 base::Bind(&WebSocketDispatcherHostTest::CreateWebSocketHost, |
60 base::Unretained(this))); | 60 base::Unretained(this))); |
61 } | 61 } |
62 | 62 |
63 virtual ~WebSocketDispatcherHostTest() { | 63 ~WebSocketDispatcherHostTest() override { |
64 // We need to invalidate the issued WeakPtrs at the beginning of the | 64 // We need to invalidate the issued WeakPtrs at the beginning of the |
65 // destructor in order not to access destructed member variables. | 65 // destructor in order not to access destructed member variables. |
66 weak_ptr_factory_.InvalidateWeakPtrs(); | 66 weak_ptr_factory_.InvalidateWeakPtrs(); |
67 } | 67 } |
68 | 68 |
69 void GoAway(int routing_id) { | 69 void GoAway(int routing_id) { |
70 gone_hosts_.push_back(routing_id); | 70 gone_hosts_.push_back(routing_id); |
71 } | 71 } |
72 | 72 |
73 base::WeakPtr<WebSocketDispatcherHostTest> GetWeakPtr() { | 73 base::WeakPtr<WebSocketDispatcherHostTest> GetWeakPtr() { |
(...skipping 136 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
210 ASSERT_EQ(2u, gone_hosts_.size()); | 210 ASSERT_EQ(2u, gone_hosts_.size()); |
211 // The gone_hosts_ ordering is not predictable because it depends on the | 211 // The gone_hosts_ ordering is not predictable because it depends on the |
212 // hash_map ordering. | 212 // hash_map ordering. |
213 std::sort(gone_hosts_.begin(), gone_hosts_.end()); | 213 std::sort(gone_hosts_.begin(), gone_hosts_.end()); |
214 EXPECT_EQ(123, gone_hosts_[0]); | 214 EXPECT_EQ(123, gone_hosts_[0]); |
215 EXPECT_EQ(456, gone_hosts_[1]); | 215 EXPECT_EQ(456, gone_hosts_[1]); |
216 } | 216 } |
217 | 217 |
218 } // namespace | 218 } // namespace |
219 } // namespace content | 219 } // namespace content |
OLD | NEW |