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

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

Issue 1985863002: Incorporate BlobChannel into Blimp image encode/decode pipeline. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@blobchannel-helium
Patch Set: fix gn dependency warning & rebase Created 4 years, 6 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 #include "blimp/engine/renderer/blob_channel_sender_proxy.h"
6
7 #include "content/public/common/service_registry.h"
8 #include "content/public/renderer/render_thread.h"
9
10 namespace blimp {
11 namespace engine {
12 namespace {
13
14 mojom::BlobChannelPtr GetConnectedBlobChannel() {
15 mojom::BlobChannelPtr blob_channel_ptr;
16 content::RenderThread::Get()->GetServiceRegistry()->ConnectToRemoteService(
17 mojo::GetProxy(&blob_channel_ptr));
18 CHECK(blob_channel_ptr) << "Could not connect to BlobChannel Mojo service.";
19 return blob_channel_ptr;
20 }
21
22 } // namespace
23
24 BlobChannelSenderProxy::BlobChannelSenderProxy()
25 : blob_channel_(GetConnectedBlobChannel()) {}
26
27 BlobChannelSenderProxy::~BlobChannelSenderProxy() {}
28
29 bool BlobChannelSenderProxy::IsInEngineCache(const std::string& id) const {
30 return replication_state_.find(id) != replication_state_.end();
31 }
32
33 bool BlobChannelSenderProxy::IsInClientCache(const std::string& id) const {
34 return replication_state_.find(id)->second;
35 }
36
37 void BlobChannelSenderProxy::PutBlob(const BlobId& id, BlobDataPtr data) {
38 DCHECK(!IsInEngineCache(id));
39
40 replication_state_[id] = false;
41 blob_channel_->PutBlob(id, data->data);
42 }
43
44 void BlobChannelSenderProxy::DeliverBlob(const std::string& id) {
45 DCHECK(!IsInClientCache(id));
46
47 // We assume that the client will have the blob if we push it.
48 // TODO(kmarshall): Revisit this assumption when asynchronous blob transport
49 // is supported.
50 replication_state_[id] = true;
51
52 blob_channel_->DeliverBlob(id);
53 }
54
55 } // namespace engine
56 } // namespace blimp
OLDNEW
« no previous file with comments | « blimp/engine/renderer/blob_channel_sender_proxy.h ('k') | blimp/engine/renderer/engine_image_serialization_processor.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698