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

Side by Side Diff: chrome/browser/media/rtc_event_log_handler.h

Issue 1650133002: Start and stop RTC event logs from private extension API. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Unused includes Created 4 years, 9 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
OLDNEW
(Empty)
1 // Copyright 2016 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4
5 #ifndef CHROME_BROWSER_MEDIA_RTC_EVENT_LOG_HANDLER_H_
6 #define CHROME_BROWSER_MEDIA_RTC_EVENT_LOG_HANDLER_H_
7
8 #include <stddef.h>
9 #include <stdint.h>
10
11 #include "base/callback.h"
12 #include "base/files/file_path.h"
13 #include "base/memory/ref_counted.h"
14 #include "base/threading/thread_checker.h"
15 #include "base/time/time.h"
16
17 namespace content {
18 class RenderProcessHost;
19 } // namespace content
20 class Profile;
21
22 // WebRtcEventLogHandler provides an interface to start and stop
23 // the WebRTC event log.
24 class WebRtcEventLogHandler
25 : public base::RefCountedThreadSafe<WebRtcEventLogHandler> {
26 public:
27 typedef base::Callback<void(bool, const std::string&)> GenericDoneCallback;
28 typedef base::Callback<void(const std::string&)> RecordingErrorCallback;
29 typedef base::Callback<void(const std::string&, bool, bool)>
30 RecordingDoneCallback;
31
32 // Key used to attach the handler to the RenderProcessHost.
33 static const char kWebRtcEventLogHandlerKey[];
34
35 explicit WebRtcEventLogHandler(Profile* profile);
36
37 // Starts an RTC event log. The call writes the most recent events to a
38 // file and then starts logging events for the given |delay|.
39 // If |delay| is zero, the logging will continue until
40 // StopWebRtcEventLogging()
41 // is explicitly invoked.
42 // |callback| is invoked once recording stops. If |delay| is zero
43 // |callback| is invoked once recording starts.
44 // If a recording was already in progress, |error_callback| is invoked instead
45 // of |callback|.
46 void StartWebRtcEventLogging(content::RenderProcessHost* host,
47 base::TimeDelta delay,
48 const RecordingDoneCallback& callback,
49 const RecordingErrorCallback& error_callback);
50
51 // Stops an RTC event log. |callback| is invoked once recording
52 // stops. If no recording was in progress, |error_callback| is invoked instead
53 // of |callback|.
54 void StopWebRtcEventLogging(content::RenderProcessHost* host,
55 const RecordingDoneCallback& callback,
56 const RecordingErrorCallback& error_callback);
57
58 private:
59 friend class base::RefCountedThreadSafe<WebRtcEventLogHandler>;
60 virtual ~WebRtcEventLogHandler();
61
62 base::FilePath GetLogDirectoryAndEnsureExists();
63
64 // Helper for starting RTC event logs.
65 void DoStartWebRtcEventLogging(content::RenderProcessHost* host,
66 base::TimeDelta delay,
67 const RecordingDoneCallback& callback,
68 const RecordingErrorCallback& error_callback,
69 const base::FilePath& log_directory);
70
71 // Helper for stopping RTC event logs.
72 void DoStopWebRtcEventLogging(content::RenderProcessHost* host,
73 bool is_manual_stop,
74 uint64_t audio_debug_recordings_id,
75 const RecordingDoneCallback& callback,
76 const RecordingErrorCallback& error_callback,
77 const base::FilePath& log_directory);
78
79 // The profile associated with our renderer process.
80 Profile* const profile_;
81
82 // Must be accessed on the UI thread.
83 bool is_rtc_event_logging_in_progress_;
84
85 // This counter allows saving each log in a separate file.
86 uint64_t current_rtc_event_log_id_;
87
88 base::ThreadChecker thread_checker_;
89 DISALLOW_COPY_AND_ASSIGN(WebRtcEventLogHandler);
90 };
91
92 #endif // CHROME_BROWSER_MEDIA_RTC_EVENT_LOG_HANDLER_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698