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