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

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

Issue 1234813004: [BlobAsync] Asynchronous Blob Construction Final Patch (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@blob-protocol-change
Patch Set: comments Created 5 years 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
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/disk_cache/disk_cache.h" 20 #include "net/disk_cache/disk_cache.h"
21 #include "net/url_request/url_request.h" 21 #include "net/url_request/url_request.h"
22 #include "storage/browser/blob/blob_data_item.h"
22 #include "storage/browser/blob/blob_storage_context.h" 23 #include "storage/browser/blob/blob_storage_context.h"
24 #include "storage/browser/blob/blob_storage_registry.h"
23 #include "storage/browser/blob/internal_blob_data.h" 25 #include "storage/browser/blob/internal_blob_data.h"
24 26
25 namespace { 27 namespace {
26 28
27 const char kEmptyBlobStorageMessage[] = "No available blob data."; 29 const char kEmptyBlobStorageMessage[] = "No available blob data.";
28 const char kContentType[] = "Content Type: "; 30 const char kContentType[] = "Content Type: ";
29 const char kContentDisposition[] = "Content Disposition: "; 31 const char kContentDisposition[] = "Content Disposition: ";
30 const char kCount[] = "Count: "; 32 const char kCount[] = "Count: ";
31 const char kIndex[] = "Index: "; 33 const char kIndex[] = "Index: ";
32 const char kType[] = "Type: "; 34 const char kType[] = "Type: ";
(...skipping 97 matching lines...) Expand 10 before | Expand all | Expand 10 after
130 int ViewBlobInternalsJob::GetData( 132 int ViewBlobInternalsJob::GetData(
131 std::string* mime_type, 133 std::string* mime_type,
132 std::string* charset, 134 std::string* charset,
133 std::string* data, 135 std::string* data,
134 const net::CompletionCallback& callback) const { 136 const net::CompletionCallback& callback) const {
135 mime_type->assign("text/html"); 137 mime_type->assign("text/html");
136 charset->assign("UTF-8"); 138 charset->assign("UTF-8");
137 139
138 data->clear(); 140 data->clear();
139 StartHTML(data); 141 StartHTML(data);
140 if (blob_storage_context_->blob_map_.empty()) 142 if (blob_storage_context_->registry_.blob_map_.empty())
141 data->append(kEmptyBlobStorageMessage); 143 data->append(kEmptyBlobStorageMessage);
142 else 144 else
143 GenerateHTML(data); 145 GenerateHTML(data);
144 EndHTML(data); 146 EndHTML(data);
145 return net::OK; 147 return net::OK;
146 } 148 }
147 149
148 void ViewBlobInternalsJob::GenerateHTML(std::string* out) const { 150 void ViewBlobInternalsJob::GenerateHTML(std::string* out) const {
149 for (BlobStorageContext::BlobMap::const_iterator iter = 151 for (BlobStorageRegistry::BlobMap::const_iterator iter =
150 blob_storage_context_->blob_map_.begin(); 152 blob_storage_context_->registry_.blob_map_.begin();
151 iter != blob_storage_context_->blob_map_.end(); 153 iter != blob_storage_context_->registry_.blob_map_.end(); ++iter) {
152 ++iter) {
153 AddHTMLBoldText(iter->first, out); 154 AddHTMLBoldText(iter->first, out);
154 GenerateHTMLForBlobData(*iter->second->data, iter->second->refcount, out); 155 GenerateHTMLForBlobData(*iter->second->data, iter->second->refcount, out);
155 } 156 }
156 if (!blob_storage_context_->public_blob_urls_.empty()) { 157 if (!blob_storage_context_->registry_.url_to_uuid_.empty()) {
157 AddHorizontalRule(out); 158 AddHorizontalRule(out);
158 for (BlobStorageContext::BlobURLMap::const_iterator iter = 159 for (BlobStorageRegistry::URLMap::const_iterator iter =
159 blob_storage_context_->public_blob_urls_.begin(); 160 blob_storage_context_->registry_.url_to_uuid_.begin();
160 iter != blob_storage_context_->public_blob_urls_.end(); 161 iter != blob_storage_context_->registry_.url_to_uuid_.end(); ++iter) {
161 ++iter) {
162 AddHTMLBoldText(iter->first.spec(), out); 162 AddHTMLBoldText(iter->first.spec(), out);
163 StartHTMLList(out); 163 StartHTMLList(out);
164 AddHTMLListItem(kUUID, iter->second, out); 164 AddHTMLListItem(kUUID, iter->second, out);
165 EndHTMLList(out); 165 EndHTMLList(out);
166 } 166 }
167 } 167 }
168 } 168 }
169 169
170 void ViewBlobInternalsJob::GenerateHTMLForBlobData( 170 void ViewBlobInternalsJob::GenerateHTMLForBlobData(
171 const InternalBlobData& blob_data, 171 const InternalBlobData& blob_data,
(...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after
238 } 238 }
239 239
240 if (has_multi_items) 240 if (has_multi_items)
241 EndHTMLList(out); 241 EndHTMLList(out);
242 } 242 }
243 243
244 EndHTMLList(out); 244 EndHTMLList(out);
245 } 245 }
246 246
247 } // namespace storage 247 } // namespace storage
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698