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

Side by Side Diff: content/test/mock_google_streaming_server.cc

Issue 1164823002: Remove URLRequestStatus mutators and introduce FromError. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 6 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
OLDNEW
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 "base/bind.h" 7 #include "base/bind.h"
8 #include "base/numerics/safe_conversions.h" 8 #include "base/numerics/safe_conversions.h"
9 #include "base/strings/string_util.h" 9 #include "base/strings/string_util.h"
10 #include "base/strings/utf_string_conversions.h" 10 #include "base/strings/utf_string_conversions.h"
11 #include "base/sys_byteorder.h" 11 #include "base/sys_byteorder.h"
12 #include "base/values.h" 12 #include "base/values.h"
13 #include "content/browser/speech/google_streaming_remote_engine.h" 13 #include "content/browser/speech/google_streaming_remote_engine.h"
14 #include "content/browser/speech/proto/google_streaming_api.pb.h" 14 #include "content/browser/speech/proto/google_streaming_api.pb.h"
15 #include "content/browser/speech/speech_recognition_manager_impl.h" 15 #include "content/browser/speech/speech_recognition_manager_impl.h"
16 #include "net/base/escape.h" 16 #include "net/base/escape.h"
17 #include "net/base/net_errors.h"
17 #include "net/url_request/url_fetcher_delegate.h" 18 #include "net/url_request/url_fetcher_delegate.h"
18 #include "net/url_request/url_request_status.h" 19 #include "net/url_request/url_request_status.h"
19 20
20 using base::HostToNet32; 21 using base::HostToNet32;
21 using base::checked_cast; 22 using base::checked_cast;
22 23
23 namespace content { 24 namespace content {
24 25
25 MockGoogleStreamingServer::MockGoogleStreamingServer(Delegate* delegate) 26 MockGoogleStreamingServer::MockGoogleStreamingServer(Delegate* delegate)
26 : delegate_(delegate), 27 : delegate_(delegate),
(...skipping 95 matching lines...) Expand 10 before | Expand all | Expand 10 after
122 } 123 }
123 124
124 const std::string& MockGoogleStreamingServer::GetRequestGrammar() const { 125 const std::string& MockGoogleStreamingServer::GetRequestGrammar() const {
125 return request_grammar; 126 return request_grammar;
126 } 127 }
127 128
128 void MockGoogleStreamingServer::SimulateServerResponse( 129 void MockGoogleStreamingServer::SimulateServerResponse(
129 bool success, const std::string& http_response) { 130 bool success, const std::string& http_response) {
130 net::TestURLFetcher* fetcher = GetURLFetcher(true); 131 net::TestURLFetcher* fetcher = GetURLFetcher(true);
131 132
132 net::URLRequestStatus status; 133 fetcher->set_status(
133 status.set_status(success ? net::URLRequestStatus::SUCCESS : 134 net::URLRequestStatus::FromError(success ? net::OK : net::ERR_FAILED));
134 net::URLRequestStatus::FAILED);
135 fetcher->set_status(status);
136 fetcher->set_response_code(success ? 200 : 500); 135 fetcher->set_response_code(success ? 200 : 500);
137 fetcher->SetResponseString(http_response); 136 fetcher->SetResponseString(http_response);
138 fetcher->delegate()->OnURLFetchDownloadProgress(fetcher, 0, 0); 137 fetcher->delegate()->OnURLFetchDownloadProgress(fetcher, 0, 0);
139 } 138 }
140 139
141 // Can return NULL if the SpeechRecognizer has not requested the connection yet. 140 // Can return NULL if the SpeechRecognizer has not requested the connection yet.
142 net::TestURLFetcher* MockGoogleStreamingServer::GetURLFetcher( 141 net::TestURLFetcher* MockGoogleStreamingServer::GetURLFetcher(
143 bool downstream) const { 142 bool downstream) const {
144 return url_fetcher_factory_.GetFetcherByID( 143 return url_fetcher_factory_.GetFetcherByID(
145 downstream ? kDownstreamUrlFetcherId : kUpstreamUrlFetcherId); 144 downstream ? kDownstreamUrlFetcherId : kUpstreamUrlFetcherId);
146 } 145 }
147 146
148 } // namespace content 147 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698