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

Unified Diff: chrome/browser/ui/webui/quota_internals_types.cc

Issue 7084024: Add chrome://quota-internals/ (Closed) Base URL: http://git.chromium.org/git/chromium.git@trunk
Patch Set: '' Created 9 years, 6 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: chrome/browser/ui/webui/quota_internals_types.cc
diff --git a/chrome/browser/ui/webui/quota_internals_types.cc b/chrome/browser/ui/webui/quota_internals_types.cc
new file mode 100644
index 0000000000000000000000000000000000000000..6db9bcb2acd4424278bd05fcab603dc1de7caac1
--- /dev/null
+++ b/chrome/browser/ui/webui/quota_internals_types.cc
@@ -0,0 +1,107 @@
+// Copyright (c) 2011 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include "chrome/browser/ui/webui/quota_internals_types.h"
+
+#include "base/logging.h"
+#include "base/memory/scoped_ptr.h"
+#include "base/values.h"
+#include "net/base/net_util.h"
+
+namespace {
+
+std::string StorageTypeToString(quota::StorageType type) {
+ switch (type) {
+ case quota::kStorageTypeTemporary:
+ return "temporary";
+ case quota::kStorageTypePersistent:
+ return "persistent";
+ default:
+ return "unknown";
+ }
+}
+
+} // anonymous namespace
+
+namespace quota_internals {
+
+GlobalData::GlobalData(quota::StorageType type,
+ int64 usage,
+ int64 unlimited_usage,
+ int64 quota)
+ : type_(type),
+ usage_(usage),
+ unlimited_usage_(unlimited_usage),
+ quota_(quota) {
+}
+
+Value* GlobalData::NewValue() const {
+ scoped_ptr<DictionaryValue> dict(new DictionaryValue);
+ dict->SetString("type", StorageTypeToString(type_));
+ if (usage_ >= 0)
+ dict->SetDouble("usage", static_cast<double>(usage_));
+ if (unlimited_usage_ >= 0)
+ dict->SetDouble("unlimitedUsage", static_cast<double>(unlimited_usage_));
+ if (quota_ >= 0)
+ dict->SetDouble("quota", static_cast<double>(quota_));
+ return dict.release();
+}
+
+HostData::HostData(const std::string& host,
+ quota::StorageType type,
+ int64 usage,
+ int64 quota)
+ : host_(host),
+ type_(type),
+ usage_(usage),
+ quota_(quota) {
+}
+
+Value* HostData::NewValue() const {
+ scoped_ptr<DictionaryValue> dict(new DictionaryValue);
+ DCHECK(!host_.empty());
+ dict->SetString("host", host_);
+ dict->SetString("type", StorageTypeToString(type_));
+ if (usage_ >= 0)
+ dict->SetDouble("usage", static_cast<double>(usage_));
+ if (quota_ >= 0)
+ dict->SetDouble("quota", static_cast<double>(quota_));
+ return dict.release();
+}
+
+OriginData::OriginData(const GURL& origin,
+ quota::StorageType type,
+ int in_use,
+ int used_count,
+ base::Time last_access_time,
+ base::Time last_modified_time)
+ : origin_(origin),
+ type_(type),
+ host_(net::GetHostOrSpecFromURL(origin)),
+ in_use_(in_use),
+ used_count_(used_count),
+ last_access_time_(last_access_time),
+ last_modified_time_(last_modified_time) {
+}
+
+Value* OriginData::NewValue() const {
+ scoped_ptr<DictionaryValue> dict(new DictionaryValue);
+ DCHECK(!origin_.is_empty());
+ DCHECK(!host_.empty());
+ dict->SetString("origin", origin_.spec());
+ dict->SetString("type", StorageTypeToString(type_));
+ dict->SetString("host", host_);
+ if (in_use_ >= 0)
+ dict->SetBoolean("inUse", in_use_ ? true : false);
+ if (used_count_ >= 0)
+ dict->SetInteger("usedCount", used_count_);
+ if (!last_access_time_.is_null())
+ dict->SetDouble("lastAccessTime", last_access_time_.ToDoubleT() * 1000.0);
+ if (!last_modified_time_.is_null())
+ dict->SetDouble("lastModifiedTime",
+ last_modified_time_.ToDoubleT() * 1000.0);
+ return dict.release();
+}
+
+} // namespace quota_internals

Powered by Google App Engine
This is Rietveld 408576698