| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 // P2PSocketDispatcher is a per-renderer object that dispatchers all | 5 // P2PSocketDispatcher is a per-renderer object that dispatchers all |
| 6 // P2P messages received from the browser and relays all P2P messages | 6 // P2P messages received from the browser and relays all P2P messages |
| 7 // sent to the browser. P2PSocketClient instances register themselves | 7 // sent to the browser. P2PSocketClient instances register themselves |
| 8 // with the dispatcher using RegisterClient() and UnregisterClient(). | 8 // with the dispatcher using RegisterClient() and UnregisterClient(). |
| 9 // | 9 // |
| 10 // Relationship of classes. | 10 // Relationship of classes. |
| (...skipping 23 matching lines...) Expand all Loading... |
| 34 class RenderViewImpl; | 34 class RenderViewImpl; |
| 35 | 35 |
| 36 namespace base { | 36 namespace base { |
| 37 class MessageLoopProxy; | 37 class MessageLoopProxy; |
| 38 } // namespace base | 38 } // namespace base |
| 39 | 39 |
| 40 namespace net { | 40 namespace net { |
| 41 class IPEndPoint; | 41 class IPEndPoint; |
| 42 } // namespace net | 42 } // namespace net |
| 43 | 43 |
| 44 namespace webkit_glue { | |
| 45 class NetworkListObserver; | |
| 46 } // webkit_glue | |
| 47 | |
| 48 namespace content { | 44 namespace content { |
| 49 | 45 |
| 50 class P2PHostAddressRequest; | 46 class P2PHostAddressRequest; |
| 51 class P2PSocketClient; | 47 class P2PSocketClient; |
| 52 | 48 |
| 53 // P2PSocketDispatcher works on the renderer thread. It dispatches all | 49 // P2PSocketDispatcher works on the renderer thread. It dispatches all |
| 54 // messages on that thread, and all its methods must be called on the | 50 // messages on that thread, and all its methods must be called on the |
| 55 // same thread. | 51 // same thread. |
| 56 class CONTENT_EXPORT P2PSocketDispatcher : public content::RenderViewObserver { | 52 class CONTENT_EXPORT P2PSocketDispatcher : public content::RenderViewObserver { |
| 57 public: | 53 public: |
| 54 class NetworkListObserver { |
| 55 public: |
| 56 virtual ~NetworkListObserver() { } |
| 57 |
| 58 virtual void OnNetworkListChanged( |
| 59 const net::NetworkInterfaceList& list) = 0; |
| 60 |
| 61 protected: |
| 62 NetworkListObserver() { } |
| 63 |
| 64 private: |
| 65 DISALLOW_COPY_AND_ASSIGN(NetworkListObserver); |
| 66 }; |
| 67 |
| 58 explicit P2PSocketDispatcher(RenderViewImpl* render_view); | 68 explicit P2PSocketDispatcher(RenderViewImpl* render_view); |
| 59 virtual ~P2PSocketDispatcher(); | 69 virtual ~P2PSocketDispatcher(); |
| 60 | 70 |
| 61 // Add a new network list observer. Each observer is called | 71 // Add a new network list observer. Each observer is called |
| 62 // immidiately after it is registered and then later whenever | 72 // immidiately after its't registered and then later whenever |
| 63 // network configuration changes. | 73 // network configuration changes. |
| 64 void AddNetworkListObserver( | 74 void AddNetworkListObserver(NetworkListObserver* network_list_observer); |
| 65 webkit_glue::NetworkListObserver* network_list_observer); | |
| 66 | 75 |
| 67 // Removes network list observer. | 76 // Removes network list observer. |
| 68 void RemoveNetworkListObserver( | 77 void RemoveNetworkListObserver(NetworkListObserver* network_list_observer); |
| 69 webkit_glue::NetworkListObserver* network_list_observer); | |
| 70 | 78 |
| 71 // RenderViewObserver overrides. | 79 // RenderViewObserver overrides. |
| 72 virtual bool OnMessageReceived(const IPC::Message& message) OVERRIDE; | 80 virtual bool OnMessageReceived(const IPC::Message& message) OVERRIDE; |
| 73 | 81 |
| 74 private: | 82 private: |
| 75 friend class P2PHostAddressRequest; | 83 friend class P2PHostAddressRequest; |
| 76 friend class P2PSocketClient; | 84 friend class P2PSocketClient; |
| 77 class AsyncMessageSender; | 85 class AsyncMessageSender; |
| 78 | 86 |
| 79 base::MessageLoopProxy* message_loop(); | 87 base::MessageLoopProxy* message_loop(); |
| (...skipping 18 matching lines...) Expand all Loading... |
| 98 const std::vector<char>& data); | 106 const std::vector<char>& data); |
| 99 | 107 |
| 100 P2PSocketClient* GetClient(int socket_id); | 108 P2PSocketClient* GetClient(int socket_id); |
| 101 | 109 |
| 102 scoped_refptr<base::MessageLoopProxy> message_loop_; | 110 scoped_refptr<base::MessageLoopProxy> message_loop_; |
| 103 IDMap<P2PSocketClient> clients_; | 111 IDMap<P2PSocketClient> clients_; |
| 104 | 112 |
| 105 IDMap<P2PHostAddressRequest> host_address_requests_; | 113 IDMap<P2PHostAddressRequest> host_address_requests_; |
| 106 | 114 |
| 107 bool network_notifications_started_; | 115 bool network_notifications_started_; |
| 108 scoped_refptr<ObserverListThreadSafe<webkit_glue::NetworkListObserver> > | 116 scoped_refptr<ObserverListThreadSafe<NetworkListObserver> > |
| 109 network_list_observers_; | 117 network_list_observers_; |
| 110 | 118 |
| 111 scoped_refptr<AsyncMessageSender> async_message_sender_; | 119 scoped_refptr<AsyncMessageSender> async_message_sender_; |
| 112 | 120 |
| 113 DISALLOW_COPY_AND_ASSIGN(P2PSocketDispatcher); | 121 DISALLOW_COPY_AND_ASSIGN(P2PSocketDispatcher); |
| 114 }; | 122 }; |
| 115 | 123 |
| 116 } // namespace content | 124 } // namespace content |
| 117 | 125 |
| 118 #endif // CONTENT_RENDERER_P2P_SOCKET_DISPATCHER_H_ | 126 #endif // CONTENT_RENDERER_P2P_SOCKET_DISPATCHER_H_ |
| OLD | NEW |