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

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

Issue 2082343002: Remove calls to deprecated MessageLoop methods in content. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: CR Created 4 years, 5 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
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>
11 #include <utility> 11 #include <utility>
12 #include <vector> 12 #include <vector>
13 13
14 #include "base/bind.h" 14 #include "base/bind.h"
15 #include "base/callback.h" 15 #include "base/callback.h"
16 #include "base/location.h" 16 #include "base/location.h"
17 #include "base/macros.h" 17 #include "base/macros.h"
18 #include "base/memory/ptr_util.h" 18 #include "base/memory/ptr_util.h"
19 #include "base/message_loop/message_loop.h" 19 #include "base/message_loop/message_loop.h"
20 #include "base/run_loop.h" 20 #include "base/run_loop.h"
21 #include "base/single_thread_task_runner.h"
21 #include "base/task_runner.h" 22 #include "base/task_runner.h"
22 #include "base/threading/thread.h" 23 #include "base/threading/thread.h"
23 #include "base/threading/thread_task_runner_handle.h" 24 #include "base/threading/thread_task_runner_handle.h"
24 #include "content/public/child/fixed_received_data.h" 25 #include "content/public/child/fixed_received_data.h"
25 #include "testing/gmock/include/gmock/gmock.h" 26 #include "testing/gmock/include/gmock/gmock.h"
26 #include "testing/gtest/include/gtest/gtest.h" 27 #include "testing/gtest/include/gtest/gtest.h"
27 28
28 namespace content { 29 namespace content {
29 30
30 namespace { 31 namespace {
(...skipping 128 matching lines...) Expand 10 before | Expand all | Expand 10 after
159 return; 160 return;
160 } 161 }
161 162
162 if (rv != kDone) { 163 if (rv != kDone) {
163 // Something is wrong. 164 // Something is wrong.
164 result_ = "error"; 165 result_ = "error";
165 } 166 }
166 167
167 // The operation is done. 168 // The operation is done.
168 reader_.reset(); 169 reader_.reset();
169 main_message_loop_->PostTask(FROM_HERE, on_done_); 170 main_message_loop_->task_runner()->PostTask(FROM_HERE, on_done_);
170 } 171 }
171 172
172 private: 173 private:
173 std::unique_ptr<SharedMemoryDataConsumerHandle> handle_; 174 std::unique_ptr<SharedMemoryDataConsumerHandle> handle_;
174 std::unique_ptr<WebDataConsumerHandle::Reader> reader_; 175 std::unique_ptr<WebDataConsumerHandle::Reader> reader_;
175 std::unique_ptr<WebDataConsumerHandle::Client> client_; 176 std::unique_ptr<WebDataConsumerHandle::Client> client_;
176 base::MessageLoop* main_message_loop_; 177 base::MessageLoop* main_message_loop_;
177 base::Closure on_done_; 178 base::Closure on_done_;
178 std::string result_; 179 std::string result_;
179 }; 180 };
(...skipping 824 matching lines...) Expand 10 before | Expand all | Expand 10 after
1004 1005
1005 TEST_F(ThreadedSharedMemoryDataConsumerHandleTest, Read) { 1006 TEST_F(ThreadedSharedMemoryDataConsumerHandleTest, Read) {
1006 base::RunLoop run_loop; 1007 base::RunLoop run_loop;
1007 auto operation = base::WrapUnique(new ReadDataOperation( 1008 auto operation = base::WrapUnique(new ReadDataOperation(
1008 std::move(handle_), &loop_, run_loop.QuitClosure())); 1009 std::move(handle_), &loop_, run_loop.QuitClosure()));
1009 scoped_refptr<Logger> logger(new Logger); 1010 scoped_refptr<Logger> logger(new Logger);
1010 1011
1011 base::Thread t("DataConsumerHandle test thread"); 1012 base::Thread t("DataConsumerHandle test thread");
1012 ASSERT_TRUE(t.Start()); 1013 ASSERT_TRUE(t.Start());
1013 1014
1014 t.message_loop()->PostTask(FROM_HERE, 1015 t.task_runner()->PostTask(FROM_HERE,
1015 base::Bind(&ReadDataOperation::ReadData, 1016 base::Bind(&ReadDataOperation::ReadData,
1016 base::Unretained(operation.get()))); 1017 base::Unretained(operation.get())));
1017 1018
1018 logger->Add("1"); 1019 logger->Add("1");
1019 writer_->AddData( 1020 writer_->AddData(
1020 base::WrapUnique(new LoggingFixedReceivedData("data1", "Once ", logger))); 1021 base::WrapUnique(new LoggingFixedReceivedData("data1", "Once ", logger)));
1021 writer_->AddData( 1022 writer_->AddData(
1022 base::WrapUnique(new LoggingFixedReceivedData("data2", "upon ", logger))); 1023 base::WrapUnique(new LoggingFixedReceivedData("data2", "upon ", logger)));
1023 writer_->AddData(base::WrapUnique( 1024 writer_->AddData(base::WrapUnique(
1024 new LoggingFixedReceivedData("data3", "a time ", logger))); 1025 new LoggingFixedReceivedData("data3", "a time ", logger)));
1025 writer_->AddData(base::WrapUnique( 1026 writer_->AddData(base::WrapUnique(
1026 new LoggingFixedReceivedData("data4", "there ", logger))); 1027 new LoggingFixedReceivedData("data4", "there ", logger)));
(...skipping 17 matching lines...) Expand all
1044 logger->log()); 1045 logger->log());
1045 } 1046 }
1046 1047
1047 INSTANTIATE_TEST_CASE_P(SharedMemoryDataConsumerHandleTest, 1048 INSTANTIATE_TEST_CASE_P(SharedMemoryDataConsumerHandleTest,
1048 SharedMemoryDataConsumerHandleTest, 1049 SharedMemoryDataConsumerHandleTest,
1049 ::testing::Values(kApplyBackpressure, 1050 ::testing::Values(kApplyBackpressure,
1050 kDoNotApplyBackpressure)); 1051 kDoNotApplyBackpressure));
1051 } // namespace 1052 } // namespace
1052 1053
1053 } // namespace content 1054 } // namespace content
OLDNEW
« no previous file with comments | « content/child/power_monitor_broadcast_source_unittest.cc ('k') | content/child/web_url_loader_impl_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698