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

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: 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.h"
Mark P 2016/04/19 19:34:52 Prefer 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"
(...skipping 182 matching lines...) Expand 10 before | Expand all | Expand 10 after
202 } 203 }
203 VLOG(1) << "Blob construction of " << uuid << " cancelled by renderer. " 204 VLOG(1) << "Blob construction of " << uuid << " cancelled by renderer. "
204 << " Reason: " << static_cast<int>(code) << "."; 205 << " Reason: " << static_cast<int>(code) << ".";
205 async_builder_.CancelBuildingBlob(uuid, code, context); 206 async_builder_.CancelBuildingBlob(uuid, code, context);
206 } 207 }
207 208
208 void BlobDispatcherHost::OnIncrementBlobRefCount(const std::string& uuid) { 209 void BlobDispatcherHost::OnIncrementBlobRefCount(const std::string& uuid) {
209 DCHECK_CURRENTLY_ON(BrowserThread::IO); 210 DCHECK_CURRENTLY_ON(BrowserThread::IO);
210 BlobStorageContext* context = this->context(); 211 BlobStorageContext* context = this->context();
211 if (uuid.empty() || !context->registry().HasEntry(uuid)) { 212 if (uuid.empty() || !context->registry().HasEntry(uuid)) {
213 UMA_HISTOGRAM_BOOLEAN("Storage.Blob.InvalidReferenceInc", true);
Mark P 2016/04/19 19:34:52 If you're only emitting true to this histogram, wh
212 bad_message::ReceivedBadMessage( 214 bad_message::ReceivedBadMessage(
213 this, bad_message::BDH_INVALID_REFCOUNT_OPERATION); 215 this, bad_message::BDH_INVALID_REFCOUNT_OPERATION);
214 return; 216 return;
215 } 217 }
216 context->IncrementBlobRefCount(uuid); 218 context->IncrementBlobRefCount(uuid);
217 blobs_inuse_map_[uuid] += 1; 219 blobs_inuse_map_[uuid] += 1;
218 } 220 }
219 221
220 void BlobDispatcherHost::OnDecrementBlobRefCount(const std::string& uuid) { 222 void BlobDispatcherHost::OnDecrementBlobRefCount(const std::string& uuid) {
221 DCHECK_CURRENTLY_ON(BrowserThread::IO); 223 DCHECK_CURRENTLY_ON(BrowserThread::IO);
222 if (uuid.empty() || !IsInUseInHost(uuid)) { 224 if (uuid.empty() || !IsInUseInHost(uuid)) {
225 UMA_HISTOGRAM_BOOLEAN("Storage.Blob.InvalidReferenceDec", true);
223 bad_message::ReceivedBadMessage( 226 bad_message::ReceivedBadMessage(
224 this, bad_message::BDH_INVALID_REFCOUNT_OPERATION); 227 this, bad_message::BDH_INVALID_REFCOUNT_OPERATION);
225 return; 228 return;
226 } 229 }
227 BlobStorageContext* context = this->context(); 230 BlobStorageContext* context = this->context();
228 context->DecrementBlobRefCount(uuid); 231 context->DecrementBlobRefCount(uuid);
229 blobs_inuse_map_[uuid] -= 1; 232 blobs_inuse_map_[uuid] -= 1;
230 if (blobs_inuse_map_[uuid] == 0) { 233 if (blobs_inuse_map_[uuid] == 0) {
231 blobs_inuse_map_.erase(uuid); 234 blobs_inuse_map_.erase(uuid);
232 // If the blob has been deleted in the context and we're still building it, 235 // 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 236 // this means we have no references waiting to read it. Clear the building
234 // state and send a cancel message to the renderer. 237 // state and send a cancel message to the renderer.
235 if (async_builder_.IsBeingBuilt(uuid) && 238 if (async_builder_.IsBeingBuilt(uuid) &&
236 !context->registry().HasEntry(uuid)) { 239 !context->registry().HasEntry(uuid)) {
237 async_builder_.CancelBuildingBlob( 240 async_builder_.CancelBuildingBlob(
238 uuid, IPCBlobCreationCancelCode::BLOB_DEREFERENCED_WHILE_BUILDING, 241 uuid, IPCBlobCreationCancelCode::BLOB_DEREFERENCED_WHILE_BUILDING,
239 context); 242 context);
240 Send(new BlobStorageMsg_CancelBuildingBlob( 243 Send(new BlobStorageMsg_CancelBuildingBlob(
241 uuid, IPCBlobCreationCancelCode::BLOB_DEREFERENCED_WHILE_BUILDING)); 244 uuid, IPCBlobCreationCancelCode::BLOB_DEREFERENCED_WHILE_BUILDING));
242 } 245 }
243 } 246 }
244 } 247 }
245 248
246 void BlobDispatcherHost::OnRegisterPublicBlobURL(const GURL& public_url, 249 void BlobDispatcherHost::OnRegisterPublicBlobURL(const GURL& public_url,
247 const std::string& uuid) { 250 const std::string& uuid) {
248 DCHECK_CURRENTLY_ON(BrowserThread::IO); 251 DCHECK_CURRENTLY_ON(BrowserThread::IO);
249 BlobStorageContext* context = this->context(); 252 BlobStorageContext* context = this->context();
250 if (uuid.empty() || !IsInUseInHost(uuid) || 253 if (uuid.empty() || !IsInUseInHost(uuid) ||
251 context->registry().IsURLMapped(public_url)) { 254 context->registry().IsURLMapped(public_url)) {
255 UMA_HISTOGRAM_BOOLEAN("Storage.Blob.InvalidURLRegister", true);
Mark P 2016/04/19 19:34:52 analogous comment here
252 bad_message::ReceivedBadMessage(this, 256 bad_message::ReceivedBadMessage(this,
253 bad_message::BDH_INVALID_URL_OPERATION); 257 bad_message::BDH_INVALID_URL_OPERATION);
254 return; 258 return;
255 } 259 }
256 context->RegisterPublicBlobURL(public_url, uuid); 260 context->RegisterPublicBlobURL(public_url, uuid);
257 public_blob_urls_.insert(public_url); 261 public_blob_urls_.insert(public_url);
258 } 262 }
259 263
260 void BlobDispatcherHost::OnRevokePublicBlobURL(const GURL& public_url) { 264 void BlobDispatcherHost::OnRevokePublicBlobURL(const GURL& public_url) {
261 DCHECK_CURRENTLY_ON(BrowserThread::IO); 265 DCHECK_CURRENTLY_ON(BrowserThread::IO);
262 if (!IsUrlRegisteredInHost(public_url)) { 266 if (!IsUrlRegisteredInHost(public_url)) {
267 UMA_HISTOGRAM_BOOLEAN("Storage.Blob.InvalidURLRevoke", true);
263 bad_message::ReceivedBadMessage(this, 268 bad_message::ReceivedBadMessage(this,
264 bad_message::BDH_INVALID_URL_OPERATION); 269 bad_message::BDH_INVALID_URL_OPERATION);
265 return; 270 return;
266 } 271 }
267 context()->RevokePublicBlobURL(public_url); 272 context()->RevokePublicBlobURL(public_url);
268 public_blob_urls_.erase(public_url); 273 public_blob_urls_.erase(public_url);
269 } 274 }
270 275
271 storage::BlobStorageContext* BlobDispatcherHost::context() { 276 storage::BlobStorageContext* BlobDispatcherHost::context() {
272 return blob_storage_context_->context(); 277 return blob_storage_context_->context();
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after
331 context->RevokePublicBlobURL(url); 336 context->RevokePublicBlobURL(url);
332 } 337 }
333 for (const auto& uuid_refnum_pair : blobs_inuse_map_) { 338 for (const auto& uuid_refnum_pair : blobs_inuse_map_) {
334 for (int i = 0; i < uuid_refnum_pair.second; ++i) 339 for (int i = 0; i < uuid_refnum_pair.second; ++i)
335 context->DecrementBlobRefCount(uuid_refnum_pair.first); 340 context->DecrementBlobRefCount(uuid_refnum_pair.first);
336 } 341 }
337 async_builder_.CancelAll(context); 342 async_builder_.CancelAll(context);
338 } 343 }
339 344
340 } // namespace content 345 } // 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