Chromium Code Reviews| 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 #ifndef BLIMP_ENGINE_MOJO_BLOB_CHANNEL_SERVICE_H_ | 5 #ifndef BLIMP_ENGINE_MOJO_BLOB_CHANNEL_SERVICE_H_ |
| 6 #define BLIMP_ENGINE_MOJO_BLOB_CHANNEL_SERVICE_H_ | 6 #define BLIMP_ENGINE_MOJO_BLOB_CHANNEL_SERVICE_H_ |
| 7 | 7 |
| 8 #include <string> | 8 #include <string> |
| 9 | 9 |
| 10 #include "blimp/engine/mojo/blob_channel.mojom.h" | 10 #include "blimp/engine/mojo/blob_channel.mojom.h" |
| 11 #include "mojo/public/cpp/bindings/strong_binding.h" | 11 #include "mojo/public/cpp/bindings/binding_set.h" |
| 12 | 12 |
| 13 namespace blimp { | 13 namespace blimp { |
| 14 | 14 |
| 15 class BlobChannelSender; | 15 class BlobChannelSender; |
| 16 | 16 |
| 17 namespace engine { | 17 namespace engine { |
| 18 | 18 |
| 19 // Service for processing BlobChannel requests from the renderer. | 19 // Service for processing BlobChannel requests from the renderer. |
| 20 // Runs on the browser process. | 20 // Runs on the browser process. |
| 21 class BlobChannelService : public mojom::BlobChannel { | 21 class BlobChannelService : public mojom::BlobChannel { |
| 22 public: | 22 public: |
| 23 // |blob_channel_sender| must outlive the Mojo connection. | |
| 24 explicit BlobChannelService(BlobChannelSender* blob_channel_sender); | |
| 25 | |
| 23 ~BlobChannelService() override; | 26 ~BlobChannelService() override; |
| 24 | 27 |
| 25 // Factory method called by Mojo. | 28 // Factory method called by Mojo. |
| 26 static void Create(BlobChannelSender* blob_channel_sender, | 29 // Binds |this| to the connection specified by |request|. |
| 27 mojo::InterfaceRequest<mojom::BlobChannel> request); | 30 void BindRequest(mojo::InterfaceRequest<mojom::BlobChannel> request); |
| 28 | 31 |
| 29 private: | 32 private: |
| 30 // Creates a BlobChannel bound to the connection specified by |request|. | |
| 31 // |blob_channel_sender| must outlive the Mojo connection. | |
| 32 BlobChannelService(BlobChannelSender* blob_channel_sender, | |
| 33 mojom::BlobChannelRequest request); | |
| 34 | |
| 35 // BlobChannel implementation. | 33 // BlobChannel implementation. |
| 36 void GetCachedBlobIds( | 34 void GetCachedBlobIds( |
| 37 const GetCachedBlobIdsCallback& response_callback) override; | 35 const GetCachedBlobIdsCallback& response_callback) override; |
| 38 void PutBlob(const std::string& id, | 36 void PutBlob(const std::string& id, |
| 39 mojo::ScopedSharedBufferHandle data, | 37 mojo::ScopedSharedBufferHandle data, |
| 40 uint32_t size) override; | 38 uint32_t size) override; |
| 41 void DeliverBlob(const std::string& id) override; | 39 void DeliverBlob(const std::string& id) override; |
| 42 | 40 |
| 43 // Binds |this| and its object lifetime to a Mojo connection. | 41 // Binds |this| and its object lifetime to a set of Mojo connections. |
|
Kevin M
2016/07/28 20:59:17
The lifetime is not bound to BindingSet at all?
CJ
2016/07/28 22:47:05
Done.
| |
| 44 mojo::StrongBinding<mojom::BlobChannel> binding_; | 42 mojo::BindingSet<mojom::BlobChannel> bindings_; |
| 45 | 43 |
| 46 // Sender object which will receive the blobs passed over the Mojo service. | 44 // Sender object which will receive the blobs passed over the Mojo service. |
| 47 BlobChannelSender* blob_channel_sender_; | 45 BlobChannelSender* blob_channel_sender_; |
| 48 | 46 |
| 49 DISALLOW_COPY_AND_ASSIGN(BlobChannelService); | 47 DISALLOW_COPY_AND_ASSIGN(BlobChannelService); |
| 50 }; | 48 }; |
| 51 | 49 |
| 52 } // namespace engine | 50 } // namespace engine |
| 53 } // namespace blimp | 51 } // namespace blimp |
| 54 | 52 |
| 55 #endif // BLIMP_ENGINE_MOJO_BLOB_CHANNEL_SERVICE_H_ | 53 #endif // BLIMP_ENGINE_MOJO_BLOB_CHANNEL_SERVICE_H_ |
| OLD | NEW |