| OLD | NEW |
| 1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 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 #ifndef CONTENT_RENDERER_MEDIA_PEER_CONNECTION_TRACKER_H_ | 5 #ifndef CONTENT_RENDERER_MEDIA_PEER_CONNECTION_TRACKER_H_ |
| 6 #define CONTENT_RENDERER_MEDIA_PEER_CONNECTION_TRACKER_H_ | 6 #define CONTENT_RENDERER_MEDIA_PEER_CONNECTION_TRACKER_H_ |
| 7 | 7 |
| 8 #include <map> | 8 #include <map> |
| 9 | 9 |
| 10 #include "base/compiler_specific.h" | 10 #include "base/compiler_specific.h" |
| (...skipping 145 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 156 RTCPeerConnectionHandler* pc_handler, | 156 RTCPeerConnectionHandler* pc_handler, |
| 157 const blink::WebMediaStreamTrack& track); | 157 const blink::WebMediaStreamTrack& track); |
| 158 | 158 |
| 159 // Sends an update when getUserMedia is called. | 159 // Sends an update when getUserMedia is called. |
| 160 virtual void TrackGetUserMedia( | 160 virtual void TrackGetUserMedia( |
| 161 const blink::WebUserMediaRequest& user_media_request); | 161 const blink::WebUserMediaRequest& user_media_request); |
| 162 | 162 |
| 163 private: | 163 private: |
| 164 // Assign a local ID to a peer connection so that the browser process can | 164 // Assign a local ID to a peer connection so that the browser process can |
| 165 // uniquely identify a peer connection in the renderer process. | 165 // uniquely identify a peer connection in the renderer process. |
| 166 // The return value will always be positive. |
| 166 int GetNextLocalID(); | 167 int GetNextLocalID(); |
| 167 | 168 |
| 169 // Looks up a handler in our map and if found, returns its ID. If the handler |
| 170 // is not registered, the return value will be -1. |
| 171 int GetLocalIDForHandler(RTCPeerConnectionHandler* handler) const; |
| 172 |
| 168 // IPC Message handler for getting all stats. | 173 // IPC Message handler for getting all stats. |
| 169 void OnGetAllStats(); | 174 void OnGetAllStats(); |
| 170 | 175 |
| 171 // Called when the browser process reports a suspend event from the OS. | 176 // Called when the browser process reports a suspend event from the OS. |
| 172 void OnSuspend(); | 177 void OnSuspend(); |
| 173 | 178 |
| 174 void SendPeerConnectionUpdate(RTCPeerConnectionHandler* pc_handler, | 179 // Called to deliver an update to the host (PeerConnectionTrackerHost). |
| 175 const std::string& callback_type, | 180 // |local_id| - The id of the registered RTCPeerConnectionHandler. |
| 181 // Using an id instead of the hander pointer is done on purpose |
| 182 // to force doing the lookup before building the callback data |
| 183 // in case the handler isn't registered. |
| 184 // |callback_type| - A string, most often static, that represents the type |
| 185 // of operation that the data stored in |value| comes from. |
| 186 // E.g. "createOffer", "createAnswer", |
| 187 // "setRemoteDescription" etc. |
| 188 // |value| - A json serialized string containing all the information for the |
| 189 // update event. |
| 190 void SendPeerConnectionUpdate(int local_id, |
| 191 const char* callback_type, |
| 176 const std::string& value); | 192 const std::string& value); |
| 177 | 193 |
| 178 // This map stores the local ID assigned to each RTCPeerConnectionHandler. | 194 // This map stores the local ID assigned to each RTCPeerConnectionHandler. |
| 179 typedef std::map<RTCPeerConnectionHandler*, int> PeerConnectionIdMap; | 195 typedef std::map<RTCPeerConnectionHandler*, int> PeerConnectionIdMap; |
| 180 PeerConnectionIdMap peer_connection_id_map_; | 196 PeerConnectionIdMap peer_connection_id_map_; |
| 181 | 197 |
| 182 // This keeps track of the next available local ID. | 198 // This keeps track of the next available local ID. |
| 183 int next_lid_; | 199 int next_local_id_; |
| 184 base::ThreadChecker main_thread_; | 200 base::ThreadChecker main_thread_; |
| 185 | 201 |
| 186 DISALLOW_COPY_AND_ASSIGN(PeerConnectionTracker); | 202 DISALLOW_COPY_AND_ASSIGN(PeerConnectionTracker); |
| 187 }; | 203 }; |
| 188 | 204 |
| 189 } // namespace content | 205 } // namespace content |
| 190 | 206 |
| 191 #endif // CONTENT_RENDERER_MEDIA_PEER_CONNECTION_TRACKER_H_ | 207 #endif // CONTENT_RENDERER_MEDIA_PEER_CONNECTION_TRACKER_H_ |
| OLD | NEW |