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 "storage/browser/blob/blob_async_builder_host.h" | 5 #include "storage/browser/blob/blob_async_builder_host.h" |
6 | 6 |
7 #include <stddef.h> | 7 #include <stddef.h> |
8 #include <stdint.h> | 8 #include <stdint.h> |
9 #include <string.h> | 9 #include <string.h> |
10 | 10 |
(...skipping 508 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
519 {kBlob1}, &context_)); | 519 {kBlob1}, &context_)); |
520 EXPECT_EQ(BlobTransportResult::DONE, | 520 EXPECT_EQ(BlobTransportResult::DONE, |
521 host_.RegisterBlobUUID(kBlob2, kContentType, kContentDisposition, | 521 host_.RegisterBlobUUID(kBlob2, kContentType, kContentDisposition, |
522 {kGoodBlob}, &context_)); | 522 {kGoodBlob}, &context_)); |
523 EXPECT_EQ(BlobTransportResult::DONE, | 523 EXPECT_EQ(BlobTransportResult::DONE, |
524 host_.RegisterBlobUUID(kBlob3, kContentType, kContentDisposition, | 524 host_.RegisterBlobUUID(kBlob3, kContentType, kContentDisposition, |
525 std::set<std::string>(), &context_)); | 525 std::set<std::string>(), &context_)); |
526 | 526 |
527 // The first blob shouldn't be building anymore. | 527 // The first blob shouldn't be building anymore. |
528 EXPECT_FALSE(host_.IsBeingBuilt(kBlob1)); | 528 EXPECT_FALSE(host_.IsBeingBuilt(kBlob1)); |
529 // Test we get BAD_IPC. | |
530 std::vector<DataElement> descriptions; | |
531 AddShortcutMemoryItem(2, &descriptions); | |
532 DataElement element; | |
533 element.SetToBlob(kBlob1); | |
534 descriptions.push_back(element); | |
535 EXPECT_EQ(BlobTransportResult::BAD_IPC, | |
536 host_.StartBuildingBlob( | |
537 kBlob1, descriptions, 2, &context_, | |
538 base::Bind(&BlobAsyncBuilderHostTest::RequestMemoryCallback, | |
539 base::Unretained(this)))); | |
540 | 529 |
541 // Try to finish the second one, without a reference to the first. | 530 // Try to finish the second one, without a reference to the first. |
542 descriptions.clear(); | 531 std::vector<DataElement> descriptions; |
543 AddShortcutMemoryItem(2, &descriptions); | 532 AddShortcutMemoryItem(2, &descriptions); |
544 EXPECT_EQ(BlobTransportResult::BAD_IPC, | 533 EXPECT_EQ(BlobTransportResult::BAD_IPC, |
545 host_.StartBuildingBlob( | 534 host_.StartBuildingBlob( |
546 kBlob2, descriptions, 2, &context_, | 535 kBlob2, descriptions, 2, &context_, |
547 base::Bind(&BlobAsyncBuilderHostTest::RequestMemoryCallback, | 536 base::Bind(&BlobAsyncBuilderHostTest::RequestMemoryCallback, |
548 base::Unretained(this)))); | 537 base::Unretained(this)))); |
549 EXPECT_FALSE(host_.IsBeingBuilt(kBlob2)); | 538 EXPECT_FALSE(host_.IsBeingBuilt(kBlob2)); |
550 | 539 |
551 // Try to finish the third one with the reference we didn't declare earlier. | 540 // Try to finish the third one with the reference we didn't declare earlier. |
552 descriptions.clear(); | 541 descriptions.clear(); |
553 AddShortcutMemoryItem(2, &descriptions); | 542 AddShortcutMemoryItem(2, &descriptions); |
| 543 DataElement element; |
554 element.SetToBlob(kGoodBlob); | 544 element.SetToBlob(kGoodBlob); |
555 descriptions.push_back(element); | 545 descriptions.push_back(element); |
556 EXPECT_EQ(BlobTransportResult::BAD_IPC, | 546 EXPECT_EQ(BlobTransportResult::BAD_IPC, |
557 host_.StartBuildingBlob( | 547 host_.StartBuildingBlob( |
558 kBlob3, descriptions, 2, &context_, | 548 kBlob3, descriptions, 2, &context_, |
559 base::Bind(&BlobAsyncBuilderHostTest::RequestMemoryCallback, | 549 base::Bind(&BlobAsyncBuilderHostTest::RequestMemoryCallback, |
560 base::Unretained(this)))); | 550 base::Unretained(this)))); |
561 EXPECT_FALSE(host_.IsBeingBuilt(kBlob3)); | 551 EXPECT_FALSE(host_.IsBeingBuilt(kBlob3)); |
562 }; | 552 }; |
563 | 553 |
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
613 host_.RegisterBlobUUID(kBlob1, kContentType, kContentDisposition, | 603 host_.RegisterBlobUUID(kBlob1, kContentType, kContentDisposition, |
614 std::set<std::string>(), &context_)); | 604 std::set<std::string>(), &context_)); |
615 host_.CancelBuildingBlob(kBlob1, IPCBlobCreationCancelCode::UNKNOWN, | 605 host_.CancelBuildingBlob(kBlob1, IPCBlobCreationCancelCode::UNKNOWN, |
616 &context_); | 606 &context_); |
617 EXPECT_EQ(BlobTransportResult::CANCEL_REFERENCED_BLOB_BROKEN, | 607 EXPECT_EQ(BlobTransportResult::CANCEL_REFERENCED_BLOB_BROKEN, |
618 host_.RegisterBlobUUID(kBlob2, kContentType, kContentDisposition, | 608 host_.RegisterBlobUUID(kBlob2, kContentType, kContentDisposition, |
619 {kBlob1}, &context_)); | 609 {kBlob1}, &context_)); |
620 EXPECT_FALSE(host_.IsBeingBuilt(kBlob2)); | 610 EXPECT_FALSE(host_.IsBeingBuilt(kBlob2)); |
621 EXPECT_FALSE(IsBeingBuiltInContext(kBlob2)); | 611 EXPECT_FALSE(IsBeingBuiltInContext(kBlob2)); |
622 EXPECT_TRUE(context_.GetBlobDataFromUUID(kBlob2)->IsBroken()); | 612 EXPECT_TRUE(context_.GetBlobDataFromUUID(kBlob2)->IsBroken()); |
623 | |
624 // Try to finish the second one, but we should get a BAD_IPC, as we are no | |
625 // longer being constructed. | |
626 std::vector<DataElement> descriptions; | |
627 AddShortcutMemoryItem(2, &descriptions); | |
628 DataElement element; | |
629 element.SetToBlob(kBlob1); | |
630 descriptions.push_back(element); | |
631 EXPECT_EQ(BlobTransportResult::BAD_IPC, | |
632 host_.StartBuildingBlob( | |
633 kBlob2, descriptions, 2, &context_, | |
634 base::Bind(&BlobAsyncBuilderHostTest::RequestMemoryCallback, | |
635 base::Unretained(this)))); | |
636 EXPECT_FALSE(request_called_); | |
637 EXPECT_TRUE(context_.GetBlobDataFromUUID(kBlob2)->IsBroken()); | |
638 }; | 613 }; |
639 | 614 |
640 } // namespace storage | 615 } // namespace storage |
OLD | NEW |