Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(15)

Side by Side Diff: chrome/browser/speech/tts_controller_impl.h

Issue 412783002: Separate out the TtsController interface from it's impl (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fix coding style Created 6 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « chrome/browser/speech/tts_controller.cc ('k') | chrome/browser/speech/tts_controller_impl.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
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
3 // found in the LICENSE file.
4
5 #ifndef CHROME_BROWSER_SPEECH_TTS_CONTROLLER_IMPL_H_
6 #define CHROME_BROWSER_SPEECH_TTS_CONTROLLER_IMPL_H_
7
8 #include <queue>
9 #include <set>
10 #include <string>
11 #include <vector>
12
13 #include "base/memory/scoped_ptr.h"
14 #include "base/memory/singleton.h"
15 #include "base/memory/weak_ptr.h"
16 #include "chrome/browser/speech/tts_controller.h"
17 #include "url/gurl.h"
18
19 // Singleton class that manages text-to-speech for the TTS and TTS engine
20 // extension APIs, maintaining a queue of pending utterances and keeping
21 // track of all state.
22 class TtsControllerImpl : public TtsController {
23 public:
24 // Get the single instance of this class.
25 static TtsControllerImpl* GetInstance();
26
27 // TtsController methods
28 virtual bool IsSpeaking() OVERRIDE;
29 virtual void SpeakOrEnqueue(Utterance* utterance) OVERRIDE;
30 virtual void Stop() OVERRIDE;
31 virtual void Pause() OVERRIDE;
32 virtual void Resume() OVERRIDE;
33 virtual void OnTtsEvent(int utterance_id,
34 TtsEventType event_type,
35 int char_index,
36 const std::string& error_message) OVERRIDE;
37 virtual void GetVoices(Profile* profile,
38 std::vector<VoiceData>* out_voices) OVERRIDE;
39 virtual void RetrySpeakingQueuedUtterances() OVERRIDE;
40 virtual void VoicesChanged() OVERRIDE;
41 virtual void AddVoicesChangedDelegate(
42 VoicesChangedDelegate* delegate) OVERRIDE;
43 virtual void RemoveVoicesChangedDelegate(
44 VoicesChangedDelegate* delegate) OVERRIDE;
45 virtual void SetTtsEngineDelegate(TtsEngineDelegate* delegate) OVERRIDE;
46 virtual void SetPlatformImpl(TtsPlatformImpl* platform_impl) OVERRIDE;
47 virtual int QueueSize() OVERRIDE;
48
49 protected:
50 TtsControllerImpl();
51 virtual ~TtsControllerImpl();
52
53 private:
54 // Get the platform TTS implementation (or injected mock).
55 TtsPlatformImpl* GetPlatformImpl();
56
57 // Start speaking the given utterance. Will either take ownership of
58 // |utterance| or delete it if there's an error. Returns true on success.
59 void SpeakNow(Utterance* utterance);
60
61 // Clear the utterance queue. If send_events is true, will send
62 // TTS_EVENT_CANCELLED events on each one.
63 void ClearUtteranceQueue(bool send_events);
64
65 // Finalize and delete the current utterance.
66 void FinishCurrentUtterance();
67
68 // Start speaking the next utterance in the queue.
69 void SpeakNextUtterance();
70
71 // Given an utterance and a vector of voices, return the
72 // index of the voice that best matches the utterance.
73 int GetMatchingVoice(const Utterance* utterance,
74 std::vector<VoiceData>& voices);
75
76 friend struct DefaultSingletonTraits<TtsControllerImpl>;
77
78 // The current utterance being spoken.
79 Utterance* current_utterance_;
80
81 // Whether the queue is paused or not.
82 bool paused_;
83
84 // A queue of utterances to speak after the current one finishes.
85 std::queue<Utterance*> utterance_queue_;
86
87 // A set of delegates that want to be notified when the voices change.
88 std::set<VoicesChangedDelegate*> voices_changed_delegates_;
89
90 // A pointer to the platform implementation of text-to-speech, for
91 // dependency injection.
92 TtsPlatformImpl* platform_impl_;
93
94 // The delegate that processes TTS requests with user-installed extensions.
95 TtsEngineDelegate* tts_engine_delegate_;
96
97 DISALLOW_COPY_AND_ASSIGN(TtsControllerImpl);
98 };
99
100 #endif // CHROME_BROWSER_SPEECH_TTS_CONTROLLER_IMPL_H_
OLDNEW
« no previous file with comments | « chrome/browser/speech/tts_controller.cc ('k') | chrome/browser/speech/tts_controller_impl.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698