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

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

Issue 2056993003: Add Mojo IPC for seeding new Renderer with Browser's cached blob state. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@blobchannel-master
Patch Set: STL containers yay Created 4 years, 5 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
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 <map>
8 #include <memory> 9 #include <memory>
9 #include <string> 10 #include <string>
11 #include <unordered_map>
12 #include <vector>
10 13
11 #include "base/containers/hash_tables.h" 14 #include "base/containers/hash_tables.h"
15 #include "base/memory/weak_ptr.h"
12 #include "blimp/common/blimp_common_export.h" 16 #include "blimp/common/blimp_common_export.h"
13 #include "blimp/engine/mojo/blob_channel.mojom.h" 17 #include "blimp/engine/mojo/blob_channel.mojom.h"
14 #include "blimp/net/blob_channel/blob_channel_sender.h" 18 #include "blimp/net/blob_channel/blob_channel_sender.h"
15 19
16 namespace blimp { 20 namespace blimp {
17 namespace engine { 21 namespace engine {
18 22
19 // Class for sending blobs (e.g. images) from the renderer to the browser 23 // Class for sending blobs (e.g. images) from the renderer to the browser
20 // process. 24 // process.
21 class BLIMP_COMMON_EXPORT BlobChannelSenderProxy : public BlobChannelSender { 25 class BLIMP_COMMON_EXPORT BlobChannelSenderProxy : public BlobChannelSender {
22 public: 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().
23 BlobChannelSenderProxy(); 35 BlobChannelSenderProxy();
24 36
25 ~BlobChannelSenderProxy() override; 37 ~BlobChannelSenderProxy() override;
26 38
27 static std::unique_ptr<BlobChannelSenderProxy> CreateForTest( 39 static std::unique_ptr<BlobChannelSenderProxy> CreateForTest(
28 mojom::BlobChannelPtr blob_channel); 40 mojom::BlobChannelPtr blob_channel);
29 41
30 // Returns true if the blob is known to exist within the Engine cache. 42 // Returns true if the blob is known to exist within the Engine cache.
31 bool IsInEngineCache(const std::string& id) const; 43 bool IsInEngineCache(const std::string& id) const;
32 44
33 // Returns true if the blob has been delivered to the Client cache. 45 // Returns true if the blob has been delivered to the Client cache.
34 bool IsInClientCache(const std::string& id) const; 46 bool IsInClientCache(const std::string& id) const;
35 47
36 // BlobChannelSender implementation. 48 // BlobChannelSender implementation.
49 std::vector<CacheStateEntry> GetCachedBlobIds() const override;
37 void PutBlob(const BlobId& id, BlobDataPtr data) override; 50 void PutBlob(const BlobId& id, BlobDataPtr data) override;
38 void DeliverBlob(const BlobId& id) override; 51 void DeliverBlob(const BlobId& id) override;
39 52
40 private: 53 private:
54 void OnGetCacheStateComplete(
55 const std::unordered_map<std::string, bool>& cache_state);
56
41 // Testing constructor, used to supply a BlobChannel Mojo proxy directly. 57 // Testing constructor, used to supply a BlobChannel Mojo proxy directly.
42 explicit BlobChannelSenderProxy(mojom::BlobChannelPtr blob_channel); 58 explicit BlobChannelSenderProxy(mojom::BlobChannelPtr blob_channel);
43 59
44 // BlobChannel Mojo IPC stub, used for delivering blobs to the browser 60 // BlobChannel Mojo IPC stub, used for delivering blobs to the browser
45 // process. 61 // process.
46 mojom::BlobChannelPtr blob_channel_; 62 mojom::BlobChannelPtr blob_channel_;
47 63
48 // Local copy of the cache state for the local and remote BlobChannel. 64 // Local copy of the cache state for the local and remote BlobChannel.
49 // Knowledge of the cache state enables callers to avoid unnecessary 65 // Knowledge of the cache state enables callers to avoid unnecessary
50 // image encoding and transferral if the content is already in the system. 66 // image encoding and transferral if the content is already in the system.
51 base::hash_map<std::string, bool> replication_state_; 67 base::hash_map<std::string, bool> replication_state_;
52 68
69 base::WeakPtrFactory<BlobChannelSenderProxy> weak_factory_;
70
53 DISALLOW_COPY_AND_ASSIGN(BlobChannelSenderProxy); 71 DISALLOW_COPY_AND_ASSIGN(BlobChannelSenderProxy);
54 }; 72 };
55 73
56 } // namespace engine 74 } // namespace engine
57 } // namespace blimp 75 } // namespace blimp
58 76
59 #endif // BLIMP_ENGINE_RENDERER_BLOB_CHANNEL_SENDER_PROXY_H_ 77 #endif // BLIMP_ENGINE_RENDERER_BLOB_CHANNEL_SENDER_PROXY_H_
OLDNEW
« no previous file with comments | « blimp/engine/mojo/blob_channel_service.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