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 "content/browser/speech/google_one_shot_remote_engine.h" | 5 #include "content/browser/speech/google_one_shot_remote_engine.h" |
6 | 6 |
7 #include <vector> | 7 #include <vector> |
8 | 8 |
9 #include "base/json/json_reader.h" | 9 #include "base/json/json_reader.h" |
10 #include "base/string_number_conversions.h" | 10 #include "base/string_number_conversions.h" |
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
48 SpeechRecognitionError* error) { | 48 SpeechRecognitionError* error) { |
49 if (response_body.empty()) { | 49 if (response_body.empty()) { |
50 LOG(WARNING) << "ParseServerResponse: Response was empty."; | 50 LOG(WARNING) << "ParseServerResponse: Response was empty."; |
51 return false; | 51 return false; |
52 } | 52 } |
53 DVLOG(1) << "ParseServerResponse: Parsing response " << response_body; | 53 DVLOG(1) << "ParseServerResponse: Parsing response " << response_body; |
54 | 54 |
55 // Parse the response, ignoring comments. | 55 // Parse the response, ignoring comments. |
56 std::string error_msg; | 56 std::string error_msg; |
57 scoped_ptr<Value> response_value(base::JSONReader::ReadAndReturnError( | 57 scoped_ptr<Value> response_value(base::JSONReader::ReadAndReturnError( |
58 response_body, false, NULL, &error_msg)); | 58 response_body, base::JSON_PARSE_RFC, NULL, &error_msg)); |
59 if (response_value == NULL) { | 59 if (response_value == NULL) { |
60 LOG(WARNING) << "ParseServerResponse: JSONReader failed : " << error_msg; | 60 LOG(WARNING) << "ParseServerResponse: JSONReader failed : " << error_msg; |
61 return false; | 61 return false; |
62 } | 62 } |
63 | 63 |
64 if (!response_value->IsType(Value::TYPE_DICTIONARY)) { | 64 if (!response_value->IsType(Value::TYPE_DICTIONARY)) { |
65 VLOG(1) << "ParseServerResponse: Unexpected response type " | 65 VLOG(1) << "ParseServerResponse: Unexpected response type " |
66 << response_value->GetType(); | 66 << response_value->GetType(); |
67 return false; | 67 return false; |
68 } | 68 } |
(...skipping 223 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
292 | 292 |
293 bool GoogleOneShotRemoteEngine::IsRecognitionPending() const { | 293 bool GoogleOneShotRemoteEngine::IsRecognitionPending() const { |
294 return url_fetcher_ != NULL; | 294 return url_fetcher_ != NULL; |
295 } | 295 } |
296 | 296 |
297 int GoogleOneShotRemoteEngine::GetDesiredAudioChunkDurationMs() const { | 297 int GoogleOneShotRemoteEngine::GetDesiredAudioChunkDurationMs() const { |
298 return kAudioPacketIntervalMs; | 298 return kAudioPacketIntervalMs; |
299 } | 299 } |
300 | 300 |
301 } // namespace speech | 301 } // namespace speech |
OLD | NEW |