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

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: comments 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, OnBlobStatus)
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),
84 uuid),
85 base::Bind(&BlobDispatcherHost::SendBlobStatus, base::Unretained(this),
143 uuid)); 86 uuid));
144 SendIPCResponse(uuid, result); 87 SendBlobStatus(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 SendBlobStatus(uuid, BlobStatus::BLOB_DEREFERENCED_WHILE_BUILDING);
170 Send(new BlobStorageMsg_CancelBuildingBlob(
171 uuid, IPCBlobCreationCancelCode::BLOB_DEREFERENCED_WHILE_BUILDING));
172 } 113 }
173 return; 114 return;
174 } 115 }
175 if (!async_builder_.IsBeingBuilt(uuid)) { 116 if (!async_builder_.IsBeingBuilt(uuid)) {
176 SendIPCResponse(uuid, BlobTransportResult::BAD_IPC); 117 bad_message::ReceivedBadMessage(this, bad_message::BDH_CONSTRUCTION_FAILED);
177 return; 118 return;
178 } 119 }
179 BlobTransportResult result = 120 BlobStatus result =
180 async_builder_.OnMemoryResponses(uuid, responses, context); 121 async_builder_.OnMemoryResponses(uuid, responses, context);
181 SendIPCResponse(uuid, result); 122 SendBlobStatus(uuid, result);
182 } 123 }
183 124
184 void BlobDispatcherHost::OnCancelBuildingBlob( 125 void BlobDispatcherHost::OnBlobStatus(const std::string& uuid,
185 const std::string& uuid, 126 const storage::BlobStatus code) {
186 const storage::IPCBlobCreationCancelCode code) {
187 DCHECK_CURRENTLY_ON(BrowserThread::IO); 127 DCHECK_CURRENTLY_ON(BrowserThread::IO);
188 if (uuid.empty()) { 128 if (uuid.empty()) {
189 SendIPCResponse(uuid, BlobTransportResult::BAD_IPC); 129 bad_message::ReceivedBadMessage(this, bad_message::BDH_CONSTRUCTION_FAILED);
190 return; 130 return;
191 } 131 }
192 BlobStorageContext* context = this->context(); 132 BlobStorageContext* context = this->context();
193 const BlobStorageRegistry::Entry* entry = context->registry().GetEntry(uuid); 133 const BlobStorageRegistry::Entry* entry = context->registry().GetEntry(uuid);
194 if (!entry || entry->state == BlobStorageRegistry::BlobState::BROKEN) { 134 if (!entry || BlobStatusIsError(entry->status)) {
195 // We ignore messages for blobs that don't exist to handle the case where 135 // 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 136 // 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 137 // 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. 138 // 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. 139 // 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, 140 // 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 141 // 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. 142 // host. So we call cancel just in case this happens.
203 if (async_builder_.IsBeingBuilt(uuid)) { 143 if (async_builder_.IsBeingBuilt(uuid)) {
204 async_builder_.CancelBuildingBlob( 144 async_builder_.CancelBuildingBlob(
205 uuid, IPCBlobCreationCancelCode::BLOB_DEREFERENCED_WHILE_BUILDING, 145 uuid, BlobStatus::BLOB_DEREFERENCED_WHILE_BUILDING, context);
206 context);
207 } 146 }
208 return; 147 return;
209 } 148 }
210 if (!async_builder_.IsBeingBuilt(uuid)) { 149 // We should only get these messages for errors.
michaeln 2016/07/14 01:44:42 I see you're using the same generic status MSG for
dmurph 2016/07/15 02:45:27 Done.
211 SendIPCResponse(uuid, BlobTransportResult::BAD_IPC); 150 if (!async_builder_.IsBeingBuilt(uuid) || !storage::BlobStatusIsError(code)) {
151 bad_message::ReceivedBadMessage(this, bad_message::BDH_CONSTRUCTION_FAILED);
212 return; 152 return;
213 } 153 }
214 VLOG(1) << "Blob construction of " << uuid << " cancelled by renderer. " 154 VLOG(1) << "Blob construction of " << uuid << " cancelled by renderer. "
215 << " Reason: " << static_cast<int>(code) << "."; 155 << " Reason: " << static_cast<int>(code) << ".";
216 async_builder_.CancelBuildingBlob(uuid, code, context); 156 async_builder_.CancelBuildingBlob(uuid, code, context);
217 } 157 }
218 158
219 void BlobDispatcherHost::OnIncrementBlobRefCount(const std::string& uuid) { 159 void BlobDispatcherHost::OnIncrementBlobRefCount(const std::string& uuid) {
220 DCHECK_CURRENTLY_ON(BrowserThread::IO); 160 DCHECK_CURRENTLY_ON(BrowserThread::IO);
221 BlobStorageContext* context = this->context(); 161 BlobStorageContext* context = this->context();
(...skipping 27 matching lines...) Expand all
249 context->DecrementBlobRefCount(uuid); 189 context->DecrementBlobRefCount(uuid);
250 blobs_inuse_map_[uuid] -= 1; 190 blobs_inuse_map_[uuid] -= 1;
251 if (blobs_inuse_map_[uuid] == 0) { 191 if (blobs_inuse_map_[uuid] == 0) {
252 blobs_inuse_map_.erase(uuid); 192 blobs_inuse_map_.erase(uuid);
253 // If the blob has been deleted in the context and we're still building it, 193 // 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 194 // this means we have no references waiting to read it. Clear the building
255 // state and send a cancel message to the renderer. 195 // state and send a cancel message to the renderer.
256 if (async_builder_.IsBeingBuilt(uuid) && 196 if (async_builder_.IsBeingBuilt(uuid) &&
257 !context->registry().HasEntry(uuid)) { 197 !context->registry().HasEntry(uuid)) {
258 async_builder_.CancelBuildingBlob( 198 async_builder_.CancelBuildingBlob(
259 uuid, IPCBlobCreationCancelCode::BLOB_DEREFERENCED_WHILE_BUILDING, 199 uuid, BlobStatus::BLOB_DEREFERENCED_WHILE_BUILDING, context);
260 context); 200 SendBlobStatus(uuid, BlobStatus::BLOB_DEREFERENCED_WHILE_BUILDING);
261 Send(new BlobStorageMsg_CancelBuildingBlob(
262 uuid, IPCBlobCreationCancelCode::BLOB_DEREFERENCED_WHILE_BUILDING));
263 } 201 }
264 } 202 }
265 } 203 }
266 204
267 void BlobDispatcherHost::OnRegisterPublicBlobURL(const GURL& public_url, 205 void BlobDispatcherHost::OnRegisterPublicBlobURL(const GURL& public_url,
268 const std::string& uuid) { 206 const std::string& uuid) {
269 DCHECK_CURRENTLY_ON(BrowserThread::IO); 207 DCHECK_CURRENTLY_ON(BrowserThread::IO);
270 BlobStorageContext* context = this->context(); 208 BlobStorageContext* context = this->context();
271 if (uuid.empty()) { 209 if (uuid.empty()) {
272 bad_message::ReceivedBadMessage(this, 210 bad_message::ReceivedBadMessage(this,
(...skipping 29 matching lines...) Expand all
302 return blob_storage_context_->context(); 240 return blob_storage_context_->context();
303 } 241 }
304 242
305 void BlobDispatcherHost::SendMemoryRequest( 243 void BlobDispatcherHost::SendMemoryRequest(
306 const std::string& uuid, 244 const std::string& uuid,
307 std::unique_ptr<std::vector<storage::BlobItemBytesRequest>> requests, 245 std::unique_ptr<std::vector<storage::BlobItemBytesRequest>> requests,
308 std::unique_ptr<std::vector<base::SharedMemoryHandle>> memory_handles, 246 std::unique_ptr<std::vector<base::SharedMemoryHandle>> memory_handles,
309 std::unique_ptr<std::vector<base::File>> files) { 247 std::unique_ptr<std::vector<base::File>> files) {
310 DCHECK_CURRENTLY_ON(BrowserThread::IO); 248 DCHECK_CURRENTLY_ON(BrowserThread::IO);
311 std::vector<IPC::PlatformFileForTransit> file_handles; 249 std::vector<IPC::PlatformFileForTransit> file_handles;
312 // TODO(dmurph): Support file-backed blob transportation. 250 for (base::File& file : *files) {
313 DCHECK(files->empty()); 251 file_handles.push_back(IPC::TakePlatformFileForTransit(std::move(file)));
252 }
314 Send(new BlobStorageMsg_RequestMemoryItem(uuid, *requests, *memory_handles, 253 Send(new BlobStorageMsg_RequestMemoryItem(uuid, *requests, *memory_handles,
315 file_handles)); 254 file_handles));
316 } 255 }
317 256
318 void BlobDispatcherHost::SendIPCResponse(const std::string& uuid, 257 void BlobDispatcherHost::SendBlobStatus(const std::string& uuid,
319 storage::BlobTransportResult result) { 258 BlobStatus status) {
320 switch (result) { 259 if (storage::BlobStatusIsBadIPC(status)) {
321 case BlobTransportResult::BAD_IPC: 260 blobs_inuse_map_.erase(uuid);
322 bad_message::ReceivedBadMessage(this, 261 bad_message::ReceivedBadMessage(this, bad_message::BDH_CONSTRUCTION_FAILED);
323 bad_message::BDH_CONSTRUCTION_FAILED); 262 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 } 263 }
347 NOTREACHED(); 264 if (status == BlobStatus::PENDING) {
265 return;
266 }
267 Send(new BlobStorageMsg_SendBlobStatus(uuid, status));
348 } 268 }
349 269
350 bool BlobDispatcherHost::IsInUseInHost(const std::string& uuid) { 270 bool BlobDispatcherHost::IsInUseInHost(const std::string& uuid) {
351 return blobs_inuse_map_.find(uuid) != blobs_inuse_map_.end(); 271 return blobs_inuse_map_.find(uuid) != blobs_inuse_map_.end();
352 } 272 }
353 273
354 bool BlobDispatcherHost::IsUrlRegisteredInHost(const GURL& blob_url) { 274 bool BlobDispatcherHost::IsUrlRegisteredInHost(const GURL& blob_url) {
355 return public_blob_urls_.find(blob_url) != public_blob_urls_.end(); 275 return public_blob_urls_.find(blob_url) != public_blob_urls_.end();
356 } 276 }
357 277
358 void BlobDispatcherHost::ClearHostFromBlobStorageContext() { 278 void BlobDispatcherHost::ClearHostFromBlobStorageContext() {
359 BlobStorageContext* context = this->context(); 279 BlobStorageContext* context = this->context();
360 for (const auto& url : public_blob_urls_) { 280 for (const auto& url : public_blob_urls_) {
361 context->RevokePublicBlobURL(url); 281 context->RevokePublicBlobURL(url);
362 } 282 }
363 for (const auto& uuid_refnum_pair : blobs_inuse_map_) { 283 for (const auto& uuid_refnum_pair : blobs_inuse_map_) {
364 for (int i = 0; i < uuid_refnum_pair.second; ++i) 284 for (int i = 0; i < uuid_refnum_pair.second; ++i)
365 context->DecrementBlobRefCount(uuid_refnum_pair.first); 285 context->DecrementBlobRefCount(uuid_refnum_pair.first);
366 } 286 }
367 async_builder_.CancelAll(context); 287 async_builder_.CancelAll(context);
368 } 288 }
369 289
370 } // namespace content 290 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698