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_BROWSER_MEDIA_WEBRTC_INTERNALS_H_ | 5 #ifndef CONTENT_BROWSER_MEDIA_WEBRTC_INTERNALS_H_ |
6 #define CONTENT_BROWSER_MEDIA_WEBRTC_INTERNALS_H_ | 6 #define CONTENT_BROWSER_MEDIA_WEBRTC_INTERNALS_H_ |
7 | 7 |
8 #include "base/memory/singleton.h" | 8 #include "base/memory/singleton.h" |
9 #include "base/observer_list.h" | 9 #include "base/observer_list.h" |
10 #include "base/process.h" | 10 #include "base/process.h" |
11 #include "base/values.h" | 11 #include "base/values.h" |
12 #include "content/common/content_export.h" | 12 #include "content/common/content_export.h" |
| 13 #include "content/public/browser/browser_child_process_observer.h" |
13 #include "content/public/browser/notification_observer.h" | 14 #include "content/public/browser/notification_observer.h" |
14 #include "content/public/browser/notification_registrar.h" | 15 #include "content/public/browser/notification_registrar.h" |
15 | 16 |
16 namespace content { | 17 namespace content { |
17 class WebRTCInternalsUIObserver; | 18 class WebRTCInternalsUIObserver; |
18 | 19 |
19 // This is a singleton class running in the browser UI thread. | 20 // This is a singleton class running in the browser UI thread. |
20 // It collects peer connection infomation from the renderers, | 21 // It collects peer connection infomation from the renderers, |
21 // forwards the data to WebRTCInternalsUIObserver and | 22 // forwards the data to WebRTCInternalsUIObserver and |
22 // sends data collecting commands to the renderers. | 23 // sends data collecting commands to the renderers. |
23 class CONTENT_EXPORT WebRTCInternals : public NotificationObserver{ | 24 class CONTENT_EXPORT WebRTCInternals : public BrowserChildProcessObserver, |
| 25 public NotificationObserver{ |
24 public: | 26 public: |
25 static WebRTCInternals* GetInstance(); | 27 static WebRTCInternals* GetInstance(); |
26 | 28 |
27 // This method is called when a PeerConnection is created. | 29 // This method is called when a PeerConnection is created. |
28 // |render_process_id| is the id of the render process (not OS pid), which is | 30 // |render_process_id| is the id of the render process (not OS pid), which is |
29 // needed because we might not be able to get the OS process id when the | 31 // needed because we might not be able to get the OS process id when the |
30 // render process terminates and we want to clean up. | 32 // render process terminates and we want to clean up. |
31 // |pid| is the renderer process id, |lid| is the renderer local id used to | 33 // |pid| is the renderer process id, |lid| is the renderer local id used to |
32 // identify a PeerConnection, |url| is the url of the tab owning the | 34 // identify a PeerConnection, |url| is the url of the tab owning the |
33 // PeerConnection, |servers| is the servers configuration, |constraints| is | 35 // PeerConnection, |servers| is the servers configuration, |constraints| is |
(...skipping 30 matching lines...) Expand all Loading... |
64 void SendAllUpdates(); | 66 void SendAllUpdates(); |
65 | 67 |
66 private: | 68 private: |
67 friend struct DefaultSingletonTraits<WebRTCInternals>; | 69 friend struct DefaultSingletonTraits<WebRTCInternals>; |
68 | 70 |
69 WebRTCInternals(); | 71 WebRTCInternals(); |
70 virtual ~WebRTCInternals(); | 72 virtual ~WebRTCInternals(); |
71 | 73 |
72 void SendUpdate(const std::string& command, base::Value* value); | 74 void SendUpdate(const std::string& command, base::Value* value); |
73 | 75 |
| 76 // BrowserChildProcessObserver implementation. |
| 77 virtual void BrowserChildProcessCrashed( |
| 78 const ChildProcessData& data) OVERRIDE; |
| 79 |
74 // NotificationObserver implementation. | 80 // NotificationObserver implementation. |
75 virtual void Observe(int type, | 81 virtual void Observe(int type, |
76 const NotificationSource& source, | 82 const NotificationSource& source, |
77 const NotificationDetails& details) OVERRIDE; | 83 const NotificationDetails& details) OVERRIDE; |
78 | 84 |
| 85 // Called when a renderer exits (including crashes). |
| 86 void OnRendererExit(int render_process_id); |
| 87 |
79 ObserverList<WebRTCInternalsUIObserver> observers_; | 88 ObserverList<WebRTCInternalsUIObserver> observers_; |
80 | 89 |
81 // |peer_connection_data_| is a list containing all the PeerConnection | 90 // |peer_connection_data_| is a list containing all the PeerConnection |
82 // updates. | 91 // updates. |
83 // Each item of the list represents the data for one PeerConnection, which | 92 // Each item of the list represents the data for one PeerConnection, which |
84 // contains these fields: | 93 // contains these fields: |
85 // "pid" -- processId of the renderer that creates the PeerConnection. | 94 // "pid" -- processId of the renderer that creates the PeerConnection. |
86 // "lid" -- local Id assigned to the PeerConnection. | 95 // "lid" -- local Id assigned to the PeerConnection. |
87 // "url" -- url of the web page that created the PeerConnection. | 96 // "url" -- url of the web page that created the PeerConnection. |
88 // "servers" and "constraints" -- server configuration and media constraints | 97 // "servers" and "constraints" -- server configuration and media constraints |
89 // used to initialize the PeerConnection respectively. | 98 // used to initialize the PeerConnection respectively. |
90 // "log" -- a ListValue contains all the updates for the PeerConnection. Each | 99 // "log" -- a ListValue contains all the updates for the PeerConnection. Each |
91 // list item is a DictionaryValue containing "type" and "value", both of which | 100 // list item is a DictionaryValue containing "type" and "value", both of which |
92 // are strings. | 101 // are strings. |
93 base::ListValue peer_connection_data_; | 102 base::ListValue peer_connection_data_; |
94 | 103 |
95 NotificationRegistrar registrar_; | 104 NotificationRegistrar registrar_; |
96 }; | 105 }; |
97 | 106 |
98 } // namespace content | 107 } // namespace content |
99 | 108 |
100 #endif // CONTENT_BROWSER_MEDIA_WEBRTC_INTERNALS_H_ | 109 #endif // CONTENT_BROWSER_MEDIA_WEBRTC_INTERNALS_H_ |
OLD | NEW |