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

Side by Side Diff: content/browser/speech/google_streaming_remote_engine_unittest.cc

Issue 141113003: Refactor base/safe_numerics.h (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: Created 6 years, 11 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 | Annotate | Revision Log
OLDNEW
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/safe_numerics.h" 9 #include "base/numerics/safe_conversions.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 "content/browser/speech/audio_buffer.h" 12 #include "content/browser/speech/audio_buffer.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/public/common/speech_recognition_error.h" 15 #include "content/public/common/speech_recognition_error.h"
16 #include "content/public/common/speech_recognition_result.h" 16 #include "content/public/common/speech_recognition_result.h"
17 #include "net/url_request/test_url_fetcher_factory.h" 17 #include "net/url_request/test_url_fetcher_factory.h"
18 #include "net/url_request/url_request_context_getter.h" 18 #include "net/url_request/url_request_context_getter.h"
19 #include "net/url_request/url_request_status.h" 19 #include "net/url_request/url_request_status.h"
20 #include "testing/gtest/include/gtest/gtest.h" 20 #include "testing/gtest/include/gtest/gtest.h"
21 21
22 using base::HostToNet32; 22 using base::HostToNet32;
23 using base::checked_numeric_cast; 23 using base::checked_cast;
24 using net::URLRequestStatus; 24 using net::URLRequestStatus;
25 using net::TestURLFetcher; 25 using net::TestURLFetcher;
26 using net::TestURLFetcherFactory; 26 using net::TestURLFetcherFactory;
27 27
28 namespace content { 28 namespace content {
29 29
30 // Note: the terms upstream and downstream are from the point-of-view of the 30 // Note: the terms upstream and downstream are from the point-of-view of the
31 // client (engine_under_test_). 31 // client (engine_under_test_).
32 32
33 class GoogleStreamingRemoteEngineTest : public SpeechRecognitionEngineDelegate, 33 class GoogleStreamingRemoteEngineTest : public SpeechRecognitionEngineDelegate,
(...skipping 449 matching lines...) Expand 10 before | Expand all | Expand 10 after
483 return true; 483 return true;
484 } 484 }
485 485
486 std::string GoogleStreamingRemoteEngineTest::SerializeProtobufResponse( 486 std::string GoogleStreamingRemoteEngineTest::SerializeProtobufResponse(
487 const proto::SpeechRecognitionEvent& msg) { 487 const proto::SpeechRecognitionEvent& msg) {
488 std::string msg_string; 488 std::string msg_string;
489 msg.SerializeToString(&msg_string); 489 msg.SerializeToString(&msg_string);
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_numeric_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
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698