| OLD | NEW | 
|    1 // Copyright 2014 The Chromium Authors. All rights reserved. |    1 // Copyright 2014 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 #include "chromecast/media/cma/base/balanced_media_task_runner_factory.h" |    5 #include "chromecast/media/cma/base/balanced_media_task_runner_factory.h" | 
|    6  |    6  | 
|    7 #include <map> |    7 #include <map> | 
|    8  |    8  | 
|    9 #include "base/bind.h" |    9 #include "base/bind.h" | 
|   10 #include "base/callback_helpers.h" |   10 #include "base/callback_helpers.h" | 
| (...skipping 14 matching lines...) Expand all  Loading... | 
|   25   //   |new_task_cb| is invoked in that case. |   25   //   |new_task_cb| is invoked in that case. | 
|   26   // - monitor the lifetime of the media task runner, i.e. check when the media |   26   // - monitor the lifetime of the media task runner, i.e. check when the media | 
|   27   //   task runner is not needed anymore. |   27   //   task runner is not needed anymore. | 
|   28   //   |shutdown_cb| is invoked in that case. |   28   //   |shutdown_cb| is invoked in that case. | 
|   29   MediaTaskRunnerWithNotification( |   29   MediaTaskRunnerWithNotification( | 
|   30       const scoped_refptr<MediaTaskRunner>& media_task_runner, |   30       const scoped_refptr<MediaTaskRunner>& media_task_runner, | 
|   31       const base::Closure& new_task_cb, |   31       const base::Closure& new_task_cb, | 
|   32       const base::Closure& shutdown_cb); |   32       const base::Closure& shutdown_cb); | 
|   33  |   33  | 
|   34   // MediaTaskRunner implementation. |   34   // MediaTaskRunner implementation. | 
|   35   virtual bool PostMediaTask( |   35   bool PostMediaTask( | 
|   36       const tracked_objects::Location& from_here, |   36       const tracked_objects::Location& from_here, | 
|   37       const base::Closure& task, |   37       const base::Closure& task, | 
|   38       base::TimeDelta timestamp) override; |   38       base::TimeDelta timestamp) override; | 
|   39  |   39  | 
|   40  private: |   40  private: | 
|   41   virtual ~MediaTaskRunnerWithNotification(); |   41   ~MediaTaskRunnerWithNotification() override; | 
|   42  |   42  | 
|   43   scoped_refptr<MediaTaskRunner> const media_task_runner_; |   43   scoped_refptr<MediaTaskRunner> const media_task_runner_; | 
|   44  |   44  | 
|   45   const base::Closure new_task_cb_; |   45   const base::Closure new_task_cb_; | 
|   46   const base::Closure shutdown_cb_; |   46   const base::Closure shutdown_cb_; | 
|   47  |   47  | 
|   48   DISALLOW_COPY_AND_ASSIGN(MediaTaskRunnerWithNotification); |   48   DISALLOW_COPY_AND_ASSIGN(MediaTaskRunnerWithNotification); | 
|   49 }; |   49 }; | 
|   50  |   50  | 
|   51 MediaTaskRunnerWithNotification::MediaTaskRunnerWithNotification( |   51 MediaTaskRunnerWithNotification::MediaTaskRunnerWithNotification( | 
| (...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
|   86       const scoped_refptr<base::SingleThreadTaskRunner>& task_runner); |   86       const scoped_refptr<base::SingleThreadTaskRunner>& task_runner); | 
|   87  |   87  | 
|   88   // Schedule tasks whose timestamp is less than or equal to |max_timestamp|. |   88   // Schedule tasks whose timestamp is less than or equal to |max_timestamp|. | 
|   89   void ScheduleWork(base::TimeDelta max_timestamp); |   89   void ScheduleWork(base::TimeDelta max_timestamp); | 
|   90  |   90  | 
|   91   // Return the timestamp of the last media task. |   91   // Return the timestamp of the last media task. | 
|   92   // Return ::media::kNoTimestamp() if no media task has been posted. |   92   // Return ::media::kNoTimestamp() if no media task has been posted. | 
|   93   base::TimeDelta GetMediaTimestamp() const; |   93   base::TimeDelta GetMediaTimestamp() const; | 
|   94  |   94  | 
|   95   // MediaTaskRunner implementation. |   95   // MediaTaskRunner implementation. | 
|   96   virtual bool PostMediaTask( |   96   bool PostMediaTask( | 
|   97       const tracked_objects::Location& from_here, |   97       const tracked_objects::Location& from_here, | 
|   98       const base::Closure& task, |   98       const base::Closure& task, | 
|   99       base::TimeDelta timestamp) override; |   99       base::TimeDelta timestamp) override; | 
|  100  |  100  | 
|  101  private: |  101  private: | 
|  102   virtual ~BalancedMediaTaskRunner(); |  102   ~BalancedMediaTaskRunner() override; | 
|  103  |  103  | 
|  104   scoped_refptr<base::SingleThreadTaskRunner> const task_runner_; |  104   scoped_refptr<base::SingleThreadTaskRunner> const task_runner_; | 
|  105  |  105  | 
|  106   // Protects the following variables. |  106   // Protects the following variables. | 
|  107   mutable base::Lock lock_; |  107   mutable base::Lock lock_; | 
|  108  |  108  | 
|  109   // Possible pending media task. |  109   // Possible pending media task. | 
|  110   tracked_objects::Location from_here_; |  110   tracked_objects::Location from_here_; | 
|  111   base::Closure pending_task_; |  111   base::Closure pending_task_; | 
|  112  |  112  | 
| (...skipping 130 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
|  243 } |  243 } | 
|  244  |  244  | 
|  245 void BalancedMediaTaskRunnerFactory::UnregisterMediaTaskRunner( |  245 void BalancedMediaTaskRunnerFactory::UnregisterMediaTaskRunner( | 
|  246       const scoped_refptr<BalancedMediaTaskRunner>& media_task_runner) { |  246       const scoped_refptr<BalancedMediaTaskRunner>& media_task_runner) { | 
|  247   base::AutoLock auto_lock(lock_); |  247   base::AutoLock auto_lock(lock_); | 
|  248   task_runners_.erase(media_task_runner); |  248   task_runners_.erase(media_task_runner); | 
|  249 } |  249 } | 
|  250  |  250  | 
|  251 }  // namespace media |  251 }  // namespace media | 
|  252 }  // namespace chromecast |  252 }  // namespace chromecast | 
| OLD | NEW |