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

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

Issue 2723893003: [BlobStorage] Add blob status to blob-internals page (Closed)
Patch Set: Created 3 years, 9 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 | no next file » | 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 <stddef.h> 7 #include <stddef.h>
8 #include <stdint.h> 8 #include <stdint.h>
9 9
10 #include "base/bind.h" 10 #include "base/bind.h"
(...skipping 11 matching lines...) Expand all
22 #include "base/threading/thread_task_runner_handle.h" 22 #include "base/threading/thread_task_runner_handle.h"
23 #include "net/base/escape.h" 23 #include "net/base/escape.h"
24 #include "net/base/net_errors.h" 24 #include "net/base/net_errors.h"
25 #include "net/disk_cache/disk_cache.h" 25 #include "net/disk_cache/disk_cache.h"
26 #include "net/url_request/url_request.h" 26 #include "net/url_request/url_request.h"
27 #include "storage/browser/blob/blob_data_item.h" 27 #include "storage/browser/blob/blob_data_item.h"
28 #include "storage/browser/blob/blob_entry.h" 28 #include "storage/browser/blob/blob_entry.h"
29 #include "storage/browser/blob/blob_storage_context.h" 29 #include "storage/browser/blob/blob_storage_context.h"
30 #include "storage/browser/blob/blob_storage_registry.h" 30 #include "storage/browser/blob/blob_storage_registry.h"
31 #include "storage/browser/blob/shareable_blob_data_item.h" 31 #include "storage/browser/blob/shareable_blob_data_item.h"
32 #include "storage/common/blob_storage/blob_storage_constants.h"
32 33
33 namespace { 34 namespace {
35 using storage::BlobStatus;
34 36
35 const char kEmptyBlobStorageMessage[] = "No available blob data."; 37 const char kEmptyBlobStorageMessage[] = "No available blob data.";
36 const char kContentType[] = "Content Type: "; 38 const char kContentType[] = "Content Type: ";
37 const char kContentDisposition[] = "Content Disposition: "; 39 const char kContentDisposition[] = "Content Disposition: ";
38 const char kCount[] = "Count: "; 40 const char kCount[] = "Count: ";
39 const char kIndex[] = "Index: "; 41 const char kIndex[] = "Index: ";
40 const char kType[] = "Type: "; 42 const char kType[] = "Type: ";
41 const char kPath[] = "Path: "; 43 const char kPath[] = "Path: ";
42 const char kURL[] = "URL: "; 44 const char kURL[] = "URL: ";
43 const char kModificationTime[] = "Modification Time: "; 45 const char kModificationTime[] = "Modification Time: ";
44 const char kOffset[] = "Offset: "; 46 const char kOffset[] = "Offset: ";
45 const char kLength[] = "Length: "; 47 const char kLength[] = "Length: ";
46 const char kUUID[] = "Uuid: "; 48 const char kUUID[] = "Uuid: ";
47 const char kRefcount[] = "Refcount: "; 49 const char kRefcount[] = "Refcount: ";
50 const char kStatus[] = "Status: ";
48 51
49 void StartHTML(std::string* out) { 52 void StartHTML(std::string* out) {
50 out->append( 53 out->append(
51 "<!DOCTYPE HTML>" 54 "<!DOCTYPE HTML>"
52 "<html><title>Blob Storage Internals</title>" 55 "<html><title>Blob Storage Internals</title>"
53 "<meta http-equiv=\"Content-Security-Policy\"" 56 "<meta http-equiv=\"Content-Security-Policy\""
54 " content=\"object-src 'none'; script-src 'none'\">\n" 57 " content=\"object-src 'none'; script-src 'none'\">\n"
55 "<style>\n" 58 "<style>\n"
56 "body { font-family: sans-serif; font-size: 0.8em; }\n" 59 "body { font-family: sans-serif; font-size: 0.8em; }\n"
57 "tt, code, pre { font-family: WebKitHack, monospace; }\n" 60 "tt, code, pre { font-family: WebKitHack, monospace; }\n"
58 "form { display: inline }\n" 61 "form { display: inline }\n"
59 ".subsection_body { margin: 10px 0 10px 2em; }\n" 62 ".subsection_body { margin: 10px 0 10px 2em; }\n"
60 ".subsection_title { font-weight: bold; }\n" 63 ".subsection_title { font-weight: bold; }\n"
61 "</style>\n" 64 "</style>\n"
62 "</head><body>\n\n"); 65 "</head><body>\n\n");
63 } 66 }
64 67
68 std::string StatusToString(BlobStatus status) {
69 switch (status) {
70 case BlobStatus::ERR_INVALID_CONSTRUCTION_ARGUMENTS:
71 return "Illegal blob construction.";
pwnall 2017/03/01 16:44:05 Can you also add the constant names here? It'll ma
dmurph 2017/03/01 20:36:57 sgtm - I made it a little shorter by removing the
72 case BlobStatus::ERR_OUT_OF_MEMORY:
73 return "Not enough memory or disk space available for blob.";
74 case BlobStatus::ERR_FILE_WRITE_FAILED:
75 return "File operation filed";
76 case BlobStatus::ERR_SOURCE_DIED_IN_TRANSIT:
77 return "Blob source died before transporting data to browser.";
78 case BlobStatus::ERR_BLOB_DEREFERENCED_WHILE_BUILDING:
79 return "Blob references removed while building.";
80 case BlobStatus::ERR_REFERENCED_BLOB_BROKEN:
81 return "Blob contains dependency blob that is broken.";
82 case BlobStatus::DONE:
83 return "Blob built with no errors.";
84 case BlobStatus::PENDING_QUOTA:
85 return "Blob construction is pending on memory or file quota.";
86 case BlobStatus::PENDING_TRANSPORT:
87 return "Blob construction is pending on data transport from renderer.";
88 case BlobStatus::PENDING_INTERNALS:
89 return "Blob construction is pending on dependency blobs to finish "
90 "construction.";
91 }
92 NOTREACHED();
93 return "Invalid blob state.";
94 }
95
65 void EndHTML(std::string* out) { 96 void EndHTML(std::string* out) {
66 out->append("\n</body></html>"); 97 out->append("\n</body></html>");
67 } 98 }
68 99
69 void AddHTMLBoldText(const std::string& text, std::string* out) { 100 void AddHTMLBoldText(const std::string& text, std::string* out) {
70 out->append("<b>"); 101 out->append("<b>");
71 out->append(net::EscapeForHTML(text)); 102 out->append(net::EscapeForHTML(text));
72 out->append("</b>"); 103 out->append("</b>");
73 } 104 }
74 105
(...skipping 99 matching lines...) Expand 10 before | Expand all | Expand 10 after
174 205
175 void ViewBlobInternalsJob::GenerateHTMLForBlobData( 206 void ViewBlobInternalsJob::GenerateHTMLForBlobData(
176 const BlobEntry& blob_data, 207 const BlobEntry& blob_data,
177 const std::string& content_type, 208 const std::string& content_type,
178 const std::string& content_disposition, 209 const std::string& content_disposition,
179 int refcount, 210 int refcount,
180 std::string* out) { 211 std::string* out) {
181 StartHTMLList(out); 212 StartHTMLList(out);
182 213
183 AddHTMLListItem(kRefcount, base::IntToString(refcount), out); 214 AddHTMLListItem(kRefcount, base::IntToString(refcount), out);
215 AddHTMLListItem(kStatus, StatusToString(blob_data.status()), out);
184 if (!content_type.empty()) 216 if (!content_type.empty())
185 AddHTMLListItem(kContentType, content_type, out); 217 AddHTMLListItem(kContentType, content_type, out);
186 if (!content_disposition.empty()) 218 if (!content_disposition.empty())
187 AddHTMLListItem(kContentDisposition, content_disposition, out); 219 AddHTMLListItem(kContentDisposition, content_disposition, out);
188 220
189 bool has_multi_items = blob_data.items().size() > 1; 221 bool has_multi_items = blob_data.items().size() > 1;
190 if (has_multi_items) { 222 if (has_multi_items) {
191 AddHTMLListItem(kCount, 223 AddHTMLListItem(kCount,
192 base::UTF16ToUTF8(base::FormatNumber(blob_data.items().size())), out); 224 base::UTF16ToUTF8(base::FormatNumber(blob_data.items().size())), out);
193 } 225 }
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after
248 } 280 }
249 281
250 if (has_multi_items) 282 if (has_multi_items)
251 EndHTMLList(out); 283 EndHTMLList(out);
252 } 284 }
253 285
254 EndHTMLList(out); 286 EndHTMLList(out);
255 } 287 }
256 288
257 } // namespace storage 289 } // namespace storage
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698