| OLD | NEW |
| (Empty) |
| 1 // Copyright 2015 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/base/android/media_task_runner.h" | |
| 6 | |
| 7 #include "base/command_line.h" | |
| 8 #include "base/lazy_instance.h" | |
| 9 #include "base/metrics/field_trial.h" | |
| 10 #include "base/strings/string_util.h" | |
| 11 #include "base/threading/thread.h" | |
| 12 #include "media/base/media_switches.h" | |
| 13 | |
| 14 namespace media { | |
| 15 | |
| 16 class MediaThread : public base::Thread { | |
| 17 public: | |
| 18 MediaThread() : base::Thread("BrowserMediaThread") { | |
| 19 Start(); | |
| 20 } | |
| 21 }; | |
| 22 | |
| 23 // Create media thread | |
| 24 base::LazyInstance<MediaThread>::Leaky g_media_thread = | |
| 25 LAZY_INSTANCE_INITIALIZER; | |
| 26 | |
| 27 scoped_refptr<base::SingleThreadTaskRunner> GetMediaTaskRunner() { | |
| 28 return g_media_thread.Pointer()->task_runner(); | |
| 29 } | |
| 30 | |
| 31 bool UseMediaThreadForMediaPlayback() { | |
| 32 const std::string group_name = | |
| 33 base::FieldTrialList::FindFullName("EnableMediaThreadForMediaPlayback"); | |
| 34 | |
| 35 // Command line switches take precedence over filed trial groups. | |
| 36 // The disable switch takes precedence over enable switch. | |
| 37 if (base::CommandLine::ForCurrentProcess()->HasSwitch( | |
| 38 switches::kDisableMediaThreadForMediaPlayback)) { | |
| 39 return false; | |
| 40 } | |
| 41 | |
| 42 if (base::CommandLine::ForCurrentProcess()->HasSwitch( | |
| 43 switches::kEnableMediaThreadForMediaPlayback)) { | |
| 44 return true; | |
| 45 } | |
| 46 | |
| 47 DVLOG(1) << __FUNCTION__ << ": group_name:'" << group_name << "'"; | |
| 48 | |
| 49 return base::StartsWith(group_name, "Enabled", base::CompareCase::SENSITIVE); | |
| 50 } | |
| 51 | |
| 52 } // namespace media | |
| OLD | NEW |