Home | History | Annotate | Download | only in utility
      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
      3 // found in the LICENSE file.
      4 
      5 #include "media/cast/test/utility/standalone_cast_environment.h"
      6 
      7 #include "base/time/default_tick_clock.h"
      8 
      9 namespace media {
     10 namespace cast {
     11 
     12 StandaloneCastEnvironment::StandaloneCastEnvironment()
     13     : CastEnvironment(
     14           make_scoped_ptr<base::TickClock>(new base::DefaultTickClock()),
     15           NULL,
     16           NULL,
     17           NULL),
     18       main_thread_("StandaloneCastEnvironment Main"),
     19       audio_thread_("StandaloneCastEnvironment Audio"),
     20       video_thread_("StandaloneCastEnvironment Video") {
     21 #define CREATE_TASK_RUNNER(name, options)   \
     22   name##_thread_.StartWithOptions(options); \
     23   CastEnvironment::name##_thread_proxy_ = name##_thread_.message_loop_proxy()
     24 
     25   CREATE_TASK_RUNNER(main,
     26                      base::Thread::Options(base::MessageLoop::TYPE_IO, 0));
     27   CREATE_TASK_RUNNER(audio, base::Thread::Options());
     28   CREATE_TASK_RUNNER(video, base::Thread::Options());
     29 #undef CREATE_TASK_RUNNER
     30 }
     31 
     32 StandaloneCastEnvironment::~StandaloneCastEnvironment() {
     33   DCHECK(CalledOnValidThread());
     34 }
     35 
     36 void StandaloneCastEnvironment::Shutdown() {
     37   DCHECK(CalledOnValidThread());
     38   main_thread_.Stop();
     39   audio_thread_.Stop();
     40   video_thread_.Stop();
     41 }
     42 
     43 }  // namespace cast
     44 }  // namespace media
     45