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

Side by Side Diff: content/child/blob_storage/blob_transport_controller_unittest.cc

Issue 2086033002: [BlobAsync] Fixed shared memory mapping (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: comments 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
« no previous file with comments | « content/child/blob_storage/blob_transport_controller.cc ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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/blob_storage/blob_transport_controller.h" 5 #include "content/child/blob_storage/blob_transport_controller.h"
6 6
7 #include <stddef.h> 7 #include <stddef.h>
8 #include <stdint.h> 8 #include <stdint.h>
9 #include <tuple> 9 #include <tuple>
10 10
(...skipping 284 matching lines...) Expand 10 before | Expand all | Expand 10 after
295 std::vector<BlobItemBytesRequest> requests; 295 std::vector<BlobItemBytesRequest> requests;
296 std::vector<base::SharedMemoryHandle> memory_handles; 296 std::vector<base::SharedMemoryHandle> memory_handles;
297 std::vector<IPC::PlatformFileForTransit> file_handles; 297 std::vector<IPC::PlatformFileForTransit> file_handles;
298 298
299 // Request for all data in shared memory 299 // Request for all data in shared memory
300 requests.push_back( 300 requests.push_back(
301 BlobItemBytesRequest::CreateSharedMemoryRequest(0, 1, 0, 11, 0, 0)); 301 BlobItemBytesRequest::CreateSharedMemoryRequest(0, 1, 0, 11, 0, 0));
302 requests.push_back( 302 requests.push_back(
303 BlobItemBytesRequest::CreateSharedMemoryRequest(1, 3, 0, 6, 0, 11)); 303 BlobItemBytesRequest::CreateSharedMemoryRequest(1, 3, 0, 6, 0, 11));
304 base::SharedMemory memory; 304 base::SharedMemory memory;
305 memory.CreateAndMapAnonymous(11 + 6); 305 memory.CreateAnonymous(11 + 6);
306 base::SharedMemoryHandle handle = 306 base::SharedMemoryHandle handle =
307 base::SharedMemory::DuplicateHandle(memory.handle()); 307 base::SharedMemory::DuplicateHandle(memory.handle());
308 CHECK(base::SharedMemory::NULLHandle() != handle); 308 CHECK(base::SharedMemory::NULLHandle() != handle);
309 memory_handles.push_back(handle); 309 memory_handles.push_back(handle);
310 310
311 OnMemoryRequest(holder, kBlobUUID, requests, &memory_handles, file_handles); 311 OnMemoryRequest(holder, kBlobUUID, requests, &memory_handles, file_handles);
312 std::vector<storage::BlobItemBytesResponse> expected; 312 std::vector<storage::BlobItemBytesResponse> expected;
313 expected.push_back(BlobItemBytesResponse(0)); 313 expected.push_back(BlobItemBytesResponse(0));
314 expected.push_back(BlobItemBytesResponse(1)); 314 expected.push_back(BlobItemBytesResponse(1));
315 ExpectMemoryResponses(kBlobUUID, expected); 315 ExpectMemoryResponses(kBlobUUID, expected);
316 std::string expected_memory = "HelloHello2Hello3"; 316 std::string expected_memory = "HelloHello2Hello3";
317 memory.Map(11 + 6);
317 const char* mem_location = static_cast<const char*>(memory.memory()); 318 const char* mem_location = static_cast<const char*>(memory.memory());
318 std::vector<char> value(mem_location, mem_location + memory.requested_size()); 319 std::vector<char> value(mem_location, mem_location + memory.requested_size());
319 EXPECT_THAT(value, testing::ElementsAreArray(expected_memory.c_str(), 320 EXPECT_THAT(value, testing::ElementsAreArray(expected_memory.c_str(),
320 expected_memory.size())); 321 expected_memory.size()));
321 } 322 }
322 323
323 TEST_F(BlobTransportControllerTest, Disk) { 324 TEST_F(BlobTransportControllerTest, Disk) {
324 const std::string kBlobUUID = "uuid"; 325 const std::string kBlobUUID = "uuid";
325 const std::string kRefBlobUUID = "refuuid"; 326 const std::string kRefBlobUUID = "refuuid";
326 const std::string kBadBlobUUID = "uuuidBad"; 327 const std::string kBadBlobUUID = "uuuidBad";
(...skipping 147 matching lines...) Expand 10 before | Expand all | Expand 10 after
474 EXPECT_FALSE(main_thread_runner_->HasPendingTask()); 475 EXPECT_FALSE(main_thread_runner_->HasPendingTask());
475 476
476 // Finish the second one. 477 // Finish the second one.
477 holder->OnDone(kBlob2UUID); 478 holder->OnDone(kBlob2UUID);
478 EXPECT_FALSE(holder->IsTransporting(kBlob2UUID)); 479 EXPECT_FALSE(holder->IsTransporting(kBlob2UUID));
479 EXPECT_TRUE(main_thread_runner_->HasPendingTask()); 480 EXPECT_TRUE(main_thread_runner_->HasPendingTask());
480 main_thread_runner_->ClearPendingTasks(); 481 main_thread_runner_->ClearPendingTasks();
481 } 482 }
482 483
483 } // namespace content 484 } // namespace content
OLDNEW
« no previous file with comments | « content/child/blob_storage/blob_transport_controller.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698