Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(120)

Side by Side Diff: blimp/engine/renderer/blob_channel_sender_proxy.h

Issue 2629743003: Remove all blimp engine code (Closed)
Patch Set: Use consistent comment style in //chrome Created 3 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
(Empty)
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
3 // found in the LICENSE file.
4
5 #ifndef BLIMP_ENGINE_RENDERER_BLOB_CHANNEL_SENDER_PROXY_H_
6 #define BLIMP_ENGINE_RENDERER_BLOB_CHANNEL_SENDER_PROXY_H_
7
8 #include <map>
9 #include <memory>
10 #include <string>
11 #include <unordered_map>
12 #include <vector>
13
14 #include "base/containers/hash_tables.h"
15 #include "base/memory/weak_ptr.h"
16 #include "blimp/common/blimp_common_export.h"
17 #include "blimp/engine/mojo/blob_channel.mojom.h"
18 #include "blimp/net/blob_channel/blob_channel_sender.h"
19
20 namespace blimp {
21 namespace engine {
22
23 // Class for sending blobs (e.g. images) from the renderer to the browser
24 // process.
25 class BLIMP_COMMON_EXPORT BlobChannelSenderProxy : public BlobChannelSender {
26 public:
27 // Asynchronously request the set of cache keys from the browser process.
28 // Knowledge of the browser's cache allows the renderer to avoid re-encoding
29 // and re-transferring image assets that are already tracked by the
30 // browser-side cache.
31 //
32 // If |this| is used in the brief time before the response arrives,
33 // the object will continue to work, but false negatives will be returned
34 // for IsInEngineCache() and IsInClientCache().
35 BlobChannelSenderProxy();
36
37 ~BlobChannelSenderProxy() override;
38
39 static std::unique_ptr<BlobChannelSenderProxy> CreateForTest(
40 mojom::BlobChannelPtr blob_channel);
41
42 // Returns true if the blob is known to exist within the Engine cache.
43 bool IsInEngineCache(const std::string& id) const;
44
45 // Returns true if the blob has been delivered to the Client cache.
46 bool IsInClientCache(const std::string& id) const;
47
48 // BlobChannelSender implementation.
49 std::vector<CacheStateEntry> GetCachedBlobIds() const override;
50 void PutBlob(const BlobId& id, BlobDataPtr data) override;
51 void DeliverBlob(const BlobId& id) override;
52
53 private:
54 void OnGetCacheStateComplete(
55 const std::unordered_map<std::string, bool>& cache_state);
56
57 // Testing constructor, used to supply a BlobChannel Mojo proxy directly.
58 explicit BlobChannelSenderProxy(mojom::BlobChannelPtr blob_channel);
59
60 // BlobChannel Mojo IPC stub, used for delivering blobs to the browser
61 // process.
62 mojom::BlobChannelPtr blob_channel_;
63
64 // Local copy of the cache state for the local and remote BlobChannel.
65 // Knowledge of the cache state enables callers to avoid unnecessary
66 // image encoding and transferral if the content is already in the system.
67 base::hash_map<std::string, bool> replication_state_;
68
69 base::WeakPtrFactory<BlobChannelSenderProxy> weak_factory_;
70
71 DISALLOW_COPY_AND_ASSIGN(BlobChannelSenderProxy);
72 };
73
74 } // namespace engine
75 } // namespace blimp
76
77 #endif // BLIMP_ENGINE_RENDERER_BLOB_CHANNEL_SENDER_PROXY_H_
OLDNEW
« no previous file with comments | « blimp/engine/renderer/blimp_remote_compositor_bridge_unittest.cc ('k') | blimp/engine/renderer/blob_channel_sender_proxy.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698