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

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

Issue 1893293006: [Blob] Added error reporting metrics to invalid message errors. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: added spaces Created 4 years, 8 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
« no previous file with comments | « no previous file | tools/metrics/histograms/histograms.xml » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 "content/browser/bad_message.h" 11 #include "content/browser/bad_message.h"
11 #include "content/browser/fileapi/chrome_blob_storage_context.h" 12 #include "content/browser/fileapi/chrome_blob_storage_context.h"
12 #include "content/common/fileapi/webblob_messages.h" 13 #include "content/common/fileapi/webblob_messages.h"
13 #include "ipc/ipc_platform_file.h" 14 #include "ipc/ipc_platform_file.h"
14 #include "storage/browser/blob/blob_storage_context.h" 15 #include "storage/browser/blob/blob_storage_context.h"
15 #include "storage/browser/blob/blob_transport_result.h" 16 #include "storage/browser/blob/blob_transport_result.h"
16 #include "storage/common/blob_storage/blob_item_bytes_request.h" 17 #include "storage/common/blob_storage/blob_item_bytes_request.h"
17 #include "storage/common/blob_storage/blob_item_bytes_response.h" 18 #include "storage/common/blob_storage/blob_item_bytes_response.h"
18 #include "storage/common/data_element.h" 19 #include "storage/common/data_element.h"
19 #include "url/gurl.h" 20 #include "url/gurl.h"
20 21
21 using storage::BlobStorageContext; 22 using storage::BlobStorageContext;
22 using storage::BlobStorageRegistry; 23 using storage::BlobStorageRegistry;
23 using storage::BlobTransportResult; 24 using storage::BlobTransportResult;
24 using storage::IPCBlobCreationCancelCode; 25 using storage::IPCBlobCreationCancelCode;
25 26
26 namespace content { 27 namespace content {
28 namespace {
29
30 // These are used for UMA stats, don't change.
31 enum RefcountOperation {
32 BDH_DECREMENT = 0,
33 BDH_INCREMENT,
34 BDH_TRACING_ENUM_LAST
35 };
36
37 } // namespace
27 38
28 BlobDispatcherHost::BlobDispatcherHost( 39 BlobDispatcherHost::BlobDispatcherHost(
29 ChromeBlobStorageContext* blob_storage_context) 40 ChromeBlobStorageContext* blob_storage_context)
30 : BrowserMessageFilter(BlobMsgStart), 41 : BrowserMessageFilter(BlobMsgStart),
31 blob_storage_context_(blob_storage_context) {} 42 blob_storage_context_(blob_storage_context) {}
32 43
33 BlobDispatcherHost::~BlobDispatcherHost() { 44 BlobDispatcherHost::~BlobDispatcherHost() {
34 ClearHostFromBlobStorageContext(); 45 ClearHostFromBlobStorageContext();
35 } 46 }
36 47
(...skipping 165 matching lines...) Expand 10 before | Expand all | Expand 10 after
202 } 213 }
203 VLOG(1) << "Blob construction of " << uuid << " cancelled by renderer. " 214 VLOG(1) << "Blob construction of " << uuid << " cancelled by renderer. "
204 << " Reason: " << static_cast<int>(code) << "."; 215 << " Reason: " << static_cast<int>(code) << ".";
205 async_builder_.CancelBuildingBlob(uuid, code, context); 216 async_builder_.CancelBuildingBlob(uuid, code, context);
206 } 217 }
207 218
208 void BlobDispatcherHost::OnIncrementBlobRefCount(const std::string& uuid) { 219 void BlobDispatcherHost::OnIncrementBlobRefCount(const std::string& uuid) {
209 DCHECK_CURRENTLY_ON(BrowserThread::IO); 220 DCHECK_CURRENTLY_ON(BrowserThread::IO);
210 BlobStorageContext* context = this->context(); 221 BlobStorageContext* context = this->context();
211 if (uuid.empty() || !context->registry().HasEntry(uuid)) { 222 if (uuid.empty() || !context->registry().HasEntry(uuid)) {
223 UMA_HISTOGRAM_ENUMERATION("Storage.Blob.InvalidReference", BDH_INCREMENT,
224 BDH_TRACING_ENUM_LAST);
212 bad_message::ReceivedBadMessage( 225 bad_message::ReceivedBadMessage(
213 this, bad_message::BDH_INVALID_REFCOUNT_OPERATION); 226 this, bad_message::BDH_INVALID_REFCOUNT_OPERATION);
214 return; 227 return;
215 } 228 }
216 context->IncrementBlobRefCount(uuid); 229 context->IncrementBlobRefCount(uuid);
217 blobs_inuse_map_[uuid] += 1; 230 blobs_inuse_map_[uuid] += 1;
218 } 231 }
219 232
220 void BlobDispatcherHost::OnDecrementBlobRefCount(const std::string& uuid) { 233 void BlobDispatcherHost::OnDecrementBlobRefCount(const std::string& uuid) {
221 DCHECK_CURRENTLY_ON(BrowserThread::IO); 234 DCHECK_CURRENTLY_ON(BrowserThread::IO);
222 if (uuid.empty() || !IsInUseInHost(uuid)) { 235 if (uuid.empty() || !IsInUseInHost(uuid)) {
236 UMA_HISTOGRAM_ENUMERATION("Storage.Blob.InvalidReference", BDH_DECREMENT,
237 BDH_TRACING_ENUM_LAST);
223 bad_message::ReceivedBadMessage( 238 bad_message::ReceivedBadMessage(
224 this, bad_message::BDH_INVALID_REFCOUNT_OPERATION); 239 this, bad_message::BDH_INVALID_REFCOUNT_OPERATION);
225 return; 240 return;
226 } 241 }
227 BlobStorageContext* context = this->context(); 242 BlobStorageContext* context = this->context();
228 context->DecrementBlobRefCount(uuid); 243 context->DecrementBlobRefCount(uuid);
229 blobs_inuse_map_[uuid] -= 1; 244 blobs_inuse_map_[uuid] -= 1;
230 if (blobs_inuse_map_[uuid] == 0) { 245 if (blobs_inuse_map_[uuid] == 0) {
231 blobs_inuse_map_.erase(uuid); 246 blobs_inuse_map_.erase(uuid);
232 // If the blob has been deleted in the context and we're still building it, 247 // If the blob has been deleted in the context and we're still building it,
233 // this means we have no references waiting to read it. Clear the building 248 // this means we have no references waiting to read it. Clear the building
234 // state and send a cancel message to the renderer. 249 // state and send a cancel message to the renderer.
235 if (async_builder_.IsBeingBuilt(uuid) && 250 if (async_builder_.IsBeingBuilt(uuid) &&
236 !context->registry().HasEntry(uuid)) { 251 !context->registry().HasEntry(uuid)) {
237 async_builder_.CancelBuildingBlob( 252 async_builder_.CancelBuildingBlob(
238 uuid, IPCBlobCreationCancelCode::BLOB_DEREFERENCED_WHILE_BUILDING, 253 uuid, IPCBlobCreationCancelCode::BLOB_DEREFERENCED_WHILE_BUILDING,
239 context); 254 context);
240 Send(new BlobStorageMsg_CancelBuildingBlob( 255 Send(new BlobStorageMsg_CancelBuildingBlob(
241 uuid, IPCBlobCreationCancelCode::BLOB_DEREFERENCED_WHILE_BUILDING)); 256 uuid, IPCBlobCreationCancelCode::BLOB_DEREFERENCED_WHILE_BUILDING));
242 } 257 }
243 } 258 }
244 } 259 }
245 260
246 void BlobDispatcherHost::OnRegisterPublicBlobURL(const GURL& public_url, 261 void BlobDispatcherHost::OnRegisterPublicBlobURL(const GURL& public_url,
247 const std::string& uuid) { 262 const std::string& uuid) {
248 DCHECK_CURRENTLY_ON(BrowserThread::IO); 263 DCHECK_CURRENTLY_ON(BrowserThread::IO);
249 BlobStorageContext* context = this->context(); 264 BlobStorageContext* context = this->context();
250 if (uuid.empty() || !IsInUseInHost(uuid) || 265 if (uuid.empty() || !IsInUseInHost(uuid) ||
251 context->registry().IsURLMapped(public_url)) { 266 context->registry().IsURLMapped(public_url)) {
267 UMA_HISTOGRAM_ENUMERATION("Storage.Blob.InvalidURLRegister", BDH_INCREMENT,
268 BDH_TRACING_ENUM_LAST);
252 bad_message::ReceivedBadMessage(this, 269 bad_message::ReceivedBadMessage(this,
253 bad_message::BDH_INVALID_URL_OPERATION); 270 bad_message::BDH_INVALID_URL_OPERATION);
254 return; 271 return;
255 } 272 }
256 context->RegisterPublicBlobURL(public_url, uuid); 273 context->RegisterPublicBlobURL(public_url, uuid);
257 public_blob_urls_.insert(public_url); 274 public_blob_urls_.insert(public_url);
258 } 275 }
259 276
260 void BlobDispatcherHost::OnRevokePublicBlobURL(const GURL& public_url) { 277 void BlobDispatcherHost::OnRevokePublicBlobURL(const GURL& public_url) {
261 DCHECK_CURRENTLY_ON(BrowserThread::IO); 278 DCHECK_CURRENTLY_ON(BrowserThread::IO);
262 if (!IsUrlRegisteredInHost(public_url)) { 279 if (!IsUrlRegisteredInHost(public_url)) {
280 UMA_HISTOGRAM_ENUMERATION("Storage.Blob.InvalidURLRegister", BDH_DECREMENT,
281 BDH_TRACING_ENUM_LAST);
263 bad_message::ReceivedBadMessage(this, 282 bad_message::ReceivedBadMessage(this,
264 bad_message::BDH_INVALID_URL_OPERATION); 283 bad_message::BDH_INVALID_URL_OPERATION);
265 return; 284 return;
266 } 285 }
267 context()->RevokePublicBlobURL(public_url); 286 context()->RevokePublicBlobURL(public_url);
268 public_blob_urls_.erase(public_url); 287 public_blob_urls_.erase(public_url);
269 } 288 }
270 289
271 storage::BlobStorageContext* BlobDispatcherHost::context() { 290 storage::BlobStorageContext* BlobDispatcherHost::context() {
272 return blob_storage_context_->context(); 291 return blob_storage_context_->context();
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after
331 context->RevokePublicBlobURL(url); 350 context->RevokePublicBlobURL(url);
332 } 351 }
333 for (const auto& uuid_refnum_pair : blobs_inuse_map_) { 352 for (const auto& uuid_refnum_pair : blobs_inuse_map_) {
334 for (int i = 0; i < uuid_refnum_pair.second; ++i) 353 for (int i = 0; i < uuid_refnum_pair.second; ++i)
335 context->DecrementBlobRefCount(uuid_refnum_pair.first); 354 context->DecrementBlobRefCount(uuid_refnum_pair.first);
336 } 355 }
337 async_builder_.CancelAll(context); 356 async_builder_.CancelAll(context);
338 } 357 }
339 358
340 } // namespace content 359 } // namespace content
OLDNEW
« no previous file with comments | « no previous file | tools/metrics/histograms/histograms.xml » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698