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

Side by Side Diff: storage/browser/blob/blob_storage_context.cc

Issue 812843005: [Storage] Added histograms for blob storage (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: cleaner windows compile fix Created 5 years, 11 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 (c) 2013 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2013 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 "storage/browser/blob/blob_storage_context.h" 5 #include "storage/browser/blob/blob_storage_context.h"
6 6
7 #include "base/bind.h" 7 #include "base/bind.h"
8 #include "base/location.h" 8 #include "base/location.h"
9 #include "base/logging.h" 9 #include "base/logging.h"
10 #include "base/message_loop/message_loop_proxy.h" 10 #include "base/message_loop/message_loop_proxy.h"
11 #include "base/metrics/histogram.h"
11 #include "storage/browser/blob/blob_data_handle.h" 12 #include "storage/browser/blob/blob_data_handle.h"
12 #include "storage/common/blob/blob_data.h" 13 #include "storage/common/blob/blob_data.h"
13 #include "url/gurl.h" 14 #include "url/gurl.h"
14 15
15 namespace storage { 16 namespace storage {
16 17
17 namespace { 18 namespace {
18 19
19 // We can't use GURL directly for these hash fragment manipulations 20 // We can't use GURL directly for these hash fragment manipulations
20 // since it doesn't have specific knowlege of the BlobURL format. GURL 21 // since it doesn't have specific knowlege of the BlobURL format. GURL
(...skipping 115 matching lines...) Expand 10 before | Expand all | Expand 10 after
136 // list of Data, File, and FileSystem items. Aggregated TYPE_BLOB items 137 // list of Data, File, and FileSystem items. Aggregated TYPE_BLOB items
137 // are expanded into the primitive constituent types. 138 // are expanded into the primitive constituent types.
138 // 1) The Data item is denoted by the raw data and length. 139 // 1) The Data item is denoted by the raw data and length.
139 // 2) The File item is denoted by the file path, the range and the expected 140 // 2) The File item is denoted by the file path, the range and the expected
140 // modification time. 141 // modification time.
141 // 3) The FileSystem File item is denoted by the FileSystem URL, the range 142 // 3) The FileSystem File item is denoted by the FileSystem URL, the range
142 // and the expected modification time. 143 // and the expected modification time.
143 // 4) The Blob items are expanded. 144 // 4) The Blob items are expanded.
144 // TODO(michaeln): Would be nice to avoid copying Data items when expanding. 145 // TODO(michaeln): Would be nice to avoid copying Data items when expanding.
145 146
146 DCHECK(item.length() > 0); 147 uint64 length = item.length();
148 DCHECK_GT(length, 0u);
149 UMA_HISTOGRAM_COUNTS("Storage.Blob.StorageSizeBeforeAppend",
150 memory_usage_ / 1024);
147 switch (item.type()) { 151 switch (item.type()) {
148 case BlobData::Item::TYPE_BYTES: 152 case BlobData::Item::TYPE_BYTES:
153 UMA_HISTOGRAM_COUNTS("Storage.BlobItemSize.Bytes", length);
149 DCHECK(!item.offset()); 154 DCHECK(!item.offset());
150 exceeded_memory = !AppendBytesItem(target_blob_data, 155 exceeded_memory = !AppendBytesItem(target_blob_data, item.bytes(),
151 item.bytes(), 156 static_cast<int64>(length));
152 static_cast<int64>(item.length()));
153 break; 157 break;
154 case BlobData::Item::TYPE_FILE: 158 case BlobData::Item::TYPE_FILE:
155 AppendFileItem(target_blob_data, 159 UMA_HISTOGRAM_COUNTS("Storage.BlobItemSize.File", length);
156 item.path(), 160 AppendFileItem(target_blob_data, item.path(), item.offset(), length,
157 item.offset(),
158 item.length(),
159 item.expected_modification_time()); 161 item.expected_modification_time());
160 break; 162 break;
161 case BlobData::Item::TYPE_FILE_FILESYSTEM: 163 case BlobData::Item::TYPE_FILE_FILESYSTEM:
162 AppendFileSystemFileItem(target_blob_data, 164 UMA_HISTOGRAM_COUNTS("Storage.BlobItemSize.FileSystem", length);
163 item.filesystem_url(), 165 AppendFileSystemFileItem(target_blob_data, item.filesystem_url(),
164 item.offset(), 166 item.offset(), length,
165 item.length(),
166 item.expected_modification_time()); 167 item.expected_modification_time());
167 break; 168 break;
168 case BlobData::Item::TYPE_BLOB: { 169 case BlobData::Item::TYPE_BLOB: {
170 UMA_HISTOGRAM_COUNTS("Storage.BlobItemSize.Blob", length);
169 scoped_ptr<BlobDataHandle> src = GetBlobDataFromUUID(item.blob_uuid()); 171 scoped_ptr<BlobDataHandle> src = GetBlobDataFromUUID(item.blob_uuid());
170 if (src) 172 if (src)
171 exceeded_memory = !ExpandStorageItems(target_blob_data, 173 exceeded_memory = !ExpandStorageItems(target_blob_data,
172 src->data(), 174 src->data(),
173 item.offset(), 175 item.offset(),
174 item.length()); 176 item.length());
175 break; 177 break;
176 } 178 }
177 default: 179 default:
178 NOTREACHED(); 180 NOTREACHED();
179 break; 181 break;
180 } 182 }
183 UMA_HISTOGRAM_COUNTS("Storage.Blob.StorageSizeAfterAppend",
michaeln 2015/01/07 21:30:53 Would it make sense to use either UMA_HISTOGRAM_ME
184 memory_usage_ / 1024);
181 185
182 // If we're using too much memory, drop this blob's data. 186 // If we're using too much memory, drop this blob's data.
183 // TODO(michaeln): Blob memory storage does not yet spill over to disk, 187 // TODO(michaeln): Blob memory storage does not yet spill over to disk,
184 // as a stop gap, we'll prevent memory usage over a max amount. 188 // as a stop gap, we'll prevent memory usage over a max amount.
185 if (exceeded_memory) { 189 if (exceeded_memory) {
186 memory_usage_ -= target_blob_data->GetMemoryUsage(); 190 memory_usage_ -= target_blob_data->GetMemoryUsage();
187 found->second.flags |= EXCEEDED_MEMORY; 191 found->second.flags |= EXCEEDED_MEMORY;
188 found->second.data = new BlobData(uuid); 192 found->second.data = new BlobData(uuid);
189 return; 193 return;
190 } 194 }
191 } 195 }
192 196
193 void BlobStorageContext::FinishBuildingBlob( 197 void BlobStorageContext::FinishBuildingBlob(
194 const std::string& uuid, const std::string& content_type) { 198 const std::string& uuid, const std::string& content_type) {
195 DCHECK(IsBeingBuilt(uuid)); 199 DCHECK(IsBeingBuilt(uuid));
196 BlobMap::iterator found = blob_map_.find(uuid); 200 BlobMap::iterator found = blob_map_.find(uuid);
197 if (found == blob_map_.end()) 201 if (found == blob_map_.end())
198 return; 202 return;
199 found->second.data->set_content_type(content_type); 203 found->second.data->set_content_type(content_type);
200 found->second.flags &= ~BEING_BUILT; 204 found->second.flags &= ~BEING_BUILT;
205 UMA_HISTOGRAM_BOOLEAN(
206 "Storage.Blob.ExceededMemory",
207 (found->second.flags & EXCEEDED_MEMORY) == EXCEEDED_MEMORY);
201 } 208 }
202 209
203 void BlobStorageContext::CancelBuildingBlob(const std::string& uuid) { 210 void BlobStorageContext::CancelBuildingBlob(const std::string& uuid) {
204 DCHECK(IsBeingBuilt(uuid)); 211 DCHECK(IsBeingBuilt(uuid));
205 DecrementBlobRefCount(uuid); 212 DecrementBlobRefCount(uuid);
206 } 213 }
207 214
208 void BlobStorageContext::IncrementBlobRefCount(const std::string& uuid) { 215 void BlobStorageContext::IncrementBlobRefCount(const std::string& uuid) {
209 BlobMap::iterator found = blob_map_.find(uuid); 216 BlobMap::iterator found = blob_map_.find(uuid);
210 if (found == blob_map_.end()) { 217 if (found == blob_map_.end()) {
(...skipping 105 matching lines...) Expand 10 before | Expand all | Expand 10 after
316 if (found == blob_map_.end()) 323 if (found == blob_map_.end())
317 return false; 324 return false;
318 return found->second.flags & BEING_BUILT; 325 return found->second.flags & BEING_BUILT;
319 } 326 }
320 327
321 bool BlobStorageContext::IsUrlRegistered(const GURL& blob_url) { 328 bool BlobStorageContext::IsUrlRegistered(const GURL& blob_url) {
322 return public_blob_urls_.find(blob_url) != public_blob_urls_.end(); 329 return public_blob_urls_.find(blob_url) != public_blob_urls_.end();
323 } 330 }
324 331
325 } // namespace storage 332 } // namespace storage
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