| Index: blimp/engine/mojo/blob_channel_service.h
|
| diff --git a/blimp/engine/mojo/blob_channel_service.h b/blimp/engine/mojo/blob_channel_service.h
|
| index a137a0694087e56ab08a372acd940d50c251cd55..1ad7552857aaf39fd6f11c4e2a040c87f95b0ad0 100644
|
| --- a/blimp/engine/mojo/blob_channel_service.h
|
| +++ b/blimp/engine/mojo/blob_channel_service.h
|
| @@ -6,22 +6,30 @@
|
| #define BLIMP_ENGINE_MOJO_BLOB_CHANNEL_SERVICE_H_
|
|
|
| #include <string>
|
| +#include <vector>
|
|
|
| +#include "base/memory/weak_ptr.h"
|
| +#include "base/threading/thread_checker.h"
|
| #include "blimp/engine/mojo/blob_channel.mojom.h"
|
| +#include "blimp/net/blob_channel/blob_channel_sender.h"
|
| #include "mojo/public/cpp/bindings/binding_set.h"
|
|
|
| namespace blimp {
|
| -
|
| -class BlobChannelSender;
|
| -
|
| namespace engine {
|
|
|
| // Service for processing BlobChannel requests from the renderer.
|
| -// Runs on the browser process.
|
| +// Caller is responsible for executing all methods on the IO thread.
|
| +// The class may interact with objects on the UI thread by posting tasks to
|
| +// |ui_task_runner_|.
|
| class BlobChannelService : public mojom::BlobChannel {
|
| public:
|
| - // |blob_channel_sender| must outlive the Mojo connection.
|
| - explicit BlobChannelService(BlobChannelSender* blob_channel_sender);
|
| + // |blob_channel_sender|: The BlobChannelSender object which will receive
|
| + // blobs and answer delivery status queries.
|
| + // |blob_sender_task_runner|: The task runner that will process all
|
| + // interactions with |blob_channel_sender|.
|
| + BlobChannelService(
|
| + base::WeakPtr<BlobChannelSender> blob_channel_sender,
|
| + scoped_refptr<base::SingleThreadTaskRunner> blob_sender_task_runner);
|
|
|
| ~BlobChannelService() override;
|
|
|
| @@ -30,6 +38,13 @@ class BlobChannelService : public mojom::BlobChannel {
|
| void BindRequest(mojo::InterfaceRequest<mojom::BlobChannel> request);
|
|
|
| private:
|
| + std::vector<BlobChannelSender::CacheStateEntry> GetCachedBlobIdsOnUiThread();
|
| +
|
| + // Processes the return value from BlobChannelSender::GetCachedBlobIds().
|
| + void OnGetCachedBlobsCompleted(
|
| + const BlobChannelService::GetCachedBlobIdsCallback& response_callback,
|
| + const std::vector<BlobChannelSender::CacheStateEntry>& ids);
|
| +
|
| // BlobChannel implementation.
|
| void GetCachedBlobIds(
|
| const GetCachedBlobIdsCallback& response_callback) override;
|
| @@ -41,7 +56,14 @@ class BlobChannelService : public mojom::BlobChannel {
|
| mojo::BindingSet<mojom::BlobChannel> bindings_;
|
|
|
| // Sender object which will receive the blobs passed over the Mojo service.
|
| - BlobChannelSender* blob_channel_sender_;
|
| + base::WeakPtr<BlobChannelSender> blob_channel_sender_;
|
| +
|
| + // UI thread TaskRunner.
|
| + scoped_refptr<base::SingleThreadTaskRunner> blob_sender_task_runner_;
|
| +
|
| + base::ThreadChecker thread_checker_;
|
| +
|
| + base::WeakPtrFactory<BlobChannelService> weak_factory_;
|
|
|
| DISALLOW_COPY_AND_ASSIGN(BlobChannelService);
|
| };
|
|
|