OLD | NEW |
1 // Copyright 2016 The Chromium Authors. All rights reserved. | 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 | 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 IOS_CHROME_BROWSER_UI_WEBUI_HISTORY_METRICS_HANDLER_H_ | 5 #ifndef MEDIA_BASE_MAC_VIDEOTOOLBOX_HELPERS_H_ |
6 #define IOS_CHROME_BROWSER_UI_WEBUI_HISTORY_METRICS_HANDLER_H_ | 6 #define MEDIA_BASE_MAC_VIDEOTOOLBOX_HELPERS_H_ |
7 | 7 |
8 #include "base/compiler_specific.h" | 8 #include "base/mac/scoped_cftyperef.h" |
9 #include "base/macros.h" | 9 #include "media/base/mac/videotoolbox_glue.h" |
10 #include "ios/public/provider/web/web_ui_ios_message_handler.h" | 10 #include "media/base/media_export.h" |
11 | 11 |
12 /////////////////////////////////////////////////////////////////////////////// | 12 namespace media { |
13 // MetricsHandler | |
14 | 13 |
15 // Let the page contents record UMA actions. Only use when you can't do it from | 14 namespace video_toolbox { |
16 // C++. For example, we currently use it to let the NTP log the position of the | |
17 // Most Visited or Bookmark the user clicked on, as we don't get that | |
18 // information through RequestOpenURL. You will need to update the metrics | |
19 // dashboard with the action names you use, as our processor won't catch that | |
20 // information (treat it as RecordComputedMetrics) | |
21 | 15 |
22 namespace base { | 16 // Create a CFDictionaryRef with the given keys and values. |
23 class ListValue; | 17 MEDIA_EXPORT base::ScopedCFTypeRef<CFDictionaryRef> |
24 } | 18 DictionaryWithKeysAndValues(CFTypeRef* keys, CFTypeRef* values, size_t size); |
25 | 19 |
26 class MetricsHandler : public web::WebUIIOSMessageHandler { | 20 // Create a CFDictionaryRef with the given key and value. |
| 21 MEDIA_EXPORT base::ScopedCFTypeRef<CFDictionaryRef> DictionaryWithKeyValue( |
| 22 CFTypeRef key, |
| 23 CFTypeRef value); |
| 24 |
| 25 // Create a CFArrayRef with the given array of integers. |
| 26 MEDIA_EXPORT base::ScopedCFTypeRef<CFArrayRef> ArrayWithIntegers(const int* v, |
| 27 size_t size); |
| 28 |
| 29 // Copy a H.264 frame stored in a CM sample buffer to an Annex B buffer. Copies |
| 30 // parameter sets for keyframes before the frame data as well. |
| 31 MEDIA_EXPORT bool CopySampleBufferToAnnexBBuffer( |
| 32 CoreMediaGlue::CMSampleBufferRef sbuf, |
| 33 bool keyframe, |
| 34 std::string* annexb_buffer); |
| 35 MEDIA_EXPORT bool CopySampleBufferToAnnexBBuffer( |
| 36 CoreMediaGlue::CMSampleBufferRef sbuf, |
| 37 bool keyframe, |
| 38 size_t annexb_buffer_size, |
| 39 char* annexb_buffer, |
| 40 size_t* used_buffer_size); |
| 41 |
| 42 // Helper class to add session properties to a VTCompressionSessionRef. |
| 43 class MEDIA_EXPORT SessionPropertySetter { |
27 public: | 44 public: |
28 MetricsHandler(); | 45 SessionPropertySetter( |
29 ~MetricsHandler() override; | 46 base::ScopedCFTypeRef<VideoToolboxGlue::VTCompressionSessionRef> session, |
| 47 const VideoToolboxGlue* const glue); |
| 48 ~SessionPropertySetter(); |
30 | 49 |
31 // WebUIIOSMessageHandler implementation. | 50 bool SetSessionProperty(CFStringRef key, int32_t value); |
32 void RegisterMessages() override; | 51 bool SetSessionProperty(CFStringRef key, bool value); |
33 | 52 bool SetSessionProperty(CFStringRef key, CFStringRef value); |
34 // Callback for the "metricsHandler:recordAction" message. This records a | 53 bool SetSessionProperty(CFStringRef key, CFArrayRef value); |
35 // user action. | |
36 void HandleRecordAction(const base::ListValue* args); | |
37 | |
38 // TODO(dbeam): http://crbug.com/104338 | |
39 | |
40 // Callback for the "metricsHandler:recordInHistogram" message. This records | |
41 // into a histogram. |args| contains the histogram name, the value to record, | |
42 // and the maximum allowed value, which can be at most 4000. The histogram | |
43 // will use at most 100 buckets, one for each 1, 10, or 100 different values, | |
44 // depending on the maximum value. | |
45 void HandleRecordInHistogram(const base::ListValue* args); | |
46 | 54 |
47 private: | 55 private: |
48 DISALLOW_COPY_AND_ASSIGN(MetricsHandler); | 56 base::ScopedCFTypeRef<VideoToolboxGlue::VTCompressionSessionRef> session_; |
| 57 const VideoToolboxGlue* glue_; |
49 }; | 58 }; |
50 | 59 |
51 #endif // IOS_CHROME_BROWSER_UI_WEBUI_HISTORY_METRICS_HANDLER_H_ | 60 } // namespace video_toolbox |
| 61 |
| 62 } // namespace media |
| 63 |
| 64 #endif // MEDIA_BASE_MAC_VIDEOTOOLBOX_HELPERS_H_ |
OLD | NEW |