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

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

Issue 2561963002: base: Remove the string logging from CHECK(). (Closed)
Patch Set: checkstring: rebase Created 4 years 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 #include "blimp/engine/renderer/blob_channel_sender_proxy.h" 5 #include "blimp/engine/renderer/blob_channel_sender_proxy.h"
6 6
7 #include <unordered_map> 7 #include <unordered_map>
8 #include <utility> 8 #include <utility>
9 9
10 #include "blimp/common/blob_cache/id_util.h" 10 #include "blimp/common/blob_cache/id_util.h"
11 #include "content/public/renderer/render_thread.h" 11 #include "content/public/renderer/render_thread.h"
12 #include "services/service_manager/public/cpp/interface_provider.h" 12 #include "services/service_manager/public/cpp/interface_provider.h"
13 13
14 namespace blimp { 14 namespace blimp {
15 namespace engine { 15 namespace engine {
16 namespace { 16 namespace {
17 17
18 mojom::BlobChannelPtr GetConnectedBlobChannel() { 18 mojom::BlobChannelPtr GetConnectedBlobChannel() {
19 mojom::BlobChannelPtr blob_channel_ptr; 19 mojom::BlobChannelPtr blob_channel_ptr;
20 content::RenderThread::Get()->GetRemoteInterfaces()->GetInterface( 20 content::RenderThread::Get()->GetRemoteInterfaces()->GetInterface(
21 &blob_channel_ptr); 21 &blob_channel_ptr);
22 CHECK(blob_channel_ptr) << "Could not connect to BlobChannel Mojo interface."; 22 // Could not connect to BlobChannel Mojo interface.
23 CHECK(blob_channel_ptr);
23 return blob_channel_ptr; 24 return blob_channel_ptr;
24 } 25 }
25 26
26 // Manages the creation and lifetime of Mojo shared memory buffers for blobs. 27 // Manages the creation and lifetime of Mojo shared memory buffers for blobs.
27 class SharedMemoryBlob { 28 class SharedMemoryBlob {
28 public: 29 public:
29 explicit SharedMemoryBlob(BlobDataPtr data); 30 explicit SharedMemoryBlob(BlobDataPtr data);
30 ~SharedMemoryBlob(); 31 ~SharedMemoryBlob();
31 32
32 mojo::ScopedSharedBufferHandle CreateRemoteHandle(); 33 mojo::ScopedSharedBufferHandle CreateRemoteHandle();
(...skipping 14 matching lines...) Expand all
47 local_handle_->Map(data->data.size()); 48 local_handle_->Map(data->data.size());
48 DCHECK(mapped); 49 DCHECK(mapped);
49 memcpy(mapped.get(), data->data.data(), data->data.size()); 50 memcpy(mapped.get(), data->data.data(), data->data.size());
50 } 51 }
51 52
52 SharedMemoryBlob::~SharedMemoryBlob() {} 53 SharedMemoryBlob::~SharedMemoryBlob() {}
53 54
54 mojo::ScopedSharedBufferHandle SharedMemoryBlob::CreateRemoteHandle() { 55 mojo::ScopedSharedBufferHandle SharedMemoryBlob::CreateRemoteHandle() {
55 mojo::ScopedSharedBufferHandle remote_handle = 56 mojo::ScopedSharedBufferHandle remote_handle =
56 local_handle_->Clone(mojo::SharedBufferHandle::AccessMode::READ_ONLY); 57 local_handle_->Clone(mojo::SharedBufferHandle::AccessMode::READ_ONLY);
57 CHECK(remote_handle.is_valid()) 58 // Mojo error when creating read-only buffer handle.
58 << "Mojo error when creating read-only buffer handle."; 59 CHECK(remote_handle.is_valid());
59 return remote_handle; 60 return remote_handle;
60 } 61 }
61 62
62 } // namespace 63 } // namespace
63 64
64 BlobChannelSenderProxy::BlobChannelSenderProxy() 65 BlobChannelSenderProxy::BlobChannelSenderProxy()
65 : blob_channel_(GetConnectedBlobChannel()), weak_factory_(this) { 66 : blob_channel_(GetConnectedBlobChannel()), weak_factory_(this) {
66 blob_channel_->GetCachedBlobIds( 67 blob_channel_->GetCachedBlobIds(
67 base::Bind(&BlobChannelSenderProxy::OnGetCacheStateComplete, 68 base::Bind(&BlobChannelSenderProxy::OnGetCacheStateComplete,
68 weak_factory_.GetWeakPtr())); 69 weak_factory_.GetWeakPtr()));
(...skipping 17 matching lines...) Expand all
86 87
87 bool BlobChannelSenderProxy::IsInClientCache(const std::string& id) const { 88 bool BlobChannelSenderProxy::IsInClientCache(const std::string& id) const {
88 auto found = replication_state_.find(id); 89 auto found = replication_state_.find(id);
89 return found != replication_state_.end() && found->second; 90 return found != replication_state_.end() && found->second;
90 } 91 }
91 92
92 void BlobChannelSenderProxy::PutBlob(const BlobId& id, BlobDataPtr data) { 93 void BlobChannelSenderProxy::PutBlob(const BlobId& id, BlobDataPtr data) {
93 DCHECK(!IsInEngineCache(id)); 94 DCHECK(!IsInEngineCache(id));
94 95
95 size_t size = data->data.size(); 96 size_t size = data->data.size();
96 CHECK(!data->data.empty()) << "Zero length blob sent: " << BlobIdToString(id); 97 // Zero length blob sent.
98 CHECK(!data->data.empty());
97 99
98 replication_state_[id] = false; 100 replication_state_[id] = false;
99 std::unique_ptr<SharedMemoryBlob> shared_mem_blob( 101 std::unique_ptr<SharedMemoryBlob> shared_mem_blob(
100 new SharedMemoryBlob(std::move(data))); 102 new SharedMemoryBlob(std::move(data)));
101 blob_channel_->PutBlob(id, shared_mem_blob->CreateRemoteHandle(), size); 103 blob_channel_->PutBlob(id, shared_mem_blob->CreateRemoteHandle(), size);
102 } 104 }
103 105
104 void BlobChannelSenderProxy::DeliverBlob(const std::string& id) { 106 void BlobChannelSenderProxy::DeliverBlob(const std::string& id) {
105 DCHECK(IsInEngineCache(id)) << "Attempted to deliver an invalid blob: " 107 DCHECK(IsInEngineCache(id)) << "Attempted to deliver an invalid blob: "
106 << BlobIdToString(id); 108 << BlobIdToString(id);
(...skipping 19 matching lines...) Expand all
126 VLOG(1) << "Received cache state from browser (" << cache_state.size() 128 VLOG(1) << "Received cache state from browser (" << cache_state.size()
127 << " items)"; 129 << " items)";
128 replication_state_.clear(); 130 replication_state_.clear();
129 for (const auto& next_item : cache_state) { 131 for (const auto& next_item : cache_state) {
130 replication_state_[next_item.first] = next_item.second; 132 replication_state_[next_item.first] = next_item.second;
131 } 133 }
132 } 134 }
133 135
134 } // namespace engine 136 } // namespace engine
135 } // namespace blimp 137 } // namespace blimp
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698