Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(359)

Side by Side Diff: trunk/src/chrome/browser/media/webrtc_logging_handler_host.h

Issue 307063003: Revert 273745 "Implements RTP header dumping." due to memory leak (Closed) Base URL: svn://svn.chromium.org/chrome/
Patch Set: Created 6 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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 #ifndef CHROME_BROWSER_MEDIA_WEBRTC_LOGGING_HANDLER_HOST_H_ 5 #ifndef CHROME_BROWSER_MEDIA_WEBRTC_LOGGING_HANDLER_HOST_H_
6 #define CHROME_BROWSER_MEDIA_WEBRTC_LOGGING_HANDLER_HOST_H_ 6 #define CHROME_BROWSER_MEDIA_WEBRTC_LOGGING_HANDLER_HOST_H_
7 7
8 #include "base/basictypes.h" 8 #include "base/basictypes.h"
9 #include "base/memory/shared_memory.h" 9 #include "base/memory/shared_memory.h"
10 #include "chrome/browser/media/rtp_dump_type.h"
11 #include "chrome/browser/media/webrtc_rtp_dump_handler.h"
12 #include "chrome/common/media/webrtc_logging_message_data.h" 10 #include "chrome/common/media/webrtc_logging_message_data.h"
13 #include "content/public/browser/browser_message_filter.h" 11 #include "content/public/browser/browser_message_filter.h"
14 #include "content/public/browser/render_process_host.h"
15 #include "net/base/net_util.h" 12 #include "net/base/net_util.h"
16 13
17 namespace net { 14 namespace net {
18 class URLRequestContextGetter; 15 class URLRequestContextGetter;
19 } // namespace net 16 } // namespace net
20 17
21 class PartialCircularBuffer; 18 class PartialCircularBuffer;
22 class Profile; 19 class Profile;
20 class RenderProcessHost;
23 21
24 typedef std::map<std::string, std::string> MetaDataMap; 22 typedef std::map<std::string, std::string> MetaDataMap;
25 23
26 // WebRtcLoggingHandlerHost handles operations regarding the WebRTC logging: 24 // WebRtcLoggingHandlerHost handles operations regarding the WebRTC logging:
27 // - Opens a shared memory buffer that the handler in the render process 25 // - Opens a shared memory buffer that the handler in the render process
28 // writes to. 26 // writes to.
29 // - Writes basic machine info to the log. 27 // - Writes basic machine info to the log.
30 // - Informs the handler in the render process when to stop logging. 28 // - Informs the handler in the render process when to stop logging.
31 // - Closes the shared memory (and thereby discarding it) or triggers uploading 29 // - Closes the shared memory (and thereby discarding it) or triggers uploading
32 // of the log. 30 // of the log.
(...skipping 13 matching lines...) Expand all
46 void SetMetaData(const MetaDataMap& meta_data, 44 void SetMetaData(const MetaDataMap& meta_data,
47 const GenericDoneCallback& callback); 45 const GenericDoneCallback& callback);
48 46
49 // Opens a log and starts logging. Must be called on the IO thread. 47 // Opens a log and starts logging. Must be called on the IO thread.
50 void StartLogging(const GenericDoneCallback& callback); 48 void StartLogging(const GenericDoneCallback& callback);
51 49
52 // Stops logging. Log will remain open until UploadLog or DiscardLog is 50 // Stops logging. Log will remain open until UploadLog or DiscardLog is
53 // called. Must be called on the IO thread. 51 // called. Must be called on the IO thread.
54 void StopLogging(const GenericDoneCallback& callback); 52 void StopLogging(const GenericDoneCallback& callback);
55 53
56 // Uploads the log and the RTP dumps. Discards the local copy. May only be 54 // Uploads the log and discards the local copy. May only be called after
57 // called after logging has stopped. Must be called on the IO thread. 55 // logging has stopped. Must be called on the IO thread.
58 void UploadLog(const UploadDoneCallback& callback); 56 void UploadLog(const UploadDoneCallback& callback);
59 57
60 // Called by WebRtcLogUploader when uploading has finished. Must be called on 58 // Called by WebRtcLogUploader when uploading has finished. Must be called on
61 // the IO thread. 59 // the IO thread.
62 void UploadLogDone(); 60 void UploadLogDone();
63 61
64 // Discards the log and the RTP dumps. May only be called after logging has 62 // Discards the log. May only be called after logging has stopped. Must be
65 // stopped. Must be called on the IO thread. 63 // called on the IO thread.
66 void DiscardLog(const GenericDoneCallback& callback); 64 void DiscardLog(const GenericDoneCallback& callback);
67 65
68 // Adds a message to the log. 66 // Adds a message to the log.
69 void LogMessage(const std::string& message); 67 void LogMessage(const std::string& message);
70 68
71 // May be called on any thread. |upload_log_on_render_close_| is used 69 // May be called on any thread. |upload_log_on_render_close_| is used
72 // for decision making and it's OK if it changes before the execution based 70 // for decision making and it's OK if it changes before the execution based
73 // on that decision has finished. 71 // on that decision has finished.
74 void set_upload_log_on_render_close(bool should_upload) { 72 void set_upload_log_on_render_close(bool should_upload) {
75 upload_log_on_render_close_ = should_upload; 73 upload_log_on_render_close_ = should_upload;
76 } 74 }
77 75
78 // Starts dumping the RTP headers for the specified direction. Must be called 76 // Starts dumping the RTP headers for the specified direction. Must be called
79 // on the IO thread. |type| specifies which direction(s) of RTP packets should 77 // on the IO thread. |incoming| and |outgoing| specifies which direction(s) of
80 // be dumped. |callback| will be called when starting the dump is done. 78 // RTP packets should be dumped. |callback| will be called when starting the
81 // |stop_callback| will be called when StopRtpDump is called. 79 // dump is done.
82 void StartRtpDump(RtpDumpType type, 80 void StartRtpDump(bool incoming,
83 const GenericDoneCallback& callback, 81 bool outgoing,
84 const content::RenderProcessHost::WebRtcStopRtpDumpCallback& 82 const GenericDoneCallback& callback);
85 stop_callback);
86 83
87 // Stops dumping the RTP headers for the specified direction. Must be called 84 // Stops dumping the RTP headers for the specified direction. Must be called
88 // on the IO thread. |type| specifies which direction(s) of RTP packet dumping 85 // on the IO thread. |incoming| and |outgoing| specifies which direction(s) of
89 // should be stopped. |callback| will be called when stopping the dump is 86 // RTP packet dumping should be stopped. |callback| will be called when
90 // done. 87 // stopping the dump is done.
91 void StopRtpDump(RtpDumpType type, const GenericDoneCallback& callback); 88 void StopRtpDump(bool incoming,
92 89 bool outgoing,
93 // Called when an RTP packet is sent or received. Must be called on the UI 90 const GenericDoneCallback& callback);
94 // thread.
95 void OnRtpPacket(const uint8* packet_header,
96 size_t header_length,
97 size_t packet_length,
98 bool incoming);
99 91
100 private: 92 private:
101 // States used for protecting from function calls made at non-allowed points 93 // States used for protecting from function calls made at non-allowed points
102 // in time. For example, StartLogging() is only allowed in CLOSED state. 94 // in time. For example, StartLogging() is only allowed in CLOSED state.
103 // Transitions: SetMetaData(): CLOSED -> CLOSED. 95 // Transitions: SetMetaData(): CLOSED -> CLOSED.
104 // StartLogging(): CLOSED -> STARTING. 96 // StartLogging(): CLOSED -> STARTING.
105 // Start done: STARTING -> STARTED. 97 // Start done: STARTING -> STARTED.
106 // StopLogging(): STARTED -> STOPPING. 98 // StopLogging(): STARTED -> STOPPING.
107 // Stop done: STOPPING -> STOPPED. 99 // Stop done: STOPPING -> STOPPED.
108 // UploadLog(): STOPPED -> UPLOADING. 100 // UploadLog(): STOPPED -> UPLOADING.
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
140 void LogInitialInfoOnIOThread(const net::NetworkInterfaceList& network_list); 132 void LogInitialInfoOnIOThread(const net::NetworkInterfaceList& network_list);
141 void NotifyLoggingStarted(); 133 void NotifyLoggingStarted();
142 134
143 // Writes a formatted log |message| to the |circular_buffer_|. 135 // Writes a formatted log |message| to the |circular_buffer_|.
144 void LogToCircularBuffer(const std::string& message); 136 void LogToCircularBuffer(const std::string& message);
145 137
146 // Gets the log directory path for |profile_| and ensure it exists. Must be 138 // Gets the log directory path for |profile_| and ensure it exists. Must be
147 // called on the FILE thread. 139 // called on the FILE thread.
148 base::FilePath GetLogDirectoryAndEnsureExists(); 140 base::FilePath GetLogDirectoryAndEnsureExists();
149 141
150 void TriggerUpload(const base::FilePath& log_directory); 142 void TriggerUploadLog(const base::FilePath& log_directory);
151
152 // A helper for TriggerUpload to do the real work.
153 void DoUploadLogAndRtpDumps(const base::FilePath& log_directory);
154 143
155 void FireGenericDoneCallback(GenericDoneCallback* callback, 144 void FireGenericDoneCallback(GenericDoneCallback* callback,
156 bool success, 145 bool success,
157 const std::string& error_message); 146 const std::string& error_message);
158 147
159 // Create the RTP dump handler and start dumping. Must be called after making
160 // sure the log directory exists.
161 void CreateRtpDumpHandlerAndStart(RtpDumpType type,
162 GenericDoneCallback callback,
163 const base::FilePath& dump_dir);
164
165 // A helper for starting RTP dump assuming the RTP dump handler has been
166 // created.
167 void DoStartRtpDump(RtpDumpType type, GenericDoneCallback* callback);
168
169 // Adds the packet to the dump on IO thread.
170 void DumpRtpPacketOnIOThread(scoped_ptr<uint8[]> packet_header,
171 size_t header_length,
172 size_t packet_length,
173 bool incoming);
174
175 scoped_ptr<unsigned char[]> log_buffer_; 148 scoped_ptr<unsigned char[]> log_buffer_;
176 scoped_ptr<PartialCircularBuffer> circular_buffer_; 149 scoped_ptr<PartialCircularBuffer> circular_buffer_;
177 150
178 // The profile associated with our renderer process. 151 // The profile associated with our renderer process.
179 Profile* profile_; 152 Profile* profile_;
180 153
181 // These are only accessed on the IO thread, except when in STARTING state. In 154 // These are only accessed on the IO thread, except when in STARTING state. In
182 // this state we are protected since entering any function that alters the 155 // this state we are protected since entering any function that alters the
183 // state is not allowed. 156 // state is not allowed.
184 MetaDataMap meta_data_; 157 MetaDataMap meta_data_;
(...skipping 14 matching lines...) Expand all
199 172
200 // This is the handle to be passed to the render process. It's stored so that 173 // This is the handle to be passed to the render process. It's stored so that
201 // it doesn't have to be passed on when posting messages between threads. 174 // it doesn't have to be passed on when posting messages between threads.
202 // It's only accessed on the IO thread. 175 // It's only accessed on the IO thread.
203 base::SharedMemoryHandle foreign_memory_handle_; 176 base::SharedMemoryHandle foreign_memory_handle_;
204 177
205 // The system time in ms when logging is started. Reset when logging_state_ 178 // The system time in ms when logging is started. Reset when logging_state_
206 // changes to STOPPED. 179 // changes to STOPPED.
207 base::Time logging_started_time_; 180 base::Time logging_started_time_;
208 181
209 // The RTP dump handler responsible for creating the RTP header dump files.
210 scoped_ptr<WebRtcRtpDumpHandler> rtp_dump_handler_;
211
212 // The callback to call when StopRtpDump is called.
213 content::RenderProcessHost::WebRtcStopRtpDumpCallback stop_rtp_dump_callback_;
214
215 DISALLOW_COPY_AND_ASSIGN(WebRtcLoggingHandlerHost); 182 DISALLOW_COPY_AND_ASSIGN(WebRtcLoggingHandlerHost);
216 }; 183 };
217 184
218 #endif // CHROME_BROWSER_MEDIA_WEBRTC_LOGGING_HANDLER_HOST_H_ 185 #endif // CHROME_BROWSER_MEDIA_WEBRTC_LOGGING_HANDLER_HOST_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698