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 "chrome/browser/speech/extension_api/tts_extension_api.h" | 5 #include "chrome/browser/speech/extension_api/tts_extension_api.h" |
6 | 6 |
7 #include <string> | 7 #include <string> |
8 | 8 |
9 #include "base/lazy_instance.h" | 9 #include "base/lazy_instance.h" |
10 #include "base/memory/weak_ptr.h" | 10 #include "base/memory/weak_ptr.h" |
(...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
82 | 82 |
83 // One of these is constructed for each utterance, and deleted | 83 // One of these is constructed for each utterance, and deleted |
84 // when the utterance gets any final event. | 84 // when the utterance gets any final event. |
85 class TtsExtensionEventHandler | 85 class TtsExtensionEventHandler |
86 : public UtteranceEventDelegate, | 86 : public UtteranceEventDelegate, |
87 public base::SupportsWeakPtr<TtsExtensionEventHandler> { | 87 public base::SupportsWeakPtr<TtsExtensionEventHandler> { |
88 public: | 88 public: |
89 virtual void OnTtsEvent(Utterance* utterance, | 89 virtual void OnTtsEvent(Utterance* utterance, |
90 TtsEventType event_type, | 90 TtsEventType event_type, |
91 int char_index, | 91 int char_index, |
92 const std::string& error_message) OVERRIDE; | 92 const std::string& error_message) override; |
93 }; | 93 }; |
94 | 94 |
95 void TtsExtensionEventHandler::OnTtsEvent(Utterance* utterance, | 95 void TtsExtensionEventHandler::OnTtsEvent(Utterance* utterance, |
96 TtsEventType event_type, | 96 TtsEventType event_type, |
97 int char_index, | 97 int char_index, |
98 const std::string& error_message) { | 98 const std::string& error_message) { |
99 if (utterance->src_id() < 0) { | 99 if (utterance->src_id() < 0) { |
100 if (utterance->finished()) | 100 if (utterance->finished()) |
101 delete this; | 101 delete this; |
102 return; | 102 return; |
(...skipping 257 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
360 } | 360 } |
361 | 361 |
362 static base::LazyInstance<BrowserContextKeyedAPIFactory<TtsAPI> > g_factory = | 362 static base::LazyInstance<BrowserContextKeyedAPIFactory<TtsAPI> > g_factory = |
363 LAZY_INSTANCE_INITIALIZER; | 363 LAZY_INSTANCE_INITIALIZER; |
364 | 364 |
365 BrowserContextKeyedAPIFactory<TtsAPI>* TtsAPI::GetFactoryInstance() { | 365 BrowserContextKeyedAPIFactory<TtsAPI>* TtsAPI::GetFactoryInstance() { |
366 return g_factory.Pointer(); | 366 return g_factory.Pointer(); |
367 } | 367 } |
368 | 368 |
369 } // namespace extensions | 369 } // namespace extensions |
OLD | NEW |