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

Side by Side Diff: content/browser/blob_storage/blob_dispatcher_host.cc

Issue 2055053003: [BlobAsync] Disk support for blob storage (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Finished comments, added new pending enum state 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 #include "content/browser/blob_storage/blob_dispatcher_host.h" 5 #include "content/browser/blob_storage/blob_dispatcher_host.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 8
9 #include "base/bind.h" 9 #include "base/bind.h"
10 #include "base/metrics/histogram_macros.h" 10 #include "base/metrics/histogram_macros.h"
11 #include "content/browser/bad_message.h" 11 #include "content/browser/bad_message.h"
12 #include "content/browser/blob_storage/chrome_blob_storage_context.h" 12 #include "content/browser/blob_storage/chrome_blob_storage_context.h"
13 #include "content/common/fileapi/webblob_messages.h" 13 #include "content/common/fileapi/webblob_messages.h"
14 #include "ipc/ipc_platform_file.h" 14 #include "ipc/ipc_platform_file.h"
15 #include "storage/browser/blob/blob_data_handle.h"
15 #include "storage/browser/blob/blob_storage_context.h" 16 #include "storage/browser/blob/blob_storage_context.h"
16 #include "storage/browser/blob/blob_transport_result.h"
17 #include "storage/common/blob_storage/blob_item_bytes_request.h" 17 #include "storage/common/blob_storage/blob_item_bytes_request.h"
18 #include "storage/common/blob_storage/blob_item_bytes_response.h" 18 #include "storage/common/blob_storage/blob_item_bytes_response.h"
19 #include "storage/common/data_element.h" 19 #include "storage/common/data_element.h"
20 #include "url/gurl.h" 20 #include "url/gurl.h"
21 21
22 using storage::BlobStorageContext; 22 using storage::BlobStorageContext;
23 using storage::BlobStorageRegistry; 23 using storage::BlobStorageRegistry;
24 using storage::BlobTransportResult; 24 using storage::BlobStatus;
25 using storage::IPCBlobCreationCancelCode;
26 25
27 namespace content { 26 namespace content {
28 namespace { 27 namespace {
29 28
30 // These are used for UMA stats, don't change. 29 // These are used for UMA stats, don't change.
31 enum RefcountOperation { 30 enum RefcountOperation {
32 BDH_DECREMENT = 0, 31 BDH_DECREMENT = 0,
33 BDH_INCREMENT, 32 BDH_INCREMENT,
34 BDH_TRACING_ENUM_LAST 33 BDH_TRACING_ENUM_LAST
35 }; 34 };
(...skipping 11 matching lines...) Expand all
47 46
48 void BlobDispatcherHost::OnChannelClosing() { 47 void BlobDispatcherHost::OnChannelClosing() {
49 ClearHostFromBlobStorageContext(); 48 ClearHostFromBlobStorageContext();
50 public_blob_urls_.clear(); 49 public_blob_urls_.clear();
51 blobs_inuse_map_.clear(); 50 blobs_inuse_map_.clear();
52 } 51 }
53 52
54 bool BlobDispatcherHost::OnMessageReceived(const IPC::Message& message) { 53 bool BlobDispatcherHost::OnMessageReceived(const IPC::Message& message) {
55 bool handled = true; 54 bool handled = true;
56 IPC_BEGIN_MESSAGE_MAP(BlobDispatcherHost, message) 55 IPC_BEGIN_MESSAGE_MAP(BlobDispatcherHost, message)
57 IPC_MESSAGE_HANDLER(BlobStorageMsg_RegisterBlobUUID, OnRegisterBlobUUID) 56 IPC_MESSAGE_HANDLER(BlobStorageMsg_RegisterBlob, OnRegisterBlob)
58 IPC_MESSAGE_HANDLER(BlobStorageMsg_StartBuildingBlob, OnStartBuildingBlob)
59 IPC_MESSAGE_HANDLER(BlobStorageMsg_MemoryItemResponse, OnMemoryItemResponse) 57 IPC_MESSAGE_HANDLER(BlobStorageMsg_MemoryItemResponse, OnMemoryItemResponse)
60 IPC_MESSAGE_HANDLER(BlobStorageMsg_CancelBuildingBlob, OnCancelBuildingBlob) 58 IPC_MESSAGE_HANDLER(BlobStorageMsg_SendBlobStatus, OnCancelBuildingBob)
61 IPC_MESSAGE_HANDLER(BlobHostMsg_IncrementRefCount, OnIncrementBlobRefCount) 59 IPC_MESSAGE_HANDLER(BlobHostMsg_IncrementRefCount, OnIncrementBlobRefCount)
62 IPC_MESSAGE_HANDLER(BlobHostMsg_DecrementRefCount, OnDecrementBlobRefCount) 60 IPC_MESSAGE_HANDLER(BlobHostMsg_DecrementRefCount, OnDecrementBlobRefCount)
63 IPC_MESSAGE_HANDLER(BlobHostMsg_RegisterPublicURL, OnRegisterPublicBlobURL) 61 IPC_MESSAGE_HANDLER(BlobHostMsg_RegisterPublicURL, OnRegisterPublicBlobURL)
64 IPC_MESSAGE_HANDLER(BlobHostMsg_RevokePublicURL, OnRevokePublicBlobURL) 62 IPC_MESSAGE_HANDLER(BlobHostMsg_RevokePublicURL, OnRevokePublicBlobURL)
65 IPC_MESSAGE_UNHANDLED(handled = false) 63 IPC_MESSAGE_UNHANDLED(handled = false)
66 IPC_END_MESSAGE_MAP() 64 IPC_END_MESSAGE_MAP()
67 return handled; 65 return handled;
68 } 66 }
69 67
70 void BlobDispatcherHost::OnRegisterBlobUUID( 68 void BlobDispatcherHost::OnRegisterBlob(
71 const std::string& uuid, 69 const std::string& uuid,
72 const std::string& content_type, 70 const std::string& content_type,
73 const std::string& content_disposition, 71 const std::string& content_disposition,
74 const std::set<std::string>& referenced_blob_uuids) { 72 const std::vector<storage::DataElement>& descriptions) {
75 DCHECK_CURRENTLY_ON(BrowserThread::IO); 73 DCHECK_CURRENTLY_ON(BrowserThread::IO);
76 BlobStorageContext* context = this->context(); 74 BlobStorageContext* context = this->context();
77 if (uuid.empty() || context->registry().HasEntry(uuid) || 75 if (uuid.empty() || context->registry().HasEntry(uuid) ||
78 async_builder_.IsBeingBuilt(uuid)) { 76 async_builder_.IsBeingBuilt(uuid)) {
79 bad_message::ReceivedBadMessage(this, bad_message::BDH_UUID_REGISTERED); 77 bad_message::ReceivedBadMessage(this, bad_message::BDH_UUID_REGISTERED);
80 return; 78 return;
81 } 79 }
82 blobs_inuse_map_[uuid] = 1; 80 blobs_inuse_map_[uuid] = 1;
83 BlobTransportResult result = async_builder_.RegisterBlobUUID( 81 BlobStatus result = async_builder_.RegisterBlob(
84 uuid, content_type, content_disposition, referenced_blob_uuids, context); 82 uuid, content_type, content_disposition, descriptions, context,
85 switch (result) {
86 case BlobTransportResult::BAD_IPC:
87 blobs_inuse_map_.erase(uuid);
88 bad_message::ReceivedBadMessage(this,
89 bad_message::BDH_CONSTRUCTION_FAILED);
90 break;
91 case BlobTransportResult::CANCEL_REFERENCED_BLOB_BROKEN:
92 // The async builder builds the blob as broken, and we just need to send
93 // the cancel message back to the renderer.
94 Send(new BlobStorageMsg_CancelBuildingBlob(
95 uuid, IPCBlobCreationCancelCode::REFERENCED_BLOB_BROKEN));
96 break;
97 case BlobTransportResult::DONE:
98 break;
99 case BlobTransportResult::CANCEL_MEMORY_FULL:
100 case BlobTransportResult::CANCEL_FILE_ERROR:
101 case BlobTransportResult::CANCEL_UNKNOWN:
102 case BlobTransportResult::PENDING_RESPONSES:
103 NOTREACHED();
104 break;
105 }
106 }
107
108 void BlobDispatcherHost::OnStartBuildingBlob(
109 const std::string& uuid,
110 const std::vector<storage::DataElement>& descriptions) {
111 DCHECK_CURRENTLY_ON(BrowserThread::IO);
112 if (uuid.empty()) {
113 SendIPCResponse(uuid, BlobTransportResult::BAD_IPC);
114 return;
115 }
116 BlobStorageContext* context = this->context();
117 const BlobStorageRegistry::Entry* entry = context->registry().GetEntry(uuid);
118 if (!entry || entry->state == BlobStorageRegistry::BlobState::BROKEN) {
119 // We ignore messages for blobs that don't exist to handle the case where
120 // the renderer de-refs a blob that we're still constructing, and there are
121 // no references to that blob. We ignore broken as well, in the case where
122 // we decided to break a blob after RegisterBlobUUID is called.
123 // Second, if the last dereference of the blob happened on a different host,
124 // then we still haven't gotten rid of the 'building' state in the original
125 // host. So we call cancel, and send the message just in case that happens.
126 if (async_builder_.IsBeingBuilt(uuid)) {
127 async_builder_.CancelBuildingBlob(
128 uuid, IPCBlobCreationCancelCode::BLOB_DEREFERENCED_WHILE_BUILDING,
129 context);
130 Send(new BlobStorageMsg_CancelBuildingBlob(
131 uuid, IPCBlobCreationCancelCode::BLOB_DEREFERENCED_WHILE_BUILDING));
132 }
133 return;
134 }
135 if (!async_builder_.IsBeingBuilt(uuid)) {
136 SendIPCResponse(uuid, BlobTransportResult::BAD_IPC);
137 return;
138 }
139 // |this| owns async_builder_ so using base::Unretained(this) is safe.
140 BlobTransportResult result = async_builder_.StartBuildingBlob(
141 uuid, descriptions, context->memory_available(), context,
142 base::Bind(&BlobDispatcherHost::SendMemoryRequest, base::Unretained(this), 83 base::Bind(&BlobDispatcherHost::SendMemoryRequest, base::Unretained(this),
143 uuid)); 84 uuid),
144 SendIPCResponse(uuid, result); 85 base::Bind(&BlobDispatcherHost::MaybeSendFinalBlobStatus,
86 base::Unretained(this), uuid));
87 MaybeSendFinalBlobStatus(uuid, result);
145 } 88 }
146 89
147 void BlobDispatcherHost::OnMemoryItemResponse( 90 void BlobDispatcherHost::OnMemoryItemResponse(
148 const std::string& uuid, 91 const std::string& uuid,
149 const std::vector<storage::BlobItemBytesResponse>& responses) { 92 const std::vector<storage::BlobItemBytesResponse>& responses) {
150 DCHECK_CURRENTLY_ON(BrowserThread::IO); 93 DCHECK_CURRENTLY_ON(BrowserThread::IO);
151 if (uuid.empty()) { 94 if (uuid.empty()) {
152 SendIPCResponse(uuid, BlobTransportResult::BAD_IPC); 95 bad_message::ReceivedBadMessage(this, bad_message::BDH_CONSTRUCTION_FAILED);
153 return; 96 return;
154 } 97 }
155 BlobStorageContext* context = this->context(); 98 BlobStorageContext* context = this->context();
156 const BlobStorageRegistry::Entry* entry = context->registry().GetEntry(uuid); 99 const BlobStorageRegistry::Entry* entry = context->registry().GetEntry(uuid);
157 if (!entry || entry->state == BlobStorageRegistry::BlobState::BROKEN) { 100 if (!entry || BlobStatusIsError(entry->status)) {
158 // We ignore messages for blobs that don't exist to handle the case where 101 // We ignore messages for blobs that don't exist to handle the case where
159 // the renderer de-refs a blob that we're still constructing, and there are 102 // the renderer de-refs a blob that we're still constructing, and there are
160 // no references to that blob. We ignore broken as well, in the case where 103 // no references to that blob. We ignore broken as well, in the case where
161 // we decided to break a blob after sending the memory request. 104 // we decided to break a blob after sending the memory request.
162 // Note: if a blob is broken, then it can't be in the async_builder. 105 // Note: if a blob is broken, then it can't be in the async_builder.
163 // Second, if the last dereference of the blob happened on a different host, 106 // Second, if the last dereference of the blob happened on a different host,
164 // then we still haven't gotten rid of the 'building' state in the original 107 // then we still haven't gotten rid of the 'building' state in the original
165 // host. So we call cancel, and send the message just in case that happens. 108 // host. So we call cancel, and send the message just in case that happens.
166 if (async_builder_.IsBeingBuilt(uuid)) { 109 if (async_builder_.IsBeingBuilt(uuid)) {
167 async_builder_.CancelBuildingBlob( 110 async_builder_.CancelBuildingBlob(
168 uuid, IPCBlobCreationCancelCode::BLOB_DEREFERENCED_WHILE_BUILDING, 111 uuid, BlobStatus::BLOB_DEREFERENCED_WHILE_BUILDING, context);
169 context); 112 MaybeSendFinalBlobStatus(uuid,
170 Send(new BlobStorageMsg_CancelBuildingBlob( 113 BlobStatus::BLOB_DEREFERENCED_WHILE_BUILDING);
171 uuid, IPCBlobCreationCancelCode::BLOB_DEREFERENCED_WHILE_BUILDING));
172 } 114 }
173 return; 115 return;
174 } 116 }
175 if (!async_builder_.IsBeingBuilt(uuid)) { 117 if (!async_builder_.IsBeingBuilt(uuid)) {
176 SendIPCResponse(uuid, BlobTransportResult::BAD_IPC); 118 bad_message::ReceivedBadMessage(this, bad_message::BDH_CONSTRUCTION_FAILED);
177 return; 119 return;
178 } 120 }
179 BlobTransportResult result = 121 BlobStatus result =
180 async_builder_.OnMemoryResponses(uuid, responses, context); 122 async_builder_.OnMemoryResponses(uuid, responses, context);
181 SendIPCResponse(uuid, result); 123 MaybeSendFinalBlobStatus(uuid, result);
182 } 124 }
183 125
184 void BlobDispatcherHost::OnCancelBuildingBlob( 126 void BlobDispatcherHost::OnCancelBuildingBob(const std::string& uuid,
185 const std::string& uuid, 127 const storage::BlobStatus code) {
186 const storage::IPCBlobCreationCancelCode code) {
187 DCHECK_CURRENTLY_ON(BrowserThread::IO); 128 DCHECK_CURRENTLY_ON(BrowserThread::IO);
188 if (uuid.empty()) { 129 if (uuid.empty()) {
189 SendIPCResponse(uuid, BlobTransportResult::BAD_IPC); 130 bad_message::ReceivedBadMessage(this, bad_message::BDH_CONSTRUCTION_FAILED);
190 return; 131 return;
191 } 132 }
192 BlobStorageContext* context = this->context(); 133 BlobStorageContext* context = this->context();
193 const BlobStorageRegistry::Entry* entry = context->registry().GetEntry(uuid); 134 const BlobStorageRegistry::Entry* entry = context->registry().GetEntry(uuid);
194 if (!entry || entry->state == BlobStorageRegistry::BlobState::BROKEN) { 135 if (!entry || BlobStatusIsError(entry->status)) {
195 // We ignore messages for blobs that don't exist to handle the case where 136 // We ignore messages for blobs that don't exist to handle the case where
196 // the renderer de-refs a blob that we're still constructing, and there are 137 // the renderer de-refs a blob that we're still constructing, and there are
197 // no references to that blob. We ignore broken as well, in the case where 138 // no references to that blob. We ignore broken as well, in the case where
198 // we decided to break a blob and the renderer also decided to cancel. 139 // we decided to break a blob and the renderer also decided to cancel.
199 // Note: if a blob is broken, then it can't be in the async_builder. 140 // Note: if a blob is broken, then it can't be in the async_builder.
200 // Second, if the last dereference of the blob happened on a different host, 141 // Second, if the last dereference of the blob happened on a different host,
201 // then we still haven't gotten rid of the 'building' state in the original 142 // then we still haven't gotten rid of the 'building' state in the original
202 // host. So we call cancel just in case this happens. 143 // host. So we call cancel just in case this happens.
203 if (async_builder_.IsBeingBuilt(uuid)) { 144 if (async_builder_.IsBeingBuilt(uuid)) {
204 async_builder_.CancelBuildingBlob( 145 async_builder_.CancelBuildingBlob(
205 uuid, IPCBlobCreationCancelCode::BLOB_DEREFERENCED_WHILE_BUILDING, 146 uuid, BlobStatus::BLOB_DEREFERENCED_WHILE_BUILDING, context);
206 context);
207 } 147 }
208 return; 148 return;
209 } 149 }
210 if (!async_builder_.IsBeingBuilt(uuid)) { 150 // We should only get these messages for errors.
211 SendIPCResponse(uuid, BlobTransportResult::BAD_IPC); 151 if (!async_builder_.IsBeingBuilt(uuid) || !storage::BlobStatusIsError(code)) {
152 bad_message::ReceivedBadMessage(this, bad_message::BDH_CONSTRUCTION_FAILED);
212 return; 153 return;
213 } 154 }
214 VLOG(1) << "Blob construction of " << uuid << " cancelled by renderer. " 155 VLOG(1) << "Blob construction of " << uuid << " cancelled by renderer. "
215 << " Reason: " << static_cast<int>(code) << "."; 156 << " Reason: " << static_cast<int>(code) << ".";
216 async_builder_.CancelBuildingBlob(uuid, code, context); 157 async_builder_.CancelBuildingBlob(uuid, code, context);
217 } 158 }
218 159
219 void BlobDispatcherHost::OnIncrementBlobRefCount(const std::string& uuid) { 160 void BlobDispatcherHost::OnIncrementBlobRefCount(const std::string& uuid) {
220 DCHECK_CURRENTLY_ON(BrowserThread::IO); 161 DCHECK_CURRENTLY_ON(BrowserThread::IO);
221 BlobStorageContext* context = this->context(); 162 BlobStorageContext* context = this->context();
(...skipping 27 matching lines...) Expand all
249 context->DecrementBlobRefCount(uuid); 190 context->DecrementBlobRefCount(uuid);
250 blobs_inuse_map_[uuid] -= 1; 191 blobs_inuse_map_[uuid] -= 1;
251 if (blobs_inuse_map_[uuid] == 0) { 192 if (blobs_inuse_map_[uuid] == 0) {
252 blobs_inuse_map_.erase(uuid); 193 blobs_inuse_map_.erase(uuid);
253 // If the blob has been deleted in the context and we're still building it, 194 // If the blob has been deleted in the context and we're still building it,
254 // this means we have no references waiting to read it. Clear the building 195 // this means we have no references waiting to read it. Clear the building
255 // state and send a cancel message to the renderer. 196 // state and send a cancel message to the renderer.
256 if (async_builder_.IsBeingBuilt(uuid) && 197 if (async_builder_.IsBeingBuilt(uuid) &&
257 !context->registry().HasEntry(uuid)) { 198 !context->registry().HasEntry(uuid)) {
258 async_builder_.CancelBuildingBlob( 199 async_builder_.CancelBuildingBlob(
259 uuid, IPCBlobCreationCancelCode::BLOB_DEREFERENCED_WHILE_BUILDING, 200 uuid, BlobStatus::BLOB_DEREFERENCED_WHILE_BUILDING, context);
260 context); 201 MaybeSendFinalBlobStatus(uuid,
261 Send(new BlobStorageMsg_CancelBuildingBlob( 202 BlobStatus::BLOB_DEREFERENCED_WHILE_BUILDING);
262 uuid, IPCBlobCreationCancelCode::BLOB_DEREFERENCED_WHILE_BUILDING));
263 } 203 }
264 } 204 }
265 } 205 }
266 206
267 void BlobDispatcherHost::OnRegisterPublicBlobURL(const GURL& public_url, 207 void BlobDispatcherHost::OnRegisterPublicBlobURL(const GURL& public_url,
268 const std::string& uuid) { 208 const std::string& uuid) {
269 DCHECK_CURRENTLY_ON(BrowserThread::IO); 209 DCHECK_CURRENTLY_ON(BrowserThread::IO);
270 BlobStorageContext* context = this->context(); 210 BlobStorageContext* context = this->context();
271 if (uuid.empty()) { 211 if (uuid.empty()) {
272 bad_message::ReceivedBadMessage(this, 212 bad_message::ReceivedBadMessage(this,
(...skipping 29 matching lines...) Expand all
302 return blob_storage_context_->context(); 242 return blob_storage_context_->context();
303 } 243 }
304 244
305 void BlobDispatcherHost::SendMemoryRequest( 245 void BlobDispatcherHost::SendMemoryRequest(
306 const std::string& uuid, 246 const std::string& uuid,
307 std::unique_ptr<std::vector<storage::BlobItemBytesRequest>> requests, 247 std::unique_ptr<std::vector<storage::BlobItemBytesRequest>> requests,
308 std::unique_ptr<std::vector<base::SharedMemoryHandle>> memory_handles, 248 std::unique_ptr<std::vector<base::SharedMemoryHandle>> memory_handles,
309 std::unique_ptr<std::vector<base::File>> files) { 249 std::unique_ptr<std::vector<base::File>> files) {
310 DCHECK_CURRENTLY_ON(BrowserThread::IO); 250 DCHECK_CURRENTLY_ON(BrowserThread::IO);
311 std::vector<IPC::PlatformFileForTransit> file_handles; 251 std::vector<IPC::PlatformFileForTransit> file_handles;
312 // TODO(dmurph): Support file-backed blob transportation. 252 for (base::File& file : *files) {
313 DCHECK(files->empty()); 253 file_handles.push_back(IPC::TakePlatformFileForTransit(std::move(file)));
254 }
314 Send(new BlobStorageMsg_RequestMemoryItem(uuid, *requests, *memory_handles, 255 Send(new BlobStorageMsg_RequestMemoryItem(uuid, *requests, *memory_handles,
315 file_handles)); 256 file_handles));
316 } 257 }
317 258
318 void BlobDispatcherHost::SendIPCResponse(const std::string& uuid, 259 void BlobDispatcherHost::MaybeSendFinalBlobStatus(const std::string& uuid,
319 storage::BlobTransportResult result) { 260 BlobStatus status) {
320 switch (result) { 261 if (storage::BlobStatusIsBadIPC(status)) {
321 case BlobTransportResult::BAD_IPC: 262 blobs_inuse_map_.erase(uuid);
322 bad_message::ReceivedBadMessage(this, 263 bad_message::ReceivedBadMessage(this, bad_message::BDH_CONSTRUCTION_FAILED);
323 bad_message::BDH_CONSTRUCTION_FAILED); 264 return;
324 return;
325 case BlobTransportResult::CANCEL_MEMORY_FULL:
326 Send(new BlobStorageMsg_CancelBuildingBlob(
327 uuid, IPCBlobCreationCancelCode::OUT_OF_MEMORY));
328 return;
329 case BlobTransportResult::CANCEL_FILE_ERROR:
330 Send(new BlobStorageMsg_CancelBuildingBlob(
331 uuid, IPCBlobCreationCancelCode::FILE_WRITE_FAILED));
332 return;
333 case BlobTransportResult::CANCEL_REFERENCED_BLOB_BROKEN:
334 Send(new BlobStorageMsg_CancelBuildingBlob(
335 uuid, IPCBlobCreationCancelCode::REFERENCED_BLOB_BROKEN));
336 return;
337 case BlobTransportResult::CANCEL_UNKNOWN:
338 Send(new BlobStorageMsg_CancelBuildingBlob(
339 uuid, IPCBlobCreationCancelCode::UNKNOWN));
340 return;
341 case BlobTransportResult::PENDING_RESPONSES:
342 return;
343 case BlobTransportResult::DONE:
344 Send(new BlobStorageMsg_DoneBuildingBlob(uuid));
345 return;
346 } 265 }
347 NOTREACHED(); 266 if (BlobStatusIsPending(status))
267 return;
268 Send(new BlobStorageMsg_SendBlobStatus(uuid, status));
348 } 269 }
349 270
350 bool BlobDispatcherHost::IsInUseInHost(const std::string& uuid) { 271 bool BlobDispatcherHost::IsInUseInHost(const std::string& uuid) {
351 return blobs_inuse_map_.find(uuid) != blobs_inuse_map_.end(); 272 return blobs_inuse_map_.find(uuid) != blobs_inuse_map_.end();
352 } 273 }
353 274
354 bool BlobDispatcherHost::IsUrlRegisteredInHost(const GURL& blob_url) { 275 bool BlobDispatcherHost::IsUrlRegisteredInHost(const GURL& blob_url) {
355 return public_blob_urls_.find(blob_url) != public_blob_urls_.end(); 276 return public_blob_urls_.find(blob_url) != public_blob_urls_.end();
356 } 277 }
357 278
358 void BlobDispatcherHost::ClearHostFromBlobStorageContext() { 279 void BlobDispatcherHost::ClearHostFromBlobStorageContext() {
359 BlobStorageContext* context = this->context(); 280 BlobStorageContext* context = this->context();
360 for (const auto& url : public_blob_urls_) { 281 for (const auto& url : public_blob_urls_) {
361 context->RevokePublicBlobURL(url); 282 context->RevokePublicBlobURL(url);
362 } 283 }
363 for (const auto& uuid_refnum_pair : blobs_inuse_map_) { 284 for (const auto& uuid_refnum_pair : blobs_inuse_map_) {
364 for (int i = 0; i < uuid_refnum_pair.second; ++i) 285 for (int i = 0; i < uuid_refnum_pair.second; ++i)
365 context->DecrementBlobRefCount(uuid_refnum_pair.first); 286 context->DecrementBlobRefCount(uuid_refnum_pair.first);
366 } 287 }
367 async_builder_.CancelAll(context); 288 async_builder_.CancelAll(context);
368 } 289 }
369 290
370 } // namespace content 291 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698