OLD | NEW |
1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 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/child/shared_memory_data_consumer_handle.h" | 5 #include "content/child/shared_memory_data_consumer_handle.h" |
6 | 6 |
7 #include <stddef.h> | 7 #include <stddef.h> |
8 #include <string.h> | 8 #include <string.h> |
9 | 9 |
10 #include <string> | 10 #include <string> |
(...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
74 scoped_refptr<Logger> logger) | 74 scoped_refptr<Logger> logger) |
75 : name_(name), data_(s, s + strlen(s)), logger_(logger) {} | 75 : name_(name), data_(s, s + strlen(s)), logger_(logger) {} |
76 ~LoggingFixedReceivedData() override { | 76 ~LoggingFixedReceivedData() override { |
77 logger_->Add(name_ + " is destructed."); | 77 logger_->Add(name_ + " is destructed."); |
78 } | 78 } |
79 | 79 |
80 const char* payload() const override { | 80 const char* payload() const override { |
81 return data_.empty() ? nullptr : &data_[0]; | 81 return data_.empty() ? nullptr : &data_[0]; |
82 } | 82 } |
83 int length() const override { return static_cast<int>(data_.size()); } | 83 int length() const override { return static_cast<int>(data_.size()); } |
84 int encoded_length() const override { return static_cast<int>(data_.size()); } | 84 int encoded_data_length() const override { |
| 85 return static_cast<int>(data_.size()); |
| 86 } |
| 87 int encoded_body_length() const override { |
| 88 return static_cast<int>(data_.size()); |
| 89 } |
85 | 90 |
86 private: | 91 private: |
87 const std::string name_; | 92 const std::string name_; |
88 const std::vector<char> data_; | 93 const std::vector<char> data_; |
89 scoped_refptr<Logger> logger_; | 94 scoped_refptr<Logger> logger_; |
90 | 95 |
91 DISALLOW_COPY_AND_ASSIGN(LoggingFixedReceivedData); | 96 DISALLOW_COPY_AND_ASSIGN(LoggingFixedReceivedData); |
92 }; | 97 }; |
93 | 98 |
94 class DestructionTrackingFunction | 99 class DestructionTrackingFunction |
(...skipping 94 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
189 base::MessageLoop loop_; | 194 base::MessageLoop loop_; |
190 }; | 195 }; |
191 | 196 |
192 class SharedMemoryDataConsumerHandleTest | 197 class SharedMemoryDataConsumerHandleTest |
193 : public ::testing::TestWithParam<BackpressureMode> { | 198 : public ::testing::TestWithParam<BackpressureMode> { |
194 protected: | 199 protected: |
195 void SetUp() override { | 200 void SetUp() override { |
196 handle_.reset(new SharedMemoryDataConsumerHandle(GetParam(), &writer_)); | 201 handle_.reset(new SharedMemoryDataConsumerHandle(GetParam(), &writer_)); |
197 } | 202 } |
198 std::unique_ptr<FixedReceivedData> NewFixedData(const char* s) { | 203 std::unique_ptr<FixedReceivedData> NewFixedData(const char* s) { |
199 return base::WrapUnique(new FixedReceivedData(s, strlen(s), strlen(s))); | 204 auto size = strlen(s); |
| 205 return base::WrapUnique(new FixedReceivedData(s, size, size, size)); |
200 } | 206 } |
201 | 207 |
202 StrictMock<MockClient> client_; | 208 StrictMock<MockClient> client_; |
203 std::unique_ptr<SharedMemoryDataConsumerHandle> handle_; | 209 std::unique_ptr<SharedMemoryDataConsumerHandle> handle_; |
204 std::unique_ptr<Writer> writer_; | 210 std::unique_ptr<Writer> writer_; |
205 base::MessageLoop loop_; | 211 base::MessageLoop loop_; |
206 }; | 212 }; |
207 | 213 |
208 void RunPostedTasks() { | 214 void RunPostedTasks() { |
209 base::RunLoop run_loop; | 215 base::RunLoop run_loop; |
(...skipping 834 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1044 logger->log()); | 1050 logger->log()); |
1045 } | 1051 } |
1046 | 1052 |
1047 INSTANTIATE_TEST_CASE_P(SharedMemoryDataConsumerHandleTest, | 1053 INSTANTIATE_TEST_CASE_P(SharedMemoryDataConsumerHandleTest, |
1048 SharedMemoryDataConsumerHandleTest, | 1054 SharedMemoryDataConsumerHandleTest, |
1049 ::testing::Values(kApplyBackpressure, | 1055 ::testing::Values(kApplyBackpressure, |
1050 kDoNotApplyBackpressure)); | 1056 kDoNotApplyBackpressure)); |
1051 } // namespace | 1057 } // namespace |
1052 | 1058 |
1053 } // namespace content | 1059 } // namespace content |
OLD | NEW |