| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 <math.h> | 5 #include <math.h> |
| 6 | 6 |
| 7 #include <map> | 7 #include <map> |
| 8 | 8 |
| 9 #include "base/command_line.h" |
| 9 #include "base/debug/leak_annotations.h" | 10 #include "base/debug/leak_annotations.h" |
| 10 #include "base/memory/scoped_ptr.h" | 11 #include "base/memory/scoped_ptr.h" |
| 11 #include "base/memory/singleton.h" | 12 #include "base/memory/singleton.h" |
| 12 #include "base/synchronization/lock.h" | 13 #include "base/synchronization/lock.h" |
| 13 #include "chrome/browser/speech/tts_platform.h" | 14 #include "chrome/browser/speech/tts_platform.h" |
| 15 #include "chrome/common/chrome_switches.h" |
| 14 #include "content/public/browser/browser_thread.h" | 16 #include "content/public/browser/browser_thread.h" |
| 15 | 17 |
| 16 #include "library_loaders/libspeechd.h" | 18 #include "library_loaders/libspeechd.h" |
| 17 | 19 |
| 18 using content::BrowserThread; | 20 using content::BrowserThread; |
| 19 | 21 |
| 20 namespace { | 22 namespace { |
| 21 | 23 |
| 22 const char kNotSupportedError[] = | 24 const char kNotSupportedError[] = |
| 23 "Native speech synthesis not supported on this platform."; | 25 "Native speech synthesis not supported on this platform."; |
| (...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 86 | 88 |
| 87 DISALLOW_COPY_AND_ASSIGN(TtsPlatformImplLinux); | 89 DISALLOW_COPY_AND_ASSIGN(TtsPlatformImplLinux); |
| 88 }; | 90 }; |
| 89 | 91 |
| 90 // static | 92 // static |
| 91 SPDNotificationType TtsPlatformImplLinux::current_notification_ = | 93 SPDNotificationType TtsPlatformImplLinux::current_notification_ = |
| 92 SPD_EVENT_END; | 94 SPD_EVENT_END; |
| 93 | 95 |
| 94 TtsPlatformImplLinux::TtsPlatformImplLinux() | 96 TtsPlatformImplLinux::TtsPlatformImplLinux() |
| 95 : utterance_id_(0) { | 97 : utterance_id_(0) { |
| 98 const CommandLine& command_line = *CommandLine::ForCurrentProcess(); |
| 99 if (!command_line.HasSwitch(switches::kEnableSpeechDispatcher)) |
| 100 return; |
| 101 |
| 96 BrowserThread::PostTask(BrowserThread::FILE, | 102 BrowserThread::PostTask(BrowserThread::FILE, |
| 97 FROM_HERE, | 103 FROM_HERE, |
| 98 base::Bind(&TtsPlatformImplLinux::Initialize, | 104 base::Bind(&TtsPlatformImplLinux::Initialize, |
| 99 base::Unretained(this))); | 105 base::Unretained(this))); |
| 100 } | 106 } |
| 101 | 107 |
| 102 void TtsPlatformImplLinux::Initialize() { | 108 void TtsPlatformImplLinux::Initialize() { |
| 103 base::AutoLock lock(initialization_lock_); | 109 base::AutoLock lock(initialization_lock_); |
| 104 | 110 |
| 105 if (!libspeechd_loader_.Load("libspeechd.so.2")) | 111 if (!libspeechd_loader_.Load("libspeechd.so.2")) |
| (...skipping 231 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 337 // static | 343 // static |
| 338 TtsPlatformImplLinux* TtsPlatformImplLinux::GetInstance() { | 344 TtsPlatformImplLinux* TtsPlatformImplLinux::GetInstance() { |
| 339 return Singleton<TtsPlatformImplLinux, | 345 return Singleton<TtsPlatformImplLinux, |
| 340 LeakySingletonTraits<TtsPlatformImplLinux> >::get(); | 346 LeakySingletonTraits<TtsPlatformImplLinux> >::get(); |
| 341 } | 347 } |
| 342 | 348 |
| 343 // static | 349 // static |
| 344 TtsPlatformImpl* TtsPlatformImpl::GetInstance() { | 350 TtsPlatformImpl* TtsPlatformImpl::GetInstance() { |
| 345 return TtsPlatformImplLinux::GetInstance(); | 351 return TtsPlatformImplLinux::GetInstance(); |
| 346 } | 352 } |
| OLD | NEW |