OLD | NEW |
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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 #ifndef JINGLE_GLUE_FAKE_SOCKET_FACTORY_H_ | 5 #ifndef JINGLE_GLUE_FAKE_SOCKET_FACTORY_H_ |
6 #define JINGLE_GLUE_FAKE_SOCKET_FACTORY_H_ | 6 #define JINGLE_GLUE_FAKE_SOCKET_FACTORY_H_ |
7 | 7 |
8 #include <map> | 8 #include <map> |
9 #include <vector> | 9 #include <vector> |
10 | 10 |
11 #include "base/basictypes.h" | 11 #include "base/basictypes.h" |
12 #include "base/compiler_specific.h" | 12 #include "base/compiler_specific.h" |
13 #include "base/memory/ref_counted.h" | 13 #include "base/memory/ref_counted.h" |
14 #include "base/threading/non_thread_safe.h" | 14 #include "base/threading/non_thread_safe.h" |
15 #include "net/base/ip_endpoint.h" | 15 #include "net/base/ip_endpoint.h" |
16 #include "third_party/libjingle/source/talk/base/asyncpacketsocket.h" | 16 #include "third_party/libjingle/source/talk/base/asyncpacketsocket.h" |
17 #include "third_party/libjingle/source/talk/base/packetsocketfactory.h" | 17 #include "third_party/libjingle/source/talk/base/packetsocketfactory.h" |
18 | 18 |
| 19 namespace base { |
19 class MessageLoop; | 20 class MessageLoop; |
| 21 } |
20 | 22 |
21 namespace jingle_glue { | 23 namespace jingle_glue { |
22 | 24 |
23 class FakeSocketManager; | 25 class FakeSocketManager; |
24 | 26 |
25 class FakeUDPPacketSocket : public talk_base::AsyncPacketSocket, | 27 class FakeUDPPacketSocket : public talk_base::AsyncPacketSocket, |
26 public base::NonThreadSafe { | 28 public base::NonThreadSafe { |
27 public: | 29 public: |
28 FakeUDPPacketSocket(FakeSocketManager* fake_socket_manager, | 30 FakeUDPPacketSocket(FakeSocketManager* fake_socket_manager, |
29 const net::IPEndPoint& address); | 31 const net::IPEndPoint& address); |
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
75 | 77 |
76 private: | 78 private: |
77 friend class base::RefCountedThreadSafe<FakeSocketManager>; | 79 friend class base::RefCountedThreadSafe<FakeSocketManager>; |
78 | 80 |
79 ~FakeSocketManager(); | 81 ~FakeSocketManager(); |
80 | 82 |
81 void DeliverPacket(const net::IPEndPoint& from, | 83 void DeliverPacket(const net::IPEndPoint& from, |
82 const net::IPEndPoint& to, | 84 const net::IPEndPoint& to, |
83 const std::vector<char>& data); | 85 const std::vector<char>& data); |
84 | 86 |
85 MessageLoop* message_loop_; | 87 base::MessageLoop* message_loop_; |
86 std::map<net::IPEndPoint, FakeUDPPacketSocket*> endpoints_; | 88 std::map<net::IPEndPoint, FakeUDPPacketSocket*> endpoints_; |
87 | 89 |
88 DISALLOW_COPY_AND_ASSIGN(FakeSocketManager); | 90 DISALLOW_COPY_AND_ASSIGN(FakeSocketManager); |
89 }; | 91 }; |
90 | 92 |
91 class FakeSocketFactory : public talk_base::PacketSocketFactory { | 93 class FakeSocketFactory : public talk_base::PacketSocketFactory { |
92 public: | 94 public: |
93 FakeSocketFactory(FakeSocketManager* socket_manager, | 95 FakeSocketFactory(FakeSocketManager* socket_manager, |
94 const net::IPAddressNumber& address); | 96 const net::IPAddressNumber& address); |
95 virtual ~FakeSocketFactory(); | 97 virtual ~FakeSocketFactory(); |
(...skipping 16 matching lines...) Expand all Loading... |
112 scoped_refptr<FakeSocketManager> socket_manager_; | 114 scoped_refptr<FakeSocketManager> socket_manager_; |
113 net::IPAddressNumber address_; | 115 net::IPAddressNumber address_; |
114 int last_allocated_port_; | 116 int last_allocated_port_; |
115 | 117 |
116 DISALLOW_COPY_AND_ASSIGN(FakeSocketFactory); | 118 DISALLOW_COPY_AND_ASSIGN(FakeSocketFactory); |
117 }; | 119 }; |
118 | 120 |
119 } // namespace jingle_glue | 121 } // namespace jingle_glue |
120 | 122 |
121 #endif // JINGLE_GLUE_FAKE_SOCKET_FACTORY_H_ | 123 #endif // JINGLE_GLUE_FAKE_SOCKET_FACTORY_H_ |
OLD | NEW |