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

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

Issue 895933007: [Storage] Blob items are now shared between blobs. Ready for disk swap. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Cleanup and added one more histogram Created 5 years, 10 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 | « storage/browser/blob/view_blob_internals_job.h ('k') | storage/storage_browser.gyp » ('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) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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/view_blob_internals_job.h" 5 #include "storage/browser/blob/view_blob_internals_job.h"
6 6
7 #include "base/bind.h" 7 #include "base/bind.h"
8 #include "base/compiler_specific.h" 8 #include "base/compiler_specific.h"
9 #include "base/format_macros.h" 9 #include "base/format_macros.h"
10 #include "base/i18n/number_formatting.h" 10 #include "base/i18n/number_formatting.h"
11 #include "base/i18n/time_formatting.h" 11 #include "base/i18n/time_formatting.h"
12 #include "base/logging.h" 12 #include "base/logging.h"
13 #include "base/message_loop/message_loop.h" 13 #include "base/message_loop/message_loop.h"
14 #include "base/strings/string_number_conversions.h" 14 #include "base/strings/string_number_conversions.h"
15 #include "base/strings/string_util.h" 15 #include "base/strings/string_util.h"
16 #include "base/strings/stringprintf.h" 16 #include "base/strings/stringprintf.h"
17 #include "base/strings/utf_string_conversions.h" 17 #include "base/strings/utf_string_conversions.h"
18 #include "net/base/escape.h" 18 #include "net/base/escape.h"
19 #include "net/base/net_errors.h" 19 #include "net/base/net_errors.h"
20 #include "net/url_request/url_request.h" 20 #include "net/url_request/url_request.h"
21 #include "storage/browser/blob/blob_data_snapshot.h"
22 #include "storage/browser/blob/blob_storage_context.h" 21 #include "storage/browser/blob/blob_storage_context.h"
22 #include "storage/browser/blob/internal_blob_data.h"
23 23
24 namespace { 24 namespace {
25 25
26 const char kEmptyBlobStorageMessage[] = "No available blob data."; 26 const char kEmptyBlobStorageMessage[] = "No available blob data.";
27 const char kContentType[] = "Content Type: "; 27 const char kContentType[] = "Content Type: ";
28 const char kContentDisposition[] = "Content Disposition: "; 28 const char kContentDisposition[] = "Content Disposition: ";
29 const char kCount[] = "Count: "; 29 const char kCount[] = "Count: ";
30 const char kIndex[] = "Index: "; 30 const char kIndex[] = "Index: ";
31 const char kType[] = "Type: "; 31 const char kType[] = "Type: ";
32 const char kPath[] = "Path: "; 32 const char kPath[] = "Path: ";
(...skipping 110 matching lines...) Expand 10 before | Expand all | Expand 10 after
143 EndHTML(data); 143 EndHTML(data);
144 return net::OK; 144 return net::OK;
145 } 145 }
146 146
147 void ViewBlobInternalsJob::GenerateHTML(std::string* out) const { 147 void ViewBlobInternalsJob::GenerateHTML(std::string* out) const {
148 for (BlobStorageContext::BlobMap::const_iterator iter = 148 for (BlobStorageContext::BlobMap::const_iterator iter =
149 blob_storage_context_->blob_map_.begin(); 149 blob_storage_context_->blob_map_.begin();
150 iter != blob_storage_context_->blob_map_.end(); 150 iter != blob_storage_context_->blob_map_.end();
151 ++iter) { 151 ++iter) {
152 AddHTMLBoldText(iter->first, out); 152 AddHTMLBoldText(iter->first, out);
153 GenerateHTMLForBlobData(*(iter->second->data.get()), iter->second->refcount, 153 GenerateHTMLForBlobData(*iter->second->data, iter->second->refcount, out);
154 out);
155 } 154 }
156 if (!blob_storage_context_->public_blob_urls_.empty()) { 155 if (!blob_storage_context_->public_blob_urls_.empty()) {
157 AddHorizontalRule(out); 156 AddHorizontalRule(out);
158 for (BlobStorageContext::BlobURLMap::const_iterator iter = 157 for (BlobStorageContext::BlobURLMap::const_iterator iter =
159 blob_storage_context_->public_blob_urls_.begin(); 158 blob_storage_context_->public_blob_urls_.begin();
160 iter != blob_storage_context_->public_blob_urls_.end(); 159 iter != blob_storage_context_->public_blob_urls_.end();
161 ++iter) { 160 ++iter) {
162 AddHTMLBoldText(iter->first.spec(), out); 161 AddHTMLBoldText(iter->first.spec(), out);
163 StartHTMLList(out); 162 StartHTMLList(out);
164 AddHTMLListItem(kUUID, iter->second, out); 163 AddHTMLListItem(kUUID, iter->second, out);
165 EndHTMLList(out); 164 EndHTMLList(out);
166 } 165 }
167 } 166 }
168 } 167 }
169 168
170 void ViewBlobInternalsJob::GenerateHTMLForBlobData( 169 void ViewBlobInternalsJob::GenerateHTMLForBlobData(
171 const BlobDataSnapshot& blob_data, 170 const InternalBlobData& blob_data,
172 int refcount, 171 int refcount,
173 std::string* out) { 172 std::string* out) {
174 StartHTMLList(out); 173 StartHTMLList(out);
175 174
176 AddHTMLListItem(kRefcount, base::IntToString(refcount), out); 175 AddHTMLListItem(kRefcount, base::IntToString(refcount), out);
177 if (!blob_data.content_type().empty()) 176 if (!blob_data.content_type().empty())
178 AddHTMLListItem(kContentType, blob_data.content_type(), out); 177 AddHTMLListItem(kContentType, blob_data.content_type(), out);
179 if (!blob_data.content_disposition().empty()) 178 if (!blob_data.content_disposition().empty())
180 AddHTMLListItem(kContentDisposition, blob_data.content_disposition(), out); 179 AddHTMLListItem(kContentDisposition, blob_data.content_disposition(), out);
181 180
182 bool has_multi_items = blob_data.items().size() > 1; 181 bool has_multi_items = blob_data.items().size() > 1;
183 if (has_multi_items) { 182 if (has_multi_items) {
184 AddHTMLListItem(kCount, 183 AddHTMLListItem(kCount,
185 base::UTF16ToUTF8(base::FormatNumber(blob_data.items().size())), out); 184 base::UTF16ToUTF8(base::FormatNumber(blob_data.items().size())), out);
186 } 185 }
187 186
188 for (size_t i = 0; i < blob_data.items().size(); ++i) { 187 for (size_t i = 0; i < blob_data.items().size(); ++i) {
189 if (has_multi_items) { 188 if (has_multi_items) {
190 AddHTMLListItem(kIndex, base::UTF16ToUTF8(base::FormatNumber(i)), out); 189 AddHTMLListItem(kIndex, base::UTF16ToUTF8(base::FormatNumber(i)), out);
191 StartHTMLList(out); 190 StartHTMLList(out);
192 } 191 }
193 const BlobDataItem& item = *(blob_data.items().at(i)); 192 const BlobDataItem& item = *(blob_data.items().at(i)->item());
194 193
195 switch (item.type()) { 194 switch (item.type()) {
196 case DataElement::TYPE_BYTES: 195 case DataElement::TYPE_BYTES:
197 AddHTMLListItem(kType, "data", out); 196 AddHTMLListItem(kType, "data", out);
198 break; 197 break;
199 case DataElement::TYPE_FILE: 198 case DataElement::TYPE_FILE:
200 AddHTMLListItem(kType, "file", out); 199 AddHTMLListItem(kType, "file", out);
201 AddHTMLListItem(kPath, 200 AddHTMLListItem(kPath,
202 net::EscapeForHTML(item.path().AsUTF8Unsafe()), 201 net::EscapeForHTML(item.path().AsUTF8Unsafe()),
203 out); 202 out);
(...skipping 29 matching lines...) Expand all
233 } 232 }
234 233
235 if (has_multi_items) 234 if (has_multi_items)
236 EndHTMLList(out); 235 EndHTMLList(out);
237 } 236 }
238 237
239 EndHTMLList(out); 238 EndHTMLList(out);
240 } 239 }
241 240
242 } // namespace storage 241 } // namespace storage
OLDNEW
« no previous file with comments | « storage/browser/blob/view_blob_internals_job.h ('k') | storage/storage_browser.gyp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698