| OLD | NEW |
| 1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 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/chromeos/arc/arc_tts_service.h" | 5 #include "chrome/browser/chromeos/arc/arc_tts_service.h" |
| 6 | 6 |
| 7 #include "base/logging.h" | 7 #include "base/logging.h" |
| 8 #include "chrome/browser/speech/tts_controller.h" | 8 #include "chrome/browser/speech/tts_controller.h" |
| 9 #include "components/arc/arc_bridge_service.h" | 9 #include "components/arc/arc_bridge_service.h" |
| 10 | 10 |
| 11 namespace arc { | 11 namespace arc { |
| 12 | 12 |
| 13 ArcTtsService::ArcTtsService(ArcBridgeService* bridge_service) | 13 ArcTtsService::ArcTtsService(ArcBridgeService* bridge_service) |
| 14 : ArcService(bridge_service), binding_(this) { | 14 : ArcService(bridge_service), binding_(this) { |
| 15 arc_bridge_service()->tts()->AddObserver(this); | 15 arc_bridge_service()->tts()->AddObserver(this); |
| 16 } | 16 } |
| 17 | 17 |
| 18 ArcTtsService::~ArcTtsService() { | 18 ArcTtsService::~ArcTtsService() { |
| 19 arc_bridge_service()->tts()->RemoveObserver(this); | 19 arc_bridge_service()->tts()->RemoveObserver(this); |
| 20 } | 20 } |
| 21 | 21 |
| 22 void ArcTtsService::OnInstanceReady() { | 22 void ArcTtsService::OnInstanceReady() { |
| 23 mojom::TtsInstance* tts_instance = arc_bridge_service()->tts()->instance(); | 23 mojom::TtsInstance* tts_instance = |
| 24 if (!tts_instance) { | 24 arc_bridge_service()->tts()->GetInstanceForMethod("Init"); |
| 25 LOG(ERROR) << "OnTtsInstanceReady called, " | 25 CHECK(tts_instance); |
| 26 << "but no tts instance found"; | |
| 27 return; | |
| 28 } | |
| 29 tts_instance->Init(binding_.CreateInterfacePtrAndBind()); | 26 tts_instance->Init(binding_.CreateInterfacePtrAndBind()); |
| 30 } | 27 } |
| 31 | 28 |
| 32 void ArcTtsService::OnTtsEvent(uint32_t id, | 29 void ArcTtsService::OnTtsEvent(uint32_t id, |
| 33 mojom::TtsEventType event_type, | 30 mojom::TtsEventType event_type, |
| 34 uint32_t char_index, | 31 uint32_t char_index, |
| 35 const mojo::String& error_msg) { | 32 const mojo::String& error_msg) { |
| 36 if (!TtsController::GetInstance()) | 33 if (!TtsController::GetInstance()) |
| 37 return; | 34 return; |
| 38 | 35 |
| (...skipping 10 matching lines...) Expand all Loading... |
| 49 break; | 46 break; |
| 50 case mojom::TtsEventType::ERROR: | 47 case mojom::TtsEventType::ERROR: |
| 51 chrome_event_type = TTS_EVENT_ERROR; | 48 chrome_event_type = TTS_EVENT_ERROR; |
| 52 break; | 49 break; |
| 53 } | 50 } |
| 54 TtsController::GetInstance()->OnTtsEvent(id, chrome_event_type, char_index, | 51 TtsController::GetInstance()->OnTtsEvent(id, chrome_event_type, char_index, |
| 55 error_msg); | 52 error_msg); |
| 56 } | 53 } |
| 57 | 54 |
| 58 } // namespace arc | 55 } // namespace arc |
| OLD | NEW |