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

Side by Side Diff: content/browser/blob_storage/blob_dispatcher_host_unittest.cc

Issue 2023243002: Remove base::Tuple (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: lint fix Created 4 years, 6 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 2016 The Chromium Authors. All rights reserved. 1 // Copyright 2016 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/browser/blob_storage/blob_dispatcher_host.h" 5 #include "content/browser/blob_storage/blob_dispatcher_host.h"
6 6
7 #include <memory> 7 #include <memory>
8 #include <tuple>
8 #include <vector> 9 #include <vector>
9 10
10 #include "base/command_line.h" 11 #include "base/command_line.h"
11 #include "base/memory/shared_memory.h" 12 #include "base/memory/shared_memory.h"
12 #include "base/run_loop.h" 13 #include "base/run_loop.h"
13 #include "base/tuple.h"
14 #include "content/browser/blob_storage/chrome_blob_storage_context.h" 14 #include "content/browser/blob_storage/chrome_blob_storage_context.h"
15 #include "content/common/fileapi/webblob_messages.h" 15 #include "content/common/fileapi/webblob_messages.h"
16 #include "content/public/common/content_switches.h" 16 #include "content/public/common/content_switches.h"
17 #include "content/public/test/test_browser_context.h" 17 #include "content/public/test/test_browser_context.h"
18 #include "content/public/test/test_browser_thread_bundle.h" 18 #include "content/public/test/test_browser_thread_bundle.h"
19 #include "ipc/ipc_sender.h" 19 #include "ipc/ipc_sender.h"
20 #include "ipc/ipc_test_sink.h" 20 #include "ipc/ipc_test_sink.h"
21 #include "ipc/message_filter.h" 21 #include "ipc/message_filter.h"
22 #include "storage/browser/blob/blob_data_builder.h" 22 #include "storage/browser/blob/blob_data_builder.h"
23 #include "storage/browser/blob/blob_data_handle.h" 23 #include "storage/browser/blob/blob_data_handle.h"
(...skipping 154 matching lines...) Expand 10 before | Expand all | Expand 10 after
178 void ExpectRequest( 178 void ExpectRequest(
179 const std::string& expected_uuid, 179 const std::string& expected_uuid,
180 const std::vector<BlobItemBytesRequest>& expected_requests) { 180 const std::vector<BlobItemBytesRequest>& expected_requests) {
181 EXPECT_FALSE( 181 EXPECT_FALSE(
182 sink_.GetFirstMessageMatching(BlobStorageMsg_DoneBuildingBlob::ID)); 182 sink_.GetFirstMessageMatching(BlobStorageMsg_DoneBuildingBlob::ID));
183 EXPECT_FALSE( 183 EXPECT_FALSE(
184 sink_.GetFirstMessageMatching(BlobStorageMsg_CancelBuildingBlob::ID)); 184 sink_.GetFirstMessageMatching(BlobStorageMsg_CancelBuildingBlob::ID));
185 const IPC::Message* message = 185 const IPC::Message* message =
186 sink_.GetUniqueMessageMatching(BlobStorageMsg_RequestMemoryItem::ID); 186 sink_.GetUniqueMessageMatching(BlobStorageMsg_RequestMemoryItem::ID);
187 ASSERT_TRUE(message); 187 ASSERT_TRUE(message);
188 base::Tuple<std::string, std::vector<storage::BlobItemBytesRequest>, 188 std::tuple<std::string, std::vector<storage::BlobItemBytesRequest>,
189 std::vector<base::SharedMemoryHandle>, 189 std::vector<base::SharedMemoryHandle>,
190 std::vector<IPC::PlatformFileForTransit>> 190 std::vector<IPC::PlatformFileForTransit>>
191 args; 191 args;
192 BlobStorageMsg_RequestMemoryItem::Read(message, &args); 192 BlobStorageMsg_RequestMemoryItem::Read(message, &args);
193 EXPECT_EQ(expected_uuid, base::get<0>(args)); 193 EXPECT_EQ(expected_uuid, std::get<0>(args));
194 std::vector<BlobItemBytesRequest> requests = base::get<1>(args); 194 std::vector<BlobItemBytesRequest> requests = std::get<1>(args);
195 ASSERT_EQ(requests.size(), expected_requests.size()); 195 ASSERT_EQ(requests.size(), expected_requests.size());
196 for (size_t i = 0; i < expected_requests.size(); ++i) { 196 for (size_t i = 0; i < expected_requests.size(); ++i) {
197 EXPECT_EQ(expected_requests[i], requests[i]); 197 EXPECT_EQ(expected_requests[i], requests[i]);
198 } 198 }
199 } 199 }
200 200
201 void ExpectRequestWithSharedMemoryHandles( 201 void ExpectRequestWithSharedMemoryHandles(
202 const std::string& expected_uuid, 202 const std::string& expected_uuid,
203 const std::vector<BlobItemBytesRequest>& expected_requests, 203 const std::vector<BlobItemBytesRequest>& expected_requests,
204 std::vector<base::SharedMemoryHandle>* shared_memory_handles) { 204 std::vector<base::SharedMemoryHandle>* shared_memory_handles) {
205 EXPECT_FALSE( 205 EXPECT_FALSE(
206 sink_.GetFirstMessageMatching(BlobStorageMsg_DoneBuildingBlob::ID)); 206 sink_.GetFirstMessageMatching(BlobStorageMsg_DoneBuildingBlob::ID));
207 EXPECT_FALSE( 207 EXPECT_FALSE(
208 sink_.GetFirstMessageMatching(BlobStorageMsg_CancelBuildingBlob::ID)); 208 sink_.GetFirstMessageMatching(BlobStorageMsg_CancelBuildingBlob::ID));
209 const IPC::Message* message = 209 const IPC::Message* message =
210 sink_.GetUniqueMessageMatching(BlobStorageMsg_RequestMemoryItem::ID); 210 sink_.GetUniqueMessageMatching(BlobStorageMsg_RequestMemoryItem::ID);
211 ASSERT_TRUE(message); 211 ASSERT_TRUE(message);
212 base::Tuple<std::string, std::vector<storage::BlobItemBytesRequest>, 212 std::tuple<std::string, std::vector<storage::BlobItemBytesRequest>,
213 std::vector<base::SharedMemoryHandle>, 213 std::vector<base::SharedMemoryHandle>,
214 std::vector<IPC::PlatformFileForTransit>> 214 std::vector<IPC::PlatformFileForTransit>>
215 args; 215 args;
216 BlobStorageMsg_RequestMemoryItem::Read(message, &args); 216 BlobStorageMsg_RequestMemoryItem::Read(message, &args);
217 EXPECT_EQ(expected_uuid, base::get<0>(args)); 217 EXPECT_EQ(expected_uuid, std::get<0>(args));
218 std::vector<BlobItemBytesRequest> requests = base::get<1>(args); 218 std::vector<BlobItemBytesRequest> requests = std::get<1>(args);
219 ASSERT_EQ(requests.size(), expected_requests.size()); 219 ASSERT_EQ(requests.size(), expected_requests.size());
220 for (size_t i = 0; i < expected_requests.size(); ++i) { 220 for (size_t i = 0; i < expected_requests.size(); ++i) {
221 EXPECT_EQ(expected_requests[i], requests[i]); 221 EXPECT_EQ(expected_requests[i], requests[i]);
222 } 222 }
223 *shared_memory_handles = std::move(base::get<2>(args)); 223 *shared_memory_handles = std::move(std::get<2>(args));
224 } 224 }
225 225
226 void ExpectCancel(const std::string& expected_uuid, 226 void ExpectCancel(const std::string& expected_uuid,
227 IPCBlobCreationCancelCode code) { 227 IPCBlobCreationCancelCode code) {
228 EXPECT_FALSE( 228 EXPECT_FALSE(
229 sink_.GetFirstMessageMatching(BlobStorageMsg_RequestMemoryItem::ID)); 229 sink_.GetFirstMessageMatching(BlobStorageMsg_RequestMemoryItem::ID));
230 EXPECT_FALSE( 230 EXPECT_FALSE(
231 sink_.GetFirstMessageMatching(BlobStorageMsg_DoneBuildingBlob::ID)); 231 sink_.GetFirstMessageMatching(BlobStorageMsg_DoneBuildingBlob::ID));
232 const IPC::Message* message = 232 const IPC::Message* message =
233 sink_.GetUniqueMessageMatching(BlobStorageMsg_CancelBuildingBlob::ID); 233 sink_.GetUniqueMessageMatching(BlobStorageMsg_CancelBuildingBlob::ID);
234 ASSERT_TRUE(message); 234 ASSERT_TRUE(message);
235 base::Tuple<std::string, IPCBlobCreationCancelCode> args; 235 std::tuple<std::string, IPCBlobCreationCancelCode> args;
236 BlobStorageMsg_CancelBuildingBlob::Read(message, &args); 236 BlobStorageMsg_CancelBuildingBlob::Read(message, &args);
237 EXPECT_EQ(expected_uuid, base::get<0>(args)); 237 EXPECT_EQ(expected_uuid, std::get<0>(args));
238 EXPECT_EQ(code, base::get<1>(args)); 238 EXPECT_EQ(code, std::get<1>(args));
239 } 239 }
240 240
241 void ExpectDone(const std::string& expected_uuid) { 241 void ExpectDone(const std::string& expected_uuid) {
242 EXPECT_FALSE( 242 EXPECT_FALSE(
243 sink_.GetFirstMessageMatching(BlobStorageMsg_RequestMemoryItem::ID)); 243 sink_.GetFirstMessageMatching(BlobStorageMsg_RequestMemoryItem::ID));
244 EXPECT_FALSE( 244 EXPECT_FALSE(
245 sink_.GetFirstMessageMatching(BlobStorageMsg_CancelBuildingBlob::ID)); 245 sink_.GetFirstMessageMatching(BlobStorageMsg_CancelBuildingBlob::ID));
246 const IPC::Message* message = 246 const IPC::Message* message =
247 sink_.GetUniqueMessageMatching(BlobStorageMsg_DoneBuildingBlob::ID); 247 sink_.GetUniqueMessageMatching(BlobStorageMsg_DoneBuildingBlob::ID);
248 base::Tuple<std::string> args; 248 std::tuple<std::string> args;
249 BlobStorageMsg_DoneBuildingBlob::Read(message, &args); 249 BlobStorageMsg_DoneBuildingBlob::Read(message, &args);
250 EXPECT_EQ(expected_uuid, base::get<0>(args)); 250 EXPECT_EQ(expected_uuid, std::get<0>(args));
251 } 251 }
252 252
253 bool IsBeingBuiltInHost(const std::string& uuid) { 253 bool IsBeingBuiltInHost(const std::string& uuid) {
254 return host_->async_builder_.IsBeingBuilt(uuid); 254 return host_->async_builder_.IsBeingBuilt(uuid);
255 } 255 }
256 256
257 IPC::TestSink sink_; 257 IPC::TestSink sink_;
258 TestBrowserThreadBundle browser_thread_bundle_; 258 TestBrowserThreadBundle browser_thread_bundle_;
259 TestBrowserContext browser_context_; 259 TestBrowserContext browser_context_;
260 ChromeBlobStorageContext* chrome_blob_storage_context_; 260 ChromeBlobStorageContext* chrome_blob_storage_context_;
(...skipping 931 matching lines...) Expand 10 before | Expand all | Expand 10 after
1192 EXPECT_EQ(IPCBlobCreationCancelCode::SOURCE_DIED_IN_TRANSIT, 1192 EXPECT_EQ(IPCBlobCreationCancelCode::SOURCE_DIED_IN_TRANSIT,
1193 same_host_error_code); 1193 same_host_error_code);
1194 EXPECT_FALSE(other_host_built); 1194 EXPECT_FALSE(other_host_built);
1195 EXPECT_EQ(IPCBlobCreationCancelCode::SOURCE_DIED_IN_TRANSIT, 1195 EXPECT_EQ(IPCBlobCreationCancelCode::SOURCE_DIED_IN_TRANSIT,
1196 other_host_error_code); 1196 other_host_error_code);
1197 1197
1198 sink_.ClearMessages(); 1198 sink_.ClearMessages();
1199 } 1199 }
1200 1200
1201 } // namespace content 1201 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698