Add support for multimedia timers to TaskQueue on Windows.

Multimedia timers are higher precision than WM_TIMER, but they're also
a limited resource and more costly. So this implementation is a best
effort implementation that falls back on WM_TIMER when multimedia
timers aren't available.

A possible future change could be to make high precision timers in a
TaskQueue, optional. The reason for doing so would be for TaskQueues
that don't need high precision timers, won't eat up timers from TQ
instances that really need it.

BUG=webrtc:7151

Review-Url: https://codereview.webrtc.org/2691973002
Cr-Commit-Position: refs/heads/master@{#16661}
diff --git a/webrtc/base/task_queue.h b/webrtc/base/task_queue.h
index eeabe05..a6a7036 100644
--- a/webrtc/base/task_queue.h
+++ b/webrtc/base/task_queue.h
@@ -178,6 +178,11 @@
   void PostTaskAndReply(std::unique_ptr<QueuedTask> task,
                         std::unique_ptr<QueuedTask> reply);
 
+  // Schedules a task to execute a specified number of milliseconds from when
+  // the call is made. The precision should be considered as "best effort"
+  // and in some cases, such as on Windows when all high precision timers have
+  // been used up, can be off by as much as 15 millseconds (although 8 would be
+  // more likely). This can be mitigated by limiting the use of delayed tasks.
   void PostDelayedTask(std::unique_ptr<QueuedTask> task, uint32_t milliseconds);
 
   template <class Closure>
@@ -185,6 +190,7 @@
     PostTask(std::unique_ptr<QueuedTask>(new ClosureTask<Closure>(closure)));
   }
 
+  // See documentation above for performance expectations.
   template <class Closure>
   void PostDelayedTask(const Closure& closure, uint32_t milliseconds) {
     PostDelayedTask(
@@ -254,10 +260,12 @@
   dispatch_queue_t queue_;
   QueueContext* const context_;
 #elif defined(WEBRTC_WIN)
+  class MultimediaTimer;
   typedef std::unordered_map<UINT_PTR, std::unique_ptr<QueuedTask>>
       DelayedTasks;
   static bool ThreadMain(void* context);
-  static bool ProcessQueuedMessages(DelayedTasks* delayed_tasks);
+  static bool ProcessQueuedMessages(DelayedTasks* delayed_tasks,
+                                    std::vector<MultimediaTimer>* timers);
 
   class WorkerThread : public PlatformThread {
    public: