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

Unified Diff: webkit/browser/blob/view_blob_internals_job.cc

Issue 23223003: Chromium Blob hacking (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 7 years, 3 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 side-by-side diff with in-line comments
Download patch
Index: webkit/browser/blob/view_blob_internals_job.cc
diff --git a/webkit/browser/blob/view_blob_internals_job.cc b/webkit/browser/blob/view_blob_internals_job.cc
index 41ef7883de5c2bcb3d8fb0668db5d16ed3b2e274..e0523a4277ba744d2451c729b2770f6645fc3efc 100644
--- a/webkit/browser/blob/view_blob_internals_job.cc
+++ b/webkit/browser/blob/view_blob_internals_job.cc
@@ -11,13 +11,14 @@
#include "base/i18n/time_formatting.h"
#include "base/logging.h"
#include "base/message_loop/message_loop.h"
+#include "base/strings/string_number_conversions.h"
#include "base/strings/string_util.h"
#include "base/strings/stringprintf.h"
#include "base/strings/utf_string_conversions.h"
#include "net/base/escape.h"
#include "net/base/net_errors.h"
#include "net/url_request/url_request.h"
-#include "webkit/browser/blob/blob_storage_controller.h"
+#include "webkit/browser/blob/blob_storage_context.h"
#include "webkit/common/blob/blob_data.h"
namespace {
@@ -34,6 +35,8 @@ const char kURL[] = "URL: ";
const char kModificationTime[] = "Modification Time: ";
const char kOffset[] = "Offset: ";
const char kLength[] = "Length: ";
+const char kUUID[] = "Uuid: ";
+const char kRefcount[] = "Refcount: ";
void StartHTML(std::string* out) {
out->append(
@@ -48,11 +51,11 @@ void StartHTML(std::string* out) {
".subsection_body { margin: 10px 0 10px 2em; }\n"
".subsection_title { font-weight: bold; }\n"
"</style>\n"
- "</head><body>\n");
+ "</head><body>\n\n");
}
void EndHTML(std::string* out) {
- out->append("</body></html>");
+ out->append("\n</body></html>");
}
void AddHTMLBoldText(const std::string& text, std::string* out) {
@@ -62,11 +65,11 @@ void AddHTMLBoldText(const std::string& text, std::string* out) {
}
void StartHTMLList(std::string* out) {
- out->append("<ul>");
+ out->append("\n<ul>");
}
void EndHTMLList(std::string* out) {
- out->append("</ul>");
+ out->append("</ul>\n");
}
void AddHTMLListItem(const std::string& element_title,
@@ -76,21 +79,11 @@ void AddHTMLListItem(const std::string& element_title,
// No need to escape element_title since constant string is passed.
out->append(element_title);
out->append(net::EscapeForHTML(element_data));
- out->append("</li>");
+ out->append("</li>\n");
}
-void AddHTMLButton(const std::string& title,
- const std::string& command,
- std::string* out) {
- // No need to escape title since constant string is passed.
- std::string escaped_command = net::EscapeForHTML(command.c_str());
- base::StringAppendF(out,
- "<form action=\"\" method=\"GET\">\n"
- "<input type=\"hidden\" name=\"remove\" value=\"%s\">\n"
- "<input type=\"submit\" value=\"%s\">\n"
- "</form><br/>\n",
- escaped_command.c_str(),
- title.c_str());
+void AddHorizontalRule(std::string* out) {
+ out->append("\n<hr>\n");
}
} // namespace
@@ -100,9 +93,9 @@ namespace webkit_blob {
ViewBlobInternalsJob::ViewBlobInternalsJob(
net::URLRequest* request,
net::NetworkDelegate* network_delegate,
- BlobStorageController* blob_storage_controller)
+ BlobStorageContext* blob_storage_context)
: net::URLRequestSimpleJob(request, network_delegate),
- blob_storage_controller_(blob_storage_controller),
+ blob_storage_context_(blob_storage_context),
weak_factory_(this) {
}
@@ -112,7 +105,7 @@ ViewBlobInternalsJob::~ViewBlobInternalsJob() {
void ViewBlobInternalsJob::Start() {
base::MessageLoop::current()->PostTask(
FROM_HERE,
- base::Bind(&ViewBlobInternalsJob::DoWorkAsync,
+ base::Bind(&ViewBlobInternalsJob::StartAsync,
weak_factory_.GetWeakPtr()));
}
@@ -134,18 +127,6 @@ void ViewBlobInternalsJob::Kill() {
weak_factory_.InvalidateWeakPtrs();
}
-void ViewBlobInternalsJob::DoWorkAsync() {
- if (request_->url().has_query() &&
- StartsWithASCII(request_->url().query(), "remove=", true)) {
- std::string blob_url = request_->url().query().substr(strlen("remove="));
- blob_url = net::UnescapeURLComponent(blob_url,
- net::UnescapeRule::NORMAL | net::UnescapeRule::URL_SPECIAL_CHARS);
- blob_storage_controller_->RemoveBlob(GURL(blob_url));
- }
-
- StartAsync();
-}
-
int ViewBlobInternalsJob::GetData(
std::string* mime_type,
std::string* charset,
@@ -156,7 +137,7 @@ int ViewBlobInternalsJob::GetData(
data->clear();
StartHTML(data);
- if (blob_storage_controller_->blob_map_.empty())
+ if (blob_storage_context_->blob_map_.empty())
data->append(kEmptyBlobStorageMessage);
else
GenerateHTML(data);
@@ -165,20 +146,47 @@ int ViewBlobInternalsJob::GetData(
}
void ViewBlobInternalsJob::GenerateHTML(std::string* out) const {
- for (BlobStorageController::BlobMap::const_iterator iter =
- blob_storage_controller_->blob_map_.begin();
- iter != blob_storage_controller_->blob_map_.end();
+ for (BlobStorageContext::BlobMap::const_iterator iter =
+ blob_storage_context_->blob_map_.begin();
+ iter != blob_storage_context_->blob_map_.end();
++iter) {
AddHTMLBoldText(iter->first, out);
- AddHTMLButton(kRemove, iter->first, out);
- GenerateHTMLForBlobData(*iter->second.get(), out);
+ GenerateHTMLForBlobData(*(iter->second.data.get()),
+ iter->second.refcount,
+ out);
+ }
+ if (!blob_storage_context_->public_blob_urls_.empty()) {
+ AddHorizontalRule(out);
+ for (BlobStorageContext::BlobURLMap::const_iterator iter =
+ blob_storage_context_->public_blob_urls_.begin();
+ iter != blob_storage_context_->public_blob_urls_.end();
+ ++iter) {
+ AddHTMLBoldText(iter->first.spec(), out);
+ StartHTMLList(out);
+ AddHTMLListItem(kUUID, iter->second, out);
+ EndHTMLList(out);
+ }
+ }
+ if (!blob_storage_context_->deprecated_blob_urls_.empty()) {
+ AddHorizontalRule(out);
+ for (BlobStorageContext::BlobURLMap::const_iterator iter =
+ blob_storage_context_->deprecated_blob_urls_.begin();
+ iter != blob_storage_context_->deprecated_blob_urls_.end();
+ ++iter) {
+ AddHTMLBoldText(iter->first.spec(), out);
+ StartHTMLList(out);
+ AddHTMLListItem(kUUID, iter->second, out);
+ EndHTMLList(out);
+ }
}
}
void ViewBlobInternalsJob::GenerateHTMLForBlobData(const BlobData& blob_data,
+ int refcount,
std::string* out) {
StartHTMLList(out);
+ AddHTMLListItem(kRefcount, base::IntToString(refcount), out);
if (!blob_data.content_type().empty())
AddHTMLListItem(kContentType, blob_data.content_type(), out);
if (!blob_data.content_disposition().empty())
@@ -213,12 +221,11 @@ void ViewBlobInternalsJob::GenerateHTMLForBlobData(const BlobData& blob_data,
}
break;
case BlobData::Item::TYPE_BLOB:
- AddHTMLListItem(kType, "blob", out);
- AddHTMLListItem(kURL, item.url().spec(), out);
+ NOTREACHED(); // Should be flattened in the storage context.
break;
case BlobData::Item::TYPE_FILE_FILESYSTEM:
AddHTMLListItem(kType, "filesystem", out);
- AddHTMLListItem(kURL, item.url().spec(), out);
+ AddHTMLListItem(kURL, item.filesystem_url().spec(), out);
if (!item.expected_modification_time().is_null()) {
AddHTMLListItem(kModificationTime, UTF16ToUTF8(
TimeFormatFriendlyDateAndTime(item.expected_modification_time())),
« no previous file with comments | « webkit/browser/blob/view_blob_internals_job.h ('k') | webkit/browser/fileapi/file_system_operation_impl_write_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698