Commit 1ff9e2f4 authored by Clark DuVall's avatar Clark DuVall Committed by Commit Bot

[Code Health] Enable gn check for //chrome/services/speech

This required moving ChunkedByteBuffer to //components/speech to be
shared between //chrome and //content.

Bug: 949535
Change-Id: I0c58762bd4c47123f9c36778c3d02b8d2da65564
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2533854Reviewed-by: default avatarScott Violet <sky@chromium.org>
Reviewed-by: default avatarEvan Liu <evliu@google.com>
Commit-Queue: Clark DuVall <cduvall@chromium.org>
Cr-Commit-Position: refs/heads/master@{#826887}
parent fe22a4ce
...@@ -77,7 +77,6 @@ no_check_targets = [ ...@@ -77,7 +77,6 @@ no_check_targets = [
"//chrome/services/cups_proxy:*", # 6 errors "//chrome/services/cups_proxy:*", # 6 errors
"//chrome/services/ipp_parser:*", # 1 error "//chrome/services/ipp_parser:*", # 1 error
"//chrome/services/removable_storage_writer:*", # 1 error "//chrome/services/removable_storage_writer:*", # 1 error
"//chrome/services/speech:*", # 5 errors
"//chrome/services/util_win:*", # 1 error "//chrome/services/util_win:*", # 1 error
"//chrome/test/chromedriver:*", # 115 errors "//chrome/test/chromedriver:*", # 115 errors
"//chrome/test/data/nacl:*", # 350 errors "//chrome/test/data/nacl:*", # 350 errors
......
...@@ -32,6 +32,8 @@ source_set("lib") { ...@@ -32,6 +32,8 @@ source_set("lib") {
"//chrome/services/speech/soda", "//chrome/services/speech/soda",
"//components/speech", "//components/speech",
"//content/public/browser:proto", "//content/public/browser:proto",
"//google_apis",
"//media/mojo/common",
"//mojo/public/cpp/bindings", "//mojo/public/cpp/bindings",
"//net", "//net",
"//services/network/public/cpp", "//services/network/public/cpp",
......
include_rules = [ include_rules = [
"+chrome/services/speech", "+chrome/services/speech",
"+components/speech", "+components/speech",
"+content/browser/speech",
"+content/public/browser", "+content/public/browser",
"+google_apis", "+google_apis",
"+media", "+media",
"+services/network", "+services/network/public",
"+services/network/test",
"+third_party/blink/public/mojom/speech", "+third_party/blink/public/mojom/speech",
] ]
...@@ -11,11 +11,11 @@ ...@@ -11,11 +11,11 @@
#include "base/strings/string_piece.h" #include "base/strings/string_piece.h"
#include "base/unguessable_token.h" #include "base/unguessable_token.h"
#include "chrome/services/speech/speech_recognition_service_impl.h" #include "chrome/services/speech/speech_recognition_service_impl.h"
#include "components/speech/chunked_byte_buffer.h"
#include "components/speech/downstream_loader.h" #include "components/speech/downstream_loader.h"
#include "components/speech/downstream_loader_client.h" #include "components/speech/downstream_loader_client.h"
#include "components/speech/upstream_loader.h" #include "components/speech/upstream_loader.h"
#include "components/speech/upstream_loader_client.h" #include "components/speech/upstream_loader_client.h"
#include "content/browser/speech/chunked_byte_buffer.h"
#include "services/network/public/mojom/url_loader_factory.mojom.h" #include "services/network/public/mojom/url_loader_factory.mojom.h"
namespace speech { namespace speech {
...@@ -108,7 +108,7 @@ class CloudSpeechRecognitionClient : public speech::UpstreamLoaderClient, ...@@ -108,7 +108,7 @@ class CloudSpeechRecognitionClient : public speech::UpstreamLoaderClient,
mojo::Remote<network::mojom::URLLoaderFactory> url_loader_factory_; mojo::Remote<network::mojom::URLLoaderFactory> url_loader_factory_;
base::WeakPtr<SpeechRecognitionServiceImpl> speech_recognition_service_impl_; base::WeakPtr<SpeechRecognitionServiceImpl> speech_recognition_service_impl_;
content::ChunkedByteBuffer chunked_byte_buffer_; ChunkedByteBuffer chunked_byte_buffer_;
}; };
} // namespace speech } // namespace speech
......
...@@ -25,6 +25,7 @@ ...@@ -25,6 +25,7 @@
#include "mojo/public/cpp/bindings/pending_remote.h" #include "mojo/public/cpp/bindings/pending_remote.h"
#include "mojo/public/cpp/bindings/receiver.h" #include "mojo/public/cpp/bindings/receiver.h"
#include "mojo/public/cpp/bindings/remote.h" #include "mojo/public/cpp/bindings/remote.h"
#include "net/http/http_util.h"
#include "services/network/public/cpp/weak_wrapper_shared_url_loader_factory.h" #include "services/network/public/cpp/weak_wrapper_shared_url_loader_factory.h"
#include "services/network/test/test_url_loader_factory.h" #include "services/network/test/test_url_loader_factory.h"
#include "testing/gtest/include/gtest/gtest.h" #include "testing/gtest/include/gtest/gtest.h"
......
...@@ -11,7 +11,7 @@ ...@@ -11,7 +11,7 @@
#include "mojo/public/cpp/bindings/pending_receiver.h" #include "mojo/public/cpp/bindings/pending_receiver.h"
#include "mojo/public/cpp/bindings/receiver.h" #include "mojo/public/cpp/bindings/receiver.h"
#include "mojo/public/cpp/bindings/receiver_set.h" #include "mojo/public/cpp/bindings/receiver_set.h"
#include "services/network/url_loader_factory.h" #include "services/network/public/mojom/url_loader_factory.mojom.h"
namespace speech { namespace speech {
......
...@@ -147,6 +147,7 @@ test("components_unittests") { ...@@ -147,6 +147,7 @@ test("components_unittests") {
"//components/signin/public/base:unit_tests", "//components/signin/public/base:unit_tests",
"//components/signin/public/identity_manager:unit_tests", "//components/signin/public/identity_manager:unit_tests",
"//components/signin/public/webdata:unit_tests", "//components/signin/public/webdata:unit_tests",
"//components/speech:unit_tests",
"//components/sqlite_proto:unit_tests", "//components/sqlite_proto:unit_tests",
"//components/ssl_errors:unit_tests", "//components/ssl_errors:unit_tests",
"//components/subresource_filter/core/browser:unit_tests", "//components/subresource_filter/core/browser:unit_tests",
......
...@@ -4,6 +4,8 @@ ...@@ -4,6 +4,8 @@
source_set("speech") { source_set("speech") {
sources = [ sources = [
"chunked_byte_buffer.cc",
"chunked_byte_buffer.h",
"downstream_loader.cc", "downstream_loader.cc",
"downstream_loader.h", "downstream_loader.h",
"downstream_loader_client.h", "downstream_loader_client.h",
...@@ -20,3 +22,12 @@ source_set("speech") { ...@@ -20,3 +22,12 @@ source_set("speech") {
"//services/network/public/mojom", "//services/network/public/mojom",
] ]
} }
source_set("unit_tests") {
testonly = true
sources = [ "chunked_byte_buffer_unittest.cc" ]
deps = [
":speech",
"//testing/gtest",
]
}
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
// Use of this source code is governed by a BSD-style license that can be // Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file. // found in the LICENSE file.
#include "content/browser/speech/chunked_byte_buffer.h" #include "components/speech/chunked_byte_buffer.h"
#include <algorithm> #include <algorithm>
#include <utility> #include <utility>
...@@ -20,12 +20,10 @@ static_assert(sizeof(size_t) >= kHeaderLength, ...@@ -20,12 +20,10 @@ static_assert(sizeof(size_t) >= kHeaderLength,
} // namespace } // namespace
namespace content { namespace speech {
ChunkedByteBuffer::ChunkedByteBuffer() ChunkedByteBuffer::ChunkedByteBuffer()
: partial_chunk_(new Chunk()), : partial_chunk_(new Chunk()), total_bytes_stored_(0) {}
total_bytes_stored_(0) {
}
ChunkedByteBuffer::~ChunkedByteBuffer() { ChunkedByteBuffer::~ChunkedByteBuffer() {
Clear(); Clear();
...@@ -62,8 +60,7 @@ void ChunkedByteBuffer::Append(const uint8_t* start, size_t length) { ...@@ -62,8 +60,7 @@ void ChunkedByteBuffer::Append(const uint8_t* start, size_t length) {
DCHECK_GT(insert_length, 0U); DCHECK_GT(insert_length, 0U);
DCHECK_LE(insert_length, remaining_bytes); DCHECK_LE(insert_length, remaining_bytes);
DCHECK_LE(next_data + insert_length, start + length); DCHECK_LE(next_data + insert_length, start + length);
insert_target->insert(insert_target->end(), insert_target->insert(insert_target->end(), next_data,
next_data,
next_data + insert_length); next_data + insert_length);
next_data += insert_length; next_data += insert_length;
remaining_bytes -= insert_length; remaining_bytes -= insert_length;
...@@ -99,7 +96,7 @@ bool ChunkedByteBuffer::HasChunks() const { ...@@ -99,7 +96,7 @@ bool ChunkedByteBuffer::HasChunks() const {
std::unique_ptr<std::vector<uint8_t>> ChunkedByteBuffer::PopChunk() { std::unique_ptr<std::vector<uint8_t>> ChunkedByteBuffer::PopChunk() {
if (chunks_.empty()) if (chunks_.empty())
return std::unique_ptr<std::vector<uint8_t>>(); return nullptr;
std::unique_ptr<Chunk> chunk = std::move(*chunks_.begin()); std::unique_ptr<Chunk> chunk = std::move(*chunks_.begin());
chunks_.erase(chunks_.begin()); chunks_.erase(chunks_.begin());
DCHECK_EQ(chunk->header.size(), kHeaderLength); DCHECK_EQ(chunk->header.size(), kHeaderLength);
...@@ -117,8 +114,7 @@ void ChunkedByteBuffer::Clear() { ...@@ -117,8 +114,7 @@ void ChunkedByteBuffer::Clear() {
ChunkedByteBuffer::Chunk::Chunk() : content(new std::vector<uint8_t>()) {} ChunkedByteBuffer::Chunk::Chunk() : content(new std::vector<uint8_t>()) {}
ChunkedByteBuffer::Chunk::~Chunk() { ChunkedByteBuffer::Chunk::~Chunk() {}
}
size_t ChunkedByteBuffer::Chunk::ExpectedContentLength() const { size_t ChunkedByteBuffer::Chunk::ExpectedContentLength() const {
DCHECK_EQ(header.size(), kHeaderLength); DCHECK_EQ(header.size(), kHeaderLength);
...@@ -128,4 +124,4 @@ size_t ChunkedByteBuffer::Chunk::ExpectedContentLength() const { ...@@ -128,4 +124,4 @@ size_t ChunkedByteBuffer::Chunk::ExpectedContentLength() const {
return static_cast<size_t>(content_length); return static_cast<size_t>(content_length);
} }
} // namespace content } // namespace speech
...@@ -2,8 +2,8 @@ ...@@ -2,8 +2,8 @@
// Use of this source code is governed by a BSD-style license that can be // Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file. // found in the LICENSE file.
#ifndef CONTENT_BROWSER_SPEECH_CHUNKED_BYTE_BUFFER_H_ #ifndef COMPONENTS_SPEECH_CHUNKED_BYTE_BUFFER_H_
#define CONTENT_BROWSER_SPEECH_CHUNKED_BYTE_BUFFER_H_ #define COMPONENTS_SPEECH_CHUNKED_BYTE_BUFFER_H_
#include <stddef.h> #include <stddef.h>
#include <stdint.h> #include <stdint.h>
...@@ -14,9 +14,8 @@ ...@@ -14,9 +14,8 @@
#include "base/macros.h" #include "base/macros.h"
#include "base/strings/string_piece.h" #include "base/strings/string_piece.h"
#include "content/common/content_export.h"
namespace content { namespace speech {
// Models a chunk-oriented byte buffer. The term chunk is herein defined as an // Models a chunk-oriented byte buffer. The term chunk is herein defined as an
// arbitrary sequence of bytes that is preceeded by N header bytes, indicating // arbitrary sequence of bytes that is preceeded by N header bytes, indicating
...@@ -28,7 +27,7 @@ namespace content { ...@@ -28,7 +27,7 @@ namespace content {
// //
// E.g. 00 00 00 04 xx xx xx xx 00 00 00 02 yy yy 00 00 00 04 zz zz zz zz // E.g. 00 00 00 04 xx xx xx xx 00 00 00 02 yy yy 00 00 00 04 zz zz zz zz
// [----- CHUNK 1 -------] [--- CHUNK 2 ---] [------ CHUNK 3 ------] // [----- CHUNK 1 -------] [--- CHUNK 2 ---] [------ CHUNK 3 ------]
class CONTENT_EXPORT ChunkedByteBuffer { class ChunkedByteBuffer {
public: public:
ChunkedByteBuffer(); ChunkedByteBuffer();
~ChunkedByteBuffer(); ~ChunkedByteBuffer();
...@@ -72,7 +71,6 @@ class CONTENT_EXPORT ChunkedByteBuffer { ...@@ -72,7 +71,6 @@ class CONTENT_EXPORT ChunkedByteBuffer {
DISALLOW_COPY_AND_ASSIGN(ChunkedByteBuffer); DISALLOW_COPY_AND_ASSIGN(ChunkedByteBuffer);
}; };
} // namespace speech
} // namespace content #endif // COMPONENTS_SPEECH_CHUNKED_BYTE_BUFFER_H_
#endif // CONTENT_BROWSER_SPEECH_CHUNKED_BYTE_BUFFER_H_
...@@ -7,10 +7,10 @@ ...@@ -7,10 +7,10 @@
#include <string> #include <string>
#include <vector> #include <vector>
#include "content/browser/speech/chunked_byte_buffer.h" #include "components/speech/chunked_byte_buffer.h"
#include "testing/gtest/include/gtest/gtest.h" #include "testing/gtest/include/gtest/gtest.h"
namespace content { namespace speech {
typedef std::vector<uint8_t> ByteVector; typedef std::vector<uint8_t> ByteVector;
...@@ -73,4 +73,4 @@ TEST(ChunkedByteBufferTest, BasicTest) { ...@@ -73,4 +73,4 @@ TEST(ChunkedByteBufferTest, BasicTest) {
EXPECT_FALSE(buffer.HasChunks()); EXPECT_FALSE(buffer.HasChunks());
} }
} // namespace content } // namespace speech
...@@ -2606,8 +2606,6 @@ source_set("browser") { ...@@ -2606,8 +2606,6 @@ source_set("browser") {
"speech/audio_buffer.h", "speech/audio_buffer.h",
"speech/audio_encoder.cc", "speech/audio_encoder.cc",
"speech/audio_encoder.h", "speech/audio_encoder.h",
"speech/chunked_byte_buffer.cc",
"speech/chunked_byte_buffer.h",
"speech/endpointer/endpointer.cc", "speech/endpointer/endpointer.cc",
"speech/endpointer/endpointer.h", "speech/endpointer/endpointer.h",
"speech/endpointer/energy_endpointer.cc", "speech/endpointer/energy_endpointer.cc",
......
...@@ -14,12 +14,12 @@ ...@@ -14,12 +14,12 @@
#include "base/memory/ref_counted.h" #include "base/memory/ref_counted.h"
#include "base/sequence_checker.h" #include "base/sequence_checker.h"
#include "base/strings/string_piece.h" #include "base/strings/string_piece.h"
#include "components/speech/chunked_byte_buffer.h"
#include "components/speech/downstream_loader.h" #include "components/speech/downstream_loader.h"
#include "components/speech/downstream_loader_client.h" #include "components/speech/downstream_loader_client.h"
#include "components/speech/upstream_loader.h" #include "components/speech/upstream_loader.h"
#include "components/speech/upstream_loader_client.h" #include "components/speech/upstream_loader_client.h"
#include "content/browser/speech/audio_encoder.h" #include "content/browser/speech/audio_encoder.h"
#include "content/browser/speech/chunked_byte_buffer.h"
#include "content/common/content_export.h" #include "content/common/content_export.h"
#include "content/public/browser/speech_recognition_session_preamble.h" #include "content/public/browser/speech_recognition_session_preamble.h"
#include "services/network/public/cpp/simple_url_loader_stream_consumer.h" #include "services/network/public/cpp/simple_url_loader_stream_consumer.h"
...@@ -218,7 +218,7 @@ class CONTENT_EXPORT SpeechRecognitionEngine ...@@ -218,7 +218,7 @@ class CONTENT_EXPORT SpeechRecognitionEngine
const std::string accept_language_; const std::string accept_language_;
std::unique_ptr<AudioEncoder> encoder_; std::unique_ptr<AudioEncoder> encoder_;
std::unique_ptr<AudioEncoder> preamble_encoder_; std::unique_ptr<AudioEncoder> preamble_encoder_;
ChunkedByteBuffer chunked_byte_buffer_; speech::ChunkedByteBuffer chunked_byte_buffer_;
bool got_last_definitive_result_; bool got_last_definitive_result_;
bool is_dispatching_event_; bool is_dispatching_event_;
bool use_framed_post_data_; bool use_framed_post_data_;
......
...@@ -2449,7 +2449,6 @@ test("content_unittests") { ...@@ -2449,7 +2449,6 @@ test("content_unittests") {
"../browser/direct_sockets/direct_sockets_unittest.cc", "../browser/direct_sockets/direct_sockets_unittest.cc",
"../browser/host_zoom_map_impl_unittest.cc", "../browser/host_zoom_map_impl_unittest.cc",
"../browser/serial/serial_unittest.cc", "../browser/serial/serial_unittest.cc",
"../browser/speech/chunked_byte_buffer_unittest.cc",
"../browser/speech/endpointer/endpointer_unittest.cc", "../browser/speech/endpointer/endpointer_unittest.cc",
"../browser/speech/speech_recognition_engine_unittest.cc", "../browser/speech/speech_recognition_engine_unittest.cc",
"../browser/speech/speech_recognizer_impl_unittest.cc", "../browser/speech/speech_recognizer_impl_unittest.cc",
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment