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_RENDERER_BLOB_CHANNEL_SENDER_PROXY_H_ | 5 #ifndef BLIMP_ENGINE_RENDERER_BLOB_CHANNEL_SENDER_PROXY_H_ |
6 #define BLIMP_ENGINE_RENDERER_BLOB_CHANNEL_SENDER_PROXY_H_ | 6 #define BLIMP_ENGINE_RENDERER_BLOB_CHANNEL_SENDER_PROXY_H_ |
7 | 7 |
8 #include <memory> | 8 #include <memory> |
9 #include <string> | 9 #include <string> |
10 | 10 |
11 #include "base/containers/hash_tables.h" | 11 #include "base/containers/hash_tables.h" |
12 #include "blimp/common/blimp_common_export.h" | 12 #include "blimp/common/blimp_common_export.h" |
13 #include "blimp/engine/mojo/blob_channel.mojom.h" | 13 #include "blimp/engine/mojo/blob_channel.mojom.h" |
14 #include "blimp/net/blob_channel/blob_channel_sender.h" | 14 #include "blimp/net/blob_channel/blob_channel_sender.h" |
15 | 15 |
16 namespace blimp { | 16 namespace blimp { |
17 namespace engine { | 17 namespace engine { |
18 | 18 |
19 // Class for sending blobs (e.g. images) from the renderer to the browser | 19 // Class for sending blobs (e.g. images) from the renderer to the browser |
20 // process. | 20 // process. |
21 class BLIMP_COMMON_EXPORT BlobChannelSenderProxy : public BlobChannelSender { | 21 class BLIMP_COMMON_EXPORT BlobChannelSenderProxy : public BlobChannelSender { |
22 public: | 22 public: |
23 BlobChannelSenderProxy(); | 23 BlobChannelSenderProxy(); |
| 24 |
24 ~BlobChannelSenderProxy() override; | 25 ~BlobChannelSenderProxy() override; |
25 | 26 |
| 27 static std::unique_ptr<BlobChannelSenderProxy> CreateForTest( |
| 28 mojom::BlobChannelPtr blob_channel); |
| 29 |
26 // Returns true if the blob is known to exist within the Engine cache. | 30 // Returns true if the blob is known to exist within the Engine cache. |
27 bool IsInEngineCache(const std::string& id) const; | 31 bool IsInEngineCache(const std::string& id) const; |
28 | 32 |
29 // Returns true if the blob has been delivered to the Client cache. | 33 // Returns true if the blob has been delivered to the Client cache. |
30 bool IsInClientCache(const std::string& id) const; | 34 bool IsInClientCache(const std::string& id) const; |
31 | 35 |
32 // BlobChannelSender implementation. | 36 // BlobChannelSender implementation. |
33 void PutBlob(const BlobId& id, BlobDataPtr data) override; | 37 void PutBlob(const BlobId& id, BlobDataPtr data) override; |
34 void DeliverBlob(const BlobId& id) override; | 38 void DeliverBlob(const BlobId& id) override; |
35 | 39 |
36 private: | 40 private: |
| 41 // Testing constructor, used to supply a BlobChannel Mojo proxy directly. |
| 42 explicit BlobChannelSenderProxy(mojom::BlobChannelPtr blob_channel); |
| 43 |
37 // BlobChannel Mojo IPC stub, used for delivering blobs to the browser | 44 // BlobChannel Mojo IPC stub, used for delivering blobs to the browser |
38 // process. | 45 // process. |
39 mojom::BlobChannelPtr blob_channel_; | 46 mojom::BlobChannelPtr blob_channel_; |
40 | 47 |
41 // Local copy of the cache state for the local and remote BlobChannel. | 48 // Local copy of the cache state for the local and remote BlobChannel. |
42 // Knowledge of the cache state enables callers to avoid unnecessary | 49 // Knowledge of the cache state enables callers to avoid unnecessary |
43 // image encoding and transferral if the content is already in the system. | 50 // image encoding and transferral if the content is already in the system. |
44 base::hash_map<std::string, bool> replication_state_; | 51 base::hash_map<std::string, bool> replication_state_; |
45 | 52 |
46 DISALLOW_COPY_AND_ASSIGN(BlobChannelSenderProxy); | 53 DISALLOW_COPY_AND_ASSIGN(BlobChannelSenderProxy); |
47 }; | 54 }; |
48 | 55 |
49 } // namespace engine | 56 } // namespace engine |
50 } // namespace blimp | 57 } // namespace blimp |
51 | 58 |
52 #endif // BLIMP_ENGINE_RENDERER_BLOB_CHANNEL_SENDER_PROXY_H_ | 59 #endif // BLIMP_ENGINE_RENDERER_BLOB_CHANNEL_SENDER_PROXY_H_ |
OLD | NEW |