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

Unified 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 side-by-side diff with in-line comments
Download patch
Index: blimp/engine/renderer/blob_channel_sender_proxy.cc
diff --git a/blimp/engine/renderer/blob_channel_sender_proxy.cc b/blimp/engine/renderer/blob_channel_sender_proxy.cc
new file mode 100644
index 0000000000000000000000000000000000000000..8b689d36c73dd840878105bb72a926845ebe97be
--- /dev/null
+++ b/blimp/engine/renderer/blob_channel_sender_proxy.cc
@@ -0,0 +1,56 @@
+// Copyright 2016 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include "blimp/engine/renderer/blob_channel_sender_proxy.h"
+
+#include "content/public/common/service_registry.h"
+#include "content/public/renderer/render_thread.h"
+
+namespace blimp {
+namespace engine {
+namespace {
+
+mojom::BlobChannelPtr GetConnectedBlobChannel() {
+ mojom::BlobChannelPtr blob_channel_ptr;
+ content::RenderThread::Get()->GetServiceRegistry()->ConnectToRemoteService(
+ mojo::GetProxy(&blob_channel_ptr));
+ CHECK(blob_channel_ptr) << "Could not connect to BlobChannel Mojo service.";
+ return blob_channel_ptr;
+}
+
+} // namespace
+
+BlobChannelSenderProxy::BlobChannelSenderProxy()
+ : blob_channel_(GetConnectedBlobChannel()) {}
+
+BlobChannelSenderProxy::~BlobChannelSenderProxy() {}
+
+bool BlobChannelSenderProxy::IsInEngineCache(const std::string& id) const {
+ return replication_state_.find(id) != replication_state_.end();
+}
+
+bool BlobChannelSenderProxy::IsInClientCache(const std::string& id) const {
+ return replication_state_.find(id)->second;
+}
+
+void BlobChannelSenderProxy::PutBlob(const BlobId& id, BlobDataPtr data) {
+ DCHECK(!IsInEngineCache(id));
+
+ replication_state_[id] = false;
+ blob_channel_->PutBlob(id, data->data);
+}
+
+void BlobChannelSenderProxy::DeliverBlob(const std::string& id) {
+ DCHECK(!IsInClientCache(id));
+
+ // We assume that the client will have the blob if we push it.
+ // TODO(kmarshall): Revisit this assumption when asynchronous blob transport
+ // is supported.
+ replication_state_[id] = true;
+
+ blob_channel_->DeliverBlob(id);
+}
+
+} // namespace engine
+} // namespace blimp
« 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