| 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 <queue> | 5 #include <queue> |
| 6 | 6 |
| 7 #include "base/memory/scoped_ptr.h" | 7 #include "base/memory/scoped_ptr.h" |
| 8 #include "base/message_loop/message_loop.h" | 8 #include "base/message_loop/message_loop.h" |
| 9 #include "base/numerics/safe_conversions.h" | 9 #include "base/numerics/safe_conversions.h" |
| 10 #include "base/strings/utf_string_conversions.h" | 10 #include "base/strings/utf_string_conversions.h" |
| (...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 45 void OnSpeechRecognitionEngineResults( | 45 void OnSpeechRecognitionEngineResults( |
| 46 const SpeechRecognitionResults& results) override { | 46 const SpeechRecognitionResults& results) override { |
| 47 results_.push(results); | 47 results_.push(results); |
| 48 } | 48 } |
| 49 void OnSpeechRecognitionEngineError( | 49 void OnSpeechRecognitionEngineError( |
| 50 const SpeechRecognitionError& error) override { | 50 const SpeechRecognitionError& error) override { |
| 51 error_ = error.code; | 51 error_ = error.code; |
| 52 } | 52 } |
| 53 | 53 |
| 54 // testing::Test methods. | 54 // testing::Test methods. |
| 55 virtual void SetUp() override; | 55 void SetUp() override; |
| 56 virtual void TearDown() override; | 56 void TearDown() override; |
| 57 | 57 |
| 58 protected: | 58 protected: |
| 59 enum DownstreamError { | 59 enum DownstreamError { |
| 60 DOWNSTREAM_ERROR_NONE, | 60 DOWNSTREAM_ERROR_NONE, |
| 61 DOWNSTREAM_ERROR_HTTP500, | 61 DOWNSTREAM_ERROR_HTTP500, |
| 62 DOWNSTREAM_ERROR_NETWORK, | 62 DOWNSTREAM_ERROR_NETWORK, |
| 63 DOWNSTREAM_ERROR_WEBSERVICE_NO_MATCH | 63 DOWNSTREAM_ERROR_WEBSERVICE_NO_MATCH |
| 64 }; | 64 }; |
| 65 static bool ResultsAreEqual(const SpeechRecognitionResults& a, | 65 static bool ResultsAreEqual(const SpeechRecognitionResults& a, |
| 66 const SpeechRecognitionResults& b); | 66 const SpeechRecognitionResults& b); |
| (...skipping 423 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 490 | 490 |
| 491 // Prepend 4 byte prefix length indication to the protobuf message as | 491 // Prepend 4 byte prefix length indication to the protobuf message as |
| 492 // envisaged by the google streaming recognition webservice protocol. | 492 // envisaged by the google streaming recognition webservice protocol. |
| 493 uint32 prefix = HostToNet32(checked_cast<uint32>(msg_string.size())); | 493 uint32 prefix = HostToNet32(checked_cast<uint32>(msg_string.size())); |
| 494 msg_string.insert(0, reinterpret_cast<char*>(&prefix), sizeof(prefix)); | 494 msg_string.insert(0, reinterpret_cast<char*>(&prefix), sizeof(prefix)); |
| 495 | 495 |
| 496 return msg_string; | 496 return msg_string; |
| 497 } | 497 } |
| 498 | 498 |
| 499 } // namespace content | 499 } // namespace content |
| OLD | NEW |