| 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/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 | 9 |
| 10 #include "base/memory/ptr_util.h" | 10 #include "base/memory/ptr_util.h" |
| (...skipping 262 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 273 BlobTransportController* holder = BlobTransportController::GetInstance(); | 273 BlobTransportController* holder = BlobTransportController::GetInstance(); |
| 274 | 274 |
| 275 BlobConsolidation* consolidation = new BlobConsolidation(); | 275 BlobConsolidation* consolidation = new BlobConsolidation(); |
| 276 consolidation->AddBlobItem(KRefBlobUUID, 10, 10); | 276 consolidation->AddBlobItem(KRefBlobUUID, 10, 10); |
| 277 BlobTransportController::InitiateBlobTransfer( | 277 BlobTransportController::InitiateBlobTransfer( |
| 278 kBlobUUID, kBlobContentType, base::WrapUnique(consolidation), sender_, | 278 kBlobUUID, kBlobContentType, base::WrapUnique(consolidation), sender_, |
| 279 io_thread_runner_.get(), main_thread_runner_); | 279 io_thread_runner_.get(), main_thread_runner_); |
| 280 // Check that we have the 'increase ref' pending task. | 280 // Check that we have the 'increase ref' pending task. |
| 281 EXPECT_TRUE(main_thread_runner_->HasPendingTask()); | 281 EXPECT_TRUE(main_thread_runner_->HasPendingTask()); |
| 282 // Check that we have the 'store' pending task. | 282 // Check that we have the 'store' pending task. |
| 283 EXPECT_FALSE(holder->IsTransporting(kBlobUUID)); | |
| 284 EXPECT_TRUE(io_thread_runner_->HasPendingTask()); | 283 EXPECT_TRUE(io_thread_runner_->HasPendingTask()); |
| 285 io_thread_runner_->RunPendingTasks(); | |
| 286 EXPECT_TRUE(holder->IsTransporting(kBlobUUID)); | |
| 287 // Check that we've sent the data. | 284 // Check that we've sent the data. |
| 288 ExpectRegisterAndStartMessage(kBlobUUID, kBlobContentType, | 285 ExpectRegisterAndStartMessage(kBlobUUID, kBlobContentType, |
| 289 &message_descriptions); | 286 &message_descriptions); |
| 290 main_thread_runner_->ClearPendingTasks(); | 287 main_thread_runner_->ClearPendingTasks(); |
| 291 | 288 |
| 292 // Check that we got the correct start message. | 289 // Check that we got the correct start message. |
| 290 EXPECT_FALSE(holder->IsTransporting(kBlobUUID)); |
| 291 io_thread_runner_->RunPendingTasks(); |
| 292 EXPECT_TRUE(holder->IsTransporting(kBlobUUID)); |
| 293 base::Tuple<std::string, std::vector<DataElement>> message_contents; | 293 base::Tuple<std::string, std::vector<DataElement>> message_contents; |
| 294 EXPECT_EQ(MakeBlobElement(KRefBlobUUID, 10, 10), message_descriptions[0]); | 294 EXPECT_EQ(MakeBlobElement(KRefBlobUUID, 10, 10), message_descriptions[0]); |
| 295 | 295 |
| 296 holder->OnCancel(kBlobUUID, | 296 holder->OnCancel(kBlobUUID, |
| 297 storage::IPCBlobCreationCancelCode::OUT_OF_MEMORY); | 297 storage::IPCBlobCreationCancelCode::OUT_OF_MEMORY); |
| 298 EXPECT_FALSE(holder->IsTransporting(kBlobUUID)); | 298 EXPECT_FALSE(holder->IsTransporting(kBlobUUID)); |
| 299 // Check we have the 'decrease ref' task. | 299 // Check we have the 'decrease ref' task. |
| 300 EXPECT_TRUE(main_thread_runner_->HasPendingTask()); | 300 EXPECT_TRUE(main_thread_runner_->HasPendingTask()); |
| 301 main_thread_runner_->ClearPendingTasks(); | 301 main_thread_runner_->ClearPendingTasks(); |
| 302 sink_.ClearMessages(); | 302 sink_.ClearMessages(); |
| (...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 339 std::vector<storage::BlobItemBytesResponse> output; | 339 std::vector<storage::BlobItemBytesResponse> output; |
| 340 | 340 |
| 341 // Error conditions | 341 // Error conditions |
| 342 EXPECT_EQ(ResponsesStatus::BLOB_NOT_FOUND, | 342 EXPECT_EQ(ResponsesStatus::BLOB_NOT_FOUND, |
| 343 holder->GetResponses(kBadBlobUUID, requests, &memory_handles, | 343 holder->GetResponses(kBadBlobUUID, requests, &memory_handles, |
| 344 file_handles, &output)); | 344 file_handles, &output)); |
| 345 EXPECT_EQ(0u, output.size()); | 345 EXPECT_EQ(0u, output.size()); |
| 346 } | 346 } |
| 347 | 347 |
| 348 } // namespace content | 348 } // namespace content |
| OLD | NEW |