| OLD | NEW |
| 1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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/test/mock_google_streaming_server.h" | 5 #include "content/test/mock_google_streaming_server.h" |
| 6 | 6 |
| 7 #include <stddef.h> | 7 #include <stddef.h> |
| 8 #include <stdint.h> | 8 #include <stdint.h> |
| 9 | 9 |
| 10 #include "base/bind.h" | 10 #include "base/bind.h" |
| 11 #include "base/numerics/safe_conversions.h" | 11 #include "base/numerics/safe_conversions.h" |
| 12 #include "base/strings/string_split.h" | 12 #include "base/strings/string_split.h" |
| 13 #include "base/strings/string_util.h" | 13 #include "base/strings/string_util.h" |
| 14 #include "base/strings/utf_string_conversions.h" | 14 #include "base/strings/utf_string_conversions.h" |
| 15 #include "base/sys_byteorder.h" | 15 #include "base/sys_byteorder.h" |
| 16 #include "base/values.h" | 16 #include "base/values.h" |
| 17 #include "content/browser/speech/google_streaming_remote_engine.h" | |
| 18 #include "content/browser/speech/proto/google_streaming_api.pb.h" | 17 #include "content/browser/speech/proto/google_streaming_api.pb.h" |
| 18 #include "content/browser/speech/speech_recognition_engine.h" |
| 19 #include "content/browser/speech/speech_recognition_manager_impl.h" | 19 #include "content/browser/speech/speech_recognition_manager_impl.h" |
| 20 #include "net/base/escape.h" | 20 #include "net/base/escape.h" |
| 21 #include "net/base/net_errors.h" | 21 #include "net/base/net_errors.h" |
| 22 #include "net/url_request/url_fetcher_delegate.h" | 22 #include "net/url_request/url_fetcher_delegate.h" |
| 23 #include "net/url_request/url_request_status.h" | 23 #include "net/url_request/url_request_status.h" |
| 24 | 24 |
| 25 using base::HostToNet32; | 25 using base::HostToNet32; |
| 26 using base::checked_cast; | 26 using base::checked_cast; |
| 27 | 27 |
| 28 namespace content { | 28 namespace content { |
| 29 | 29 |
| 30 MockGoogleStreamingServer::MockGoogleStreamingServer(Delegate* delegate) | 30 MockGoogleStreamingServer::MockGoogleStreamingServer(Delegate* delegate) |
| 31 : delegate_(delegate), | 31 : delegate_(delegate), |
| 32 kDownstreamUrlFetcherId( | 32 kDownstreamUrlFetcherId( |
| 33 GoogleStreamingRemoteEngine::kDownstreamUrlFetcherIdForTesting), | 33 SpeechRecognitionEngine::kDownstreamUrlFetcherIdForTesting), |
| 34 kUpstreamUrlFetcherId( | 34 kUpstreamUrlFetcherId( |
| 35 GoogleStreamingRemoteEngine::kUpstreamUrlFetcherIdForTesting) { | 35 SpeechRecognitionEngine::kUpstreamUrlFetcherIdForTesting) { |
| 36 url_fetcher_factory_.SetDelegateForTests(this); | 36 url_fetcher_factory_.SetDelegateForTests(this); |
| 37 } | 37 } |
| 38 | 38 |
| 39 MockGoogleStreamingServer::~MockGoogleStreamingServer() { | 39 MockGoogleStreamingServer::~MockGoogleStreamingServer() { |
| 40 } | 40 } |
| 41 | 41 |
| 42 void MockGoogleStreamingServer::OnRequestStart(int fetcher_id) { | 42 void MockGoogleStreamingServer::OnRequestStart(int fetcher_id) { |
| 43 if (fetcher_id != kDownstreamUrlFetcherId) | 43 if (fetcher_id != kDownstreamUrlFetcherId) |
| 44 return; | 44 return; |
| 45 | 45 |
| (...skipping 95 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 141 } | 141 } |
| 142 | 142 |
| 143 // Can return NULL if the SpeechRecognizer has not requested the connection yet. | 143 // Can return NULL if the SpeechRecognizer has not requested the connection yet. |
| 144 net::TestURLFetcher* MockGoogleStreamingServer::GetURLFetcher( | 144 net::TestURLFetcher* MockGoogleStreamingServer::GetURLFetcher( |
| 145 bool downstream) const { | 145 bool downstream) const { |
| 146 return url_fetcher_factory_.GetFetcherByID( | 146 return url_fetcher_factory_.GetFetcherByID( |
| 147 downstream ? kDownstreamUrlFetcherId : kUpstreamUrlFetcherId); | 147 downstream ? kDownstreamUrlFetcherId : kUpstreamUrlFetcherId); |
| 148 } | 148 } |
| 149 | 149 |
| 150 } // namespace content | 150 } // namespace content |
| OLD | NEW |