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

Side by Side Diff: content/child/shared_memory_data_consumer_handle_unittest.cc

Issue 2540023003: Dispatch encoded_data_length separately in content/child (Closed)
Patch Set: fix Created 4 years 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 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 65 matching lines...) Expand 10 before | Expand all | Expand 10 after
76 scoped_refptr<Logger> logger) 76 scoped_refptr<Logger> logger)
77 : name_(name), data_(s, s + strlen(s)), logger_(logger) {} 77 : name_(name), data_(s, s + strlen(s)), logger_(logger) {}
78 ~LoggingFixedReceivedData() override { 78 ~LoggingFixedReceivedData() override {
79 logger_->Add(name_ + " is destructed."); 79 logger_->Add(name_ + " is destructed.");
80 } 80 }
81 81
82 const char* payload() const override { 82 const char* payload() const override {
83 return data_.empty() ? nullptr : &data_[0]; 83 return data_.empty() ? nullptr : &data_[0];
84 } 84 }
85 int length() const override { return static_cast<int>(data_.size()); } 85 int length() const override { return static_cast<int>(data_.size()); }
86 int encoded_data_length() const override {
87 return static_cast<int>(data_.size());
88 }
89 86
90 private: 87 private:
91 const std::string name_; 88 const std::string name_;
92 const std::vector<char> data_; 89 const std::vector<char> data_;
93 scoped_refptr<Logger> logger_; 90 scoped_refptr<Logger> logger_;
94 91
95 DISALLOW_COPY_AND_ASSIGN(LoggingFixedReceivedData); 92 DISALLOW_COPY_AND_ASSIGN(LoggingFixedReceivedData);
96 }; 93 };
97 94
98 class DestructionTrackingFunction 95 class DestructionTrackingFunction
(...skipping 94 matching lines...) Expand 10 before | Expand all | Expand 10 after
193 base::MessageLoop loop_; 190 base::MessageLoop loop_;
194 }; 191 };
195 192
196 class SharedMemoryDataConsumerHandleTest 193 class SharedMemoryDataConsumerHandleTest
197 : public ::testing::TestWithParam<BackpressureMode> { 194 : public ::testing::TestWithParam<BackpressureMode> {
198 protected: 195 protected:
199 void SetUp() override { 196 void SetUp() override {
200 handle_.reset(new SharedMemoryDataConsumerHandle(GetParam(), &writer_)); 197 handle_.reset(new SharedMemoryDataConsumerHandle(GetParam(), &writer_));
201 } 198 }
202 std::unique_ptr<FixedReceivedData> NewFixedData(const char* s) { 199 std::unique_ptr<FixedReceivedData> NewFixedData(const char* s) {
203 auto size = strlen(s); 200 return base::MakeUnique<FixedReceivedData>(s, strlen(s));
204 return base::MakeUnique<FixedReceivedData>(s, size, size);
205 } 201 }
206 202
207 StrictMock<MockClient> client_; 203 StrictMock<MockClient> client_;
208 std::unique_ptr<SharedMemoryDataConsumerHandle> handle_; 204 std::unique_ptr<SharedMemoryDataConsumerHandle> handle_;
209 std::unique_ptr<Writer> writer_; 205 std::unique_ptr<Writer> writer_;
210 base::MessageLoop loop_; 206 base::MessageLoop loop_;
211 }; 207 };
212 208
213 void RunPostedTasks() { 209 void RunPostedTasks() {
214 base::RunLoop run_loop; 210 base::RunLoop run_loop;
(...skipping 841 matching lines...) Expand 10 before | Expand all | Expand 10 after
1056 logger->log()); 1052 logger->log());
1057 } 1053 }
1058 1054
1059 INSTANTIATE_TEST_CASE_P(SharedMemoryDataConsumerHandleTest, 1055 INSTANTIATE_TEST_CASE_P(SharedMemoryDataConsumerHandleTest,
1060 SharedMemoryDataConsumerHandleTest, 1056 SharedMemoryDataConsumerHandleTest,
1061 ::testing::Values(kApplyBackpressure, 1057 ::testing::Values(kApplyBackpressure,
1062 kDoNotApplyBackpressure)); 1058 kDoNotApplyBackpressure));
1063 } // namespace 1059 } // namespace
1064 1060
1065 } // namespace content 1061 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698