| OLD | NEW |
| 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 <memory> | 5 #include <memory> |
| 6 | 6 |
| 7 #include "base/location.h" |
| 7 #include "base/memory/ptr_util.h" | 8 #include "base/memory/ptr_util.h" |
| 8 #include "base/message_loop/message_loop.h" | 9 #include "base/message_loop/message_loop.h" |
| 9 #include "base/run_loop.h" | 10 #include "base/run_loop.h" |
| 11 #include "base/single_thread_task_runner.h" |
| 12 #include "base/threading/thread_task_runner_handle.h" |
| 10 #include "blimp/common/blob_cache/id_util.h" | 13 #include "blimp/common/blob_cache/id_util.h" |
| 11 #include "blimp/common/blob_cache/in_memory_blob_cache.h" | 14 #include "blimp/common/blob_cache/in_memory_blob_cache.h" |
| 12 #include "blimp/common/blob_cache/test_util.h" | 15 #include "blimp/common/blob_cache/test_util.h" |
| 13 #include "blimp/net/blob_channel/blob_channel_receiver.h" | 16 #include "blimp/net/blob_channel/blob_channel_receiver.h" |
| 14 #include "blimp/net/blob_channel/blob_channel_sender.h" | 17 #include "blimp/net/blob_channel/blob_channel_sender.h" |
| 15 #include "blimp/net/blob_channel/mock_blob_channel_receiver.h" | 18 #include "blimp/net/blob_channel/mock_blob_channel_receiver.h" |
| 16 #include "blimp/net/test_common.h" | 19 #include "blimp/net/test_common.h" |
| 17 #include "testing/gtest/include/gtest/gtest.h" | 20 #include "testing/gtest/include/gtest/gtest.h" |
| 18 | 21 |
| 19 namespace blimp { | 22 namespace blimp { |
| (...skipping 10 matching lines...) Expand all Loading... |
| 30 // after |this| is deleted. | 33 // after |this| is deleted. |
| 31 class SenderDelegateProxy : public BlobChannelSender::Delegate { | 34 class SenderDelegateProxy : public BlobChannelSender::Delegate { |
| 32 public: | 35 public: |
| 33 explicit SenderDelegateProxy(BlobChannelReceiver* receiver) | 36 explicit SenderDelegateProxy(BlobChannelReceiver* receiver) |
| 34 : receiver_(receiver) {} | 37 : receiver_(receiver) {} |
| 35 ~SenderDelegateProxy() override {} | 38 ~SenderDelegateProxy() override {} |
| 36 | 39 |
| 37 private: | 40 private: |
| 38 // BlobChannelSender implementation. | 41 // BlobChannelSender implementation. |
| 39 void DeliverBlob(const BlobId& id, BlobDataPtr data) override { | 42 void DeliverBlob(const BlobId& id, BlobDataPtr data) override { |
| 40 base::MessageLoop::current()->PostTask( | 43 base::ThreadTaskRunnerHandle::Get()->PostTask( |
| 41 FROM_HERE, base::Bind(&BlobChannelReceiver::OnBlobReceived, | 44 FROM_HERE, base::Bind(&BlobChannelReceiver::OnBlobReceived, |
| 42 base::Unretained(receiver_), id, data)); | 45 base::Unretained(receiver_), id, data)); |
| 43 } | 46 } |
| 44 | 47 |
| 45 BlobChannelReceiver* receiver_; | 48 BlobChannelReceiver* receiver_; |
| 46 | 49 |
| 47 DISALLOW_COPY_AND_ASSIGN(SenderDelegateProxy); | 50 DISALLOW_COPY_AND_ASSIGN(SenderDelegateProxy); |
| 48 }; | 51 }; |
| 49 | 52 |
| 50 // Verifies compatibility between the sender and receiver, independent of | 53 // Verifies compatibility between the sender and receiver, independent of |
| (...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 91 | 94 |
| 92 EXPECT_EQ(nullptr, receiver_->Get(blob_id).get()); | 95 EXPECT_EQ(nullptr, receiver_->Get(blob_id).get()); |
| 93 sender_->DeliverBlob(blob_id); | 96 sender_->DeliverBlob(blob_id); |
| 94 | 97 |
| 95 base::RunLoop().RunUntilIdle(); | 98 base::RunLoop().RunUntilIdle(); |
| 96 EXPECT_EQ(kBlobPayload, receiver_->Get(blob_id)->data); | 99 EXPECT_EQ(kBlobPayload, receiver_->Get(blob_id)->data); |
| 97 } | 100 } |
| 98 | 101 |
| 99 } // namespace | 102 } // namespace |
| 100 } // namespace blimp | 103 } // namespace blimp |
| OLD | NEW |