Change CdmFileIO UMA logging

Adds new UMA that logs the total time spent in the browser to read,
write, or delete a file used by the CDM. This is split by whether the
CDM is used in an incognito or non-incognito window.

This also deprecates the previous Media.EME.CdmFileIO.ReadTime and
WriteTime UMA as they are no longer generated.

This CL is manually tested as follows:
1. Build browser_test and run the following:
   out/Debug/browser_tests
   --gtest_filter=CDM_11/ECKEncryptedMediaTest.FileIOTest/0
   -v=1
   where -v=1 will print out all histograms at the end.
2. Made sure we have the following:
   Histogram: Media.EME.CdmFileIO.TimeTo.DeleteFile.Normal recorded 3 samples, ...
   0  ------------------------------------O                   (1 = 33.3%)
   1  ------------------------------------------------------O (2 = 66.7%) {33.3%}
   2  ...

   Histogram: Media.EME.CdmFileIO.TimeTo.ReadFile.Normal recorded 129 samples, ...
   0  ---O                                                    (4 = 3.1%)
   1  --O                                                     (3 = 2.3%) {3.1%}
   2  ------------------------------------------------------O (106 = 82.2%) {5.4%}
   3  ----------O                                             (15 = 11.6%) {87.6%}
   4  -O                                                      (1 = 0.8%) {99.2%}
   5  ...

   Histogram: Media.EME.CdmFileIO.TimeTo.WriteFile.Normal recorded 124 samples, ...
   0   ...
   8   -----------------------------------------------------O (99 = 79.8%) {0.0%}
   10  --------------O                                        (19 = 15.3%) {79.8%}
   12  --O                                                    (3 = 2.4%) {95.2%}
   14  -O                                                     (2 = 1.6%) {97.6%}
   17  O                                                      (1 = 0.8%) {99.2%}
   20  ...

Bug: 958294
Test: Ran several EME browser_tests with UMA logging enabled
Change-Id: Ib177c54eed1cbdc16d42a0096e4177983ce22cfd
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1743133
Commit-Queue: John Rummell <[email protected]>
Reviewed-by: Xiaohan Wang <[email protected]>
Reviewed-by: Daniel Cheng <[email protected]>
Reviewed-by: Mark Pearson <[email protected]>
Cr-Commit-Position: refs/heads/master@{#687898}
diff --git a/content/browser/media/cdm_file_impl.h b/content/browser/media/cdm_file_impl.h
index b8bfc99f..9acf60d 100644
--- a/content/browser/media/cdm_file_impl.h
+++ b/content/browser/media/cdm_file_impl.h
@@ -15,6 +15,7 @@
 #include "base/memory/weak_ptr.h"
 #include "base/threading/sequence_bound.h"
 #include "base/threading/thread_checker.h"
+#include "base/time/time.h"
 #include "media/mojo/mojom/cdm_storage.mojom.h"
 #include "storage/browser/fileapi/async_file_util.h"
 #include "url/origin.h"
@@ -80,6 +81,9 @@
   bool AcquireFileLock(const std::string& file_name);
   void ReleaseFileLock(const std::string& file_name);
 
+  // Report operation time to UMA.
+  void ReportFileOperationTimeUMA(const std::string& uma_name);
+
   // Names of the files this class represents.
   const std::string file_name_;
   const std::string temp_file_name_;
@@ -107,6 +111,9 @@
   WriteCallback write_callback_;
   base::SequenceBound<FileWriter> file_writer_;
 
+  // Time when the read or write operation starts.
+  base::TimeTicks start_time_;
+
   THREAD_CHECKER(thread_checker_);
   base::WeakPtrFactory<CdmFileImpl> weak_factory_{this};