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

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

Issue 2448353002: [BlobAsync] Moving async handling into BlobStorageContext & quota out. (Closed)
Patch Set: Fixed unused function Created 4 years, 1 month 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 <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"
11 #include "base/compiler_specific.h" 11 #include "base/compiler_specific.h"
12 #include "base/format_macros.h" 12 #include "base/format_macros.h"
13 #include "base/i18n/number_formatting.h" 13 #include "base/i18n/number_formatting.h"
14 #include "base/i18n/time_formatting.h" 14 #include "base/i18n/time_formatting.h"
15 #include "base/location.h" 15 #include "base/location.h"
16 #include "base/logging.h" 16 #include "base/logging.h"
17 #include "base/single_thread_task_runner.h" 17 #include "base/single_thread_task_runner.h"
18 #include "base/strings/string_number_conversions.h" 18 #include "base/strings/string_number_conversions.h"
19 #include "base/strings/string_util.h" 19 #include "base/strings/string_util.h"
20 #include "base/strings/stringprintf.h" 20 #include "base/strings/stringprintf.h"
21 #include "base/strings/utf_string_conversions.h" 21 #include "base/strings/utf_string_conversions.h"
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_storage_context.h" 29 #include "storage/browser/blob/blob_storage_context.h"
29 #include "storage/browser/blob/blob_storage_registry.h" 30 #include "storage/browser/blob/blob_storage_registry.h"
30 #include "storage/browser/blob/internal_blob_data.h" 31 #include "storage/browser/blob/shareable_blob_data_item.h"
31 32
32 namespace { 33 namespace {
33 34
34 const char kEmptyBlobStorageMessage[] = "No available blob data."; 35 const char kEmptyBlobStorageMessage[] = "No available blob data.";
35 const char kContentType[] = "Content Type: "; 36 const char kContentType[] = "Content Type: ";
36 const char kContentDisposition[] = "Content Disposition: "; 37 const char kContentDisposition[] = "Content Disposition: ";
37 const char kCount[] = "Count: "; 38 const char kCount[] = "Count: ";
38 const char kIndex[] = "Index: "; 39 const char kIndex[] = "Index: ";
39 const char kType[] = "Type: "; 40 const char kType[] = "Type: ";
40 const char kPath[] = "Path: "; 41 const char kPath[] = "Path: ";
(...skipping 95 matching lines...) Expand 10 before | Expand all | Expand 10 after
136 int ViewBlobInternalsJob::GetData( 137 int ViewBlobInternalsJob::GetData(
137 std::string* mime_type, 138 std::string* mime_type,
138 std::string* charset, 139 std::string* charset,
139 std::string* data, 140 std::string* data,
140 const net::CompletionCallback& callback) const { 141 const net::CompletionCallback& callback) const {
141 mime_type->assign("text/html"); 142 mime_type->assign("text/html");
142 charset->assign("UTF-8"); 143 charset->assign("UTF-8");
143 144
144 data->clear(); 145 data->clear();
145 StartHTML(data); 146 StartHTML(data);
146 if (blob_storage_context_->registry_.blob_map_.empty()) 147 if (blob_storage_context_->registry().blob_map_.empty())
147 data->append(kEmptyBlobStorageMessage); 148 data->append(kEmptyBlobStorageMessage);
148 else 149 else
149 GenerateHTML(data); 150 GenerateHTML(data);
150 EndHTML(data); 151 EndHTML(data);
151 return net::OK; 152 return net::OK;
152 } 153 }
153 154
154 void ViewBlobInternalsJob::GenerateHTML(std::string* out) const { 155 void ViewBlobInternalsJob::GenerateHTML(std::string* out) const {
155 for (BlobStorageRegistry::BlobMap::const_iterator iter = 156 for (BlobStorageRegistry::BlobMap::const_iterator iter =
156 blob_storage_context_->registry_.blob_map_.begin(); 157 blob_storage_context_->registry().blob_map_.begin();
157 iter != blob_storage_context_->registry_.blob_map_.end(); ++iter) { 158 iter != blob_storage_context_->registry().blob_map_.end(); ++iter) {
158 AddHTMLBoldText(iter->first, out); 159 AddHTMLBoldText(iter->first, out);
159 GenerateHTMLForBlobData(*iter->second->data, iter->second->content_type, 160 GenerateHTMLForBlobData(*iter->second, iter->second->content_type(),
160 iter->second->content_disposition, 161 iter->second->content_disposition(),
161 iter->second->refcount, out); 162 iter->second->refcount(), out);
162 } 163 }
163 if (!blob_storage_context_->registry_.url_to_uuid_.empty()) { 164 if (!blob_storage_context_->registry().url_to_uuid_.empty()) {
164 AddHorizontalRule(out); 165 AddHorizontalRule(out);
165 for (BlobStorageRegistry::URLMap::const_iterator iter = 166 for (BlobStorageRegistry::URLMap::const_iterator iter =
166 blob_storage_context_->registry_.url_to_uuid_.begin(); 167 blob_storage_context_->registry().url_to_uuid_.begin();
167 iter != blob_storage_context_->registry_.url_to_uuid_.end(); ++iter) { 168 iter != blob_storage_context_->registry().url_to_uuid_.end(); ++iter) {
168 AddHTMLBoldText(iter->first.spec(), out); 169 AddHTMLBoldText(iter->first.spec(), out);
169 StartHTMLList(out); 170 StartHTMLList(out);
170 AddHTMLListItem(kUUID, iter->second, out); 171 AddHTMLListItem(kUUID, iter->second, out);
171 EndHTMLList(out); 172 EndHTMLList(out);
172 } 173 }
173 } 174 }
174 } 175 }
175 176
176 void ViewBlobInternalsJob::GenerateHTMLForBlobData( 177 void ViewBlobInternalsJob::GenerateHTMLForBlobData(
177 const InternalBlobData& blob_data, 178 const BlobEntry& blob_data,
178 const std::string& content_type, 179 const std::string& content_type,
179 const std::string& content_disposition, 180 const std::string& content_disposition,
180 int refcount, 181 int refcount,
181 std::string* out) { 182 std::string* out) {
182 StartHTMLList(out); 183 StartHTMLList(out);
183 184
184 AddHTMLListItem(kRefcount, base::IntToString(refcount), out); 185 AddHTMLListItem(kRefcount, base::IntToString(refcount), out);
185 if (!content_type.empty()) 186 if (!content_type.empty())
186 AddHTMLListItem(kContentType, content_type, out); 187 AddHTMLListItem(kContentType, content_type, out);
187 if (!content_disposition.empty()) 188 if (!content_disposition.empty())
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after
225 AddHTMLListItem(kModificationTime, base::UTF16ToUTF8( 226 AddHTMLListItem(kModificationTime, base::UTF16ToUTF8(
226 TimeFormatFriendlyDateAndTime(item.expected_modification_time())), 227 TimeFormatFriendlyDateAndTime(item.expected_modification_time())),
227 out); 228 out);
228 } 229 }
229 break; 230 break;
230 case DataElement::TYPE_DISK_CACHE_ENTRY: 231 case DataElement::TYPE_DISK_CACHE_ENTRY:
231 AddHTMLListItem(kType, "disk cache entry", out); 232 AddHTMLListItem(kType, "disk cache entry", out);
232 AddHTMLListItem(kURL, item.disk_cache_entry()->GetKey(), out); 233 AddHTMLListItem(kURL, item.disk_cache_entry()->GetKey(), out);
233 break; 234 break;
234 case DataElement::TYPE_BYTES_DESCRIPTION: 235 case DataElement::TYPE_BYTES_DESCRIPTION:
236 AddHTMLListItem(kType, "pending data", out);
235 case DataElement::TYPE_UNKNOWN: 237 case DataElement::TYPE_UNKNOWN:
236 NOTREACHED(); 238 NOTREACHED();
237 break; 239 break;
238 } 240 }
239 if (item.offset()) { 241 if (item.offset()) {
240 AddHTMLListItem(kOffset, base::UTF16ToUTF8(base::FormatNumber( 242 AddHTMLListItem(kOffset, base::UTF16ToUTF8(base::FormatNumber(
241 static_cast<int64_t>(item.offset()))), 243 static_cast<int64_t>(item.offset()))),
242 out); 244 out);
243 } 245 }
244 if (static_cast<int64_t>(item.length()) != -1) { 246 if (static_cast<int64_t>(item.length()) != -1) {
245 AddHTMLListItem(kLength, base::UTF16ToUTF8(base::FormatNumber( 247 AddHTMLListItem(kLength, base::UTF16ToUTF8(base::FormatNumber(
246 static_cast<int64_t>(item.length()))), 248 static_cast<int64_t>(item.length()))),
247 out); 249 out);
248 } 250 }
249 251
250 if (has_multi_items) 252 if (has_multi_items)
251 EndHTMLList(out); 253 EndHTMLList(out);
252 } 254 }
253 255
254 EndHTMLList(out); 256 EndHTMLList(out);
255 } 257 }
256 258
257 } // namespace storage 259 } // namespace storage
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698