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 "blimp/engine/mojo/blob_channel.mojom.h" | 8 #include "blimp/engine/mojo/blob_channel.mojom.h" |
9 #include "mojo/public/cpp/bindings/strong_binding.h" | 9 #include "mojo/public/cpp/bindings/strong_binding.h" |
10 | 10 |
11 namespace blimp { | 11 namespace blimp { |
| 12 |
| 13 class BlobChannelSender; |
| 14 |
12 namespace engine { | 15 namespace engine { |
13 | 16 |
14 // Service for processing BlobChannel requests from the renderer. | 17 // Service for processing BlobChannel requests from the renderer. |
15 // Runs on the browser process. | 18 // Runs on the browser process. |
16 class BlobChannelService : public mojom::BlobChannel { | 19 class BlobChannelService : public mojom::BlobChannel { |
17 public: | 20 public: |
18 // Creates a BlobChannel bound to the connection specified by |request|. | |
19 explicit BlobChannelService(mojom::BlobChannelRequest request); | |
20 ~BlobChannelService() override; | 21 ~BlobChannelService() override; |
21 | 22 |
22 // Factory method called by Mojo. | 23 // Factory method called by Mojo. |
23 static void Create(mojo::InterfaceRequest<mojom::BlobChannel> request); | 24 static void Create(BlobChannelSender* blob_channel_sender, |
| 25 mojo::InterfaceRequest<mojom::BlobChannel> request); |
24 | 26 |
25 private: | 27 private: |
| 28 // Creates a BlobChannel bound to the connection specified by |request|. |
| 29 // |blob_channel_sender| must outlive the Mojo connection. |
| 30 BlobChannelService(BlobChannelSender* blob_channel_sender, |
| 31 mojom::BlobChannelRequest request); |
| 32 |
26 // BlobChannel implementation. | 33 // BlobChannel implementation. |
27 void Put(const mojo::String& id, mojo::Array<uint8_t> data) override; | 34 void PutBlob(const mojo::String& id, const mojo::String& data) override; |
28 void Push(const mojo::String& id) override; | 35 void DeliverBlob(const mojo::String& id) override; |
29 | 36 |
30 // Binds |this| and its object lifetime to a Mojo connection. | 37 // Binds |this| and its object lifetime to a Mojo connection. |
31 mojo::StrongBinding<mojom::BlobChannel> binding_; | 38 mojo::StrongBinding<mojom::BlobChannel> binding_; |
32 | 39 |
| 40 // Sender object which will receive the blobs passed over the Mojo service. |
| 41 BlobChannelSender* blob_channel_sender_; |
| 42 |
33 DISALLOW_COPY_AND_ASSIGN(BlobChannelService); | 43 DISALLOW_COPY_AND_ASSIGN(BlobChannelService); |
34 }; | 44 }; |
35 | 45 |
36 } // namespace engine | 46 } // namespace engine |
37 } // namespace blimp | 47 } // namespace blimp |
38 | 48 |
39 #endif // BLIMP_ENGINE_MOJO_BLOB_CHANNEL_SERVICE_H_ | 49 #endif // BLIMP_ENGINE_MOJO_BLOB_CHANNEL_SERVICE_H_ |
OLD | NEW |