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

Side by Side Diff: content/browser/devtools/renderer_overrides_handler.cc

Issue 492873002: Collapse fileapi, webkit_blob, webkit_database, quota, and webkit_common namespaces into single sto… (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: fix chromeos build Created 6 years, 4 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 | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2013 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 "content/browser/devtools/renderer_overrides_handler.h" 5 #include "content/browser/devtools/renderer_overrides_handler.h"
6 6
7 #include <map> 7 #include <map>
8 #include <string> 8 #include <string>
9 9
10 #include "base/barrier_closure.h" 10 #include "base/barrier_closure.h"
(...skipping 714 matching lines...) Expand 10 before | Expand all | Expand 10 after
725 const std::string& client_id, 725 const std::string& client_id,
726 const base::Closure& barrier, 726 const base::Closure& barrier,
727 int64 value) { 727 int64 value) {
728 base::DictionaryValue* usage_item = new base::DictionaryValue; 728 base::DictionaryValue* usage_item = new base::DictionaryValue;
729 usage_item->SetString(devtools::Page::UsageItem::kParamId, client_id); 729 usage_item->SetString(devtools::Page::UsageItem::kParamId, client_id);
730 usage_item->SetDouble(devtools::Page::UsageItem::kParamValue, value); 730 usage_item->SetDouble(devtools::Page::UsageItem::kParamValue, value);
731 list->Append(usage_item); 731 list->Append(usage_item);
732 barrier.Run(); 732 barrier.Run();
733 } 733 }
734 734
735 void DidGetQuotaValue( 735 void DidGetQuotaValue(base::DictionaryValue* dictionary,
736 base::DictionaryValue* dictionary, 736 const std::string& item_name,
737 const std::string& item_name, 737 const base::Closure& barrier,
738 const base::Closure& barrier, 738 storage::QuotaStatusCode status,
739 quota::QuotaStatusCode status, 739 int64 value) {
740 int64 value) { 740 if (status == storage::kQuotaStatusOk)
741 if (status == quota::kQuotaStatusOk)
742 dictionary->SetDouble(item_name, value); 741 dictionary->SetDouble(item_name, value);
743 barrier.Run(); 742 barrier.Run();
744 } 743 }
745 744
746 void DidGetUsageAndQuotaForWebApps( 745 void DidGetUsageAndQuotaForWebApps(base::DictionaryValue* quota,
747 base::DictionaryValue* quota, 746 const std::string& item_name,
748 const std::string& item_name, 747 const base::Closure& barrier,
749 const base::Closure& barrier, 748 storage::QuotaStatusCode status,
750 quota::QuotaStatusCode status, 749 int64 used_bytes,
751 int64 used_bytes, 750 int64 quota_in_bytes) {
752 int64 quota_in_bytes) { 751 if (status == storage::kQuotaStatusOk)
753 if (status == quota::kQuotaStatusOk)
754 quota->SetDouble(item_name, quota_in_bytes); 752 quota->SetDouble(item_name, quota_in_bytes);
755 barrier.Run(); 753 barrier.Run();
756 } 754 }
757 755
758 std::string GetStorageTypeName(quota::StorageType type) { 756 std::string GetStorageTypeName(storage::StorageType type) {
759 switch (type) { 757 switch (type) {
760 case quota::kStorageTypeTemporary: 758 case storage::kStorageTypeTemporary:
761 return devtools::Page::Usage::kParamTemporary; 759 return devtools::Page::Usage::kParamTemporary;
762 case quota::kStorageTypePersistent: 760 case storage::kStorageTypePersistent:
763 return devtools::Page::Usage::kParamPersistent; 761 return devtools::Page::Usage::kParamPersistent;
764 case quota::kStorageTypeSyncable: 762 case storage::kStorageTypeSyncable:
765 return devtools::Page::Usage::kParamSyncable; 763 return devtools::Page::Usage::kParamSyncable;
766 case quota::kStorageTypeQuotaNotManaged: 764 case storage::kStorageTypeQuotaNotManaged:
767 case quota::kStorageTypeUnknown: 765 case storage::kStorageTypeUnknown:
768 NOTREACHED(); 766 NOTREACHED();
769 } 767 }
770 return ""; 768 return "";
771 } 769 }
772 770
773 std::string GetQuotaClientName(quota::QuotaClient::ID id) { 771 std::string GetQuotaClientName(storage::QuotaClient::ID id) {
774 switch (id) { 772 switch (id) {
775 case quota::QuotaClient::kFileSystem: 773 case storage::QuotaClient::kFileSystem:
776 return devtools::Page::UsageItem::Id::kEnumFilesystem; 774 return devtools::Page::UsageItem::Id::kEnumFilesystem;
777 case quota::QuotaClient::kDatabase: 775 case storage::QuotaClient::kDatabase:
778 return devtools::Page::UsageItem::Id::kEnumDatabase; 776 return devtools::Page::UsageItem::Id::kEnumDatabase;
779 case quota::QuotaClient::kAppcache: 777 case storage::QuotaClient::kAppcache:
780 return devtools::Page::UsageItem::Id::kEnumAppcache; 778 return devtools::Page::UsageItem::Id::kEnumAppcache;
781 case quota::QuotaClient::kIndexedDatabase: 779 case storage::QuotaClient::kIndexedDatabase:
782 return devtools::Page::UsageItem::Id::kEnumIndexeddatabase; 780 return devtools::Page::UsageItem::Id::kEnumIndexeddatabase;
783 default: 781 default:
784 NOTREACHED(); 782 NOTREACHED();
785 } 783 }
786 return ""; 784 return "";
787 } 785 }
788 786
789 void QueryUsageAndQuotaOnIOThread( 787 void QueryUsageAndQuotaOnIOThread(
790 scoped_refptr<quota::QuotaManager> quota_manager, 788 scoped_refptr<storage::QuotaManager> quota_manager,
791 const GURL& security_origin, 789 const GURL& security_origin,
792 const ResponseCallback& callback) { 790 const ResponseCallback& callback) {
793 scoped_ptr<base::DictionaryValue> quota(new base::DictionaryValue); 791 scoped_ptr<base::DictionaryValue> quota(new base::DictionaryValue);
794 scoped_ptr<base::DictionaryValue> usage(new base::DictionaryValue); 792 scoped_ptr<base::DictionaryValue> usage(new base::DictionaryValue);
795 793
796 static quota::QuotaClient::ID kQuotaClients[] = { 794 static storage::QuotaClient::ID kQuotaClients[] = {
797 quota::QuotaClient::kFileSystem, 795 storage::QuotaClient::kFileSystem, storage::QuotaClient::kDatabase,
798 quota::QuotaClient::kDatabase, 796 storage::QuotaClient::kAppcache, storage::QuotaClient::kIndexedDatabase};
799 quota::QuotaClient::kAppcache,
800 quota::QuotaClient::kIndexedDatabase
801 };
802 797
803 static const size_t kStorageTypeCount = quota::kStorageTypeUnknown; 798 static const size_t kStorageTypeCount = storage::kStorageTypeUnknown;
804 std::map<quota::StorageType, base::ListValue*> storage_type_lists; 799 std::map<storage::StorageType, base::ListValue*> storage_type_lists;
805 800
806 for (size_t i = 0; i != kStorageTypeCount; i++) { 801 for (size_t i = 0; i != kStorageTypeCount; i++) {
807 const quota::StorageType type = static_cast<quota::StorageType>(i); 802 const storage::StorageType type = static_cast<storage::StorageType>(i);
808 if (type == quota::kStorageTypeQuotaNotManaged) 803 if (type == storage::kStorageTypeQuotaNotManaged)
809 continue; 804 continue;
810 storage_type_lists[type] = new base::ListValue; 805 storage_type_lists[type] = new base::ListValue;
811 usage->Set(GetStorageTypeName(type), storage_type_lists[type]); 806 usage->Set(GetStorageTypeName(type), storage_type_lists[type]);
812 } 807 }
813 808
814 const int kExpectedResults = 809 const int kExpectedResults =
815 2 + arraysize(kQuotaClients) * storage_type_lists.size(); 810 2 + arraysize(kQuotaClients) * storage_type_lists.size();
816 base::DictionaryValue* quota_raw_ptr = quota.get(); 811 base::DictionaryValue* quota_raw_ptr = quota.get();
817 812
818 // Takes ownership on usage and quota. 813 // Takes ownership on usage and quota.
819 base::Closure barrier = BarrierClosure( 814 base::Closure barrier = BarrierClosure(
820 kExpectedResults, 815 kExpectedResults,
821 base::Bind(&QueryUsageAndQuotaCompletedOnIOThread, 816 base::Bind(&QueryUsageAndQuotaCompletedOnIOThread,
822 base::Passed(&quota), 817 base::Passed(&quota),
823 base::Passed(&usage), 818 base::Passed(&usage),
824 callback)); 819 callback));
825 std::string host = net::GetHostOrSpecFromURL(security_origin); 820 std::string host = net::GetHostOrSpecFromURL(security_origin);
826 821
827 quota_manager->GetUsageAndQuotaForWebApps( 822 quota_manager->GetUsageAndQuotaForWebApps(
828 security_origin, 823 security_origin,
829 quota::kStorageTypeTemporary, 824 storage::kStorageTypeTemporary,
830 base::Bind(&DidGetUsageAndQuotaForWebApps, quota_raw_ptr, 825 base::Bind(&DidGetUsageAndQuotaForWebApps,
831 std::string(devtools::Page::Quota::kParamTemporary), barrier)); 826 quota_raw_ptr,
827 std::string(devtools::Page::Quota::kParamTemporary),
828 barrier));
832 829
833 quota_manager->GetPersistentHostQuota( 830 quota_manager->GetPersistentHostQuota(
834 host, 831 host,
835 base::Bind(&DidGetQuotaValue, quota_raw_ptr, 832 base::Bind(&DidGetQuotaValue, quota_raw_ptr,
836 std::string(devtools::Page::Quota::kParamPersistent), 833 std::string(devtools::Page::Quota::kParamPersistent),
837 barrier)); 834 barrier));
838 835
839 for (size_t i = 0; i != arraysize(kQuotaClients); i++) { 836 for (size_t i = 0; i != arraysize(kQuotaClients); i++) {
840 std::map<quota::StorageType, base::ListValue*>::const_iterator iter; 837 std::map<storage::StorageType, base::ListValue*>::const_iterator iter;
841 for (iter = storage_type_lists.begin(); 838 for (iter = storage_type_lists.begin();
842 iter != storage_type_lists.end(); ++iter) { 839 iter != storage_type_lists.end(); ++iter) {
843 const quota::StorageType type = (*iter).first; 840 const storage::StorageType type = (*iter).first;
844 if (!quota_manager->IsTrackingHostUsage(type, kQuotaClients[i])) { 841 if (!quota_manager->IsTrackingHostUsage(type, kQuotaClients[i])) {
845 barrier.Run(); 842 barrier.Run();
846 continue; 843 continue;
847 } 844 }
848 quota_manager->GetHostUsage( 845 quota_manager->GetHostUsage(
849 host, type, kQuotaClients[i], 846 host, type, kQuotaClients[i],
850 base::Bind(&DidGetHostUsage, (*iter).second, 847 base::Bind(&DidGetHostUsage, (*iter).second,
851 GetQuotaClientName(kQuotaClients[i]), 848 GetQuotaClientName(kQuotaClients[i]),
852 barrier)); 849 barrier));
853 } 850 }
(...skipping 15 matching lines...) Expand all
869 } 866 }
870 867
871 ResponseCallback callback = base::Bind( 868 ResponseCallback callback = base::Bind(
872 &RendererOverridesHandler::PageQueryUsageAndQuotaCompleted, 869 &RendererOverridesHandler::PageQueryUsageAndQuotaCompleted,
873 weak_factory_.GetWeakPtr(), 870 weak_factory_.GetWeakPtr(),
874 command); 871 command);
875 872
876 if (!host_) 873 if (!host_)
877 return command->InternalErrorResponse("Could not connect to view"); 874 return command->InternalErrorResponse("Could not connect to view");
878 875
879 scoped_refptr<quota::QuotaManager> quota_manager = 876 scoped_refptr<storage::QuotaManager> quota_manager =
880 host_->GetProcess()->GetStoragePartition()->GetQuotaManager(); 877 host_->GetProcess()->GetStoragePartition()->GetQuotaManager();
881 878
882 BrowserThread::PostTask( 879 BrowserThread::PostTask(
883 BrowserThread::IO, FROM_HERE, 880 BrowserThread::IO, FROM_HERE,
884 base::Bind( 881 base::Bind(
885 &QueryUsageAndQuotaOnIOThread, 882 &QueryUsageAndQuotaOnIOThread,
886 quota_manager, 883 quota_manager,
887 GURL(security_origin), 884 GURL(security_origin),
888 callback)); 885 callback));
889 886
(...skipping 389 matching lines...) Expand 10 before | Expand all | Expand 10 after
1279 return; 1276 return;
1280 bool enabled = touch_emulation_enabled_ || screencast_command_; 1277 bool enabled = touch_emulation_enabled_ || screencast_command_;
1281 host_->SetTouchEventEmulationEnabled(enabled); 1278 host_->SetTouchEventEmulationEnabled(enabled);
1282 WebContentsImpl* web_contents = static_cast<WebContentsImpl*>( 1279 WebContentsImpl* web_contents = static_cast<WebContentsImpl*>(
1283 WebContents::FromRenderViewHost(host_)); 1280 WebContents::FromRenderViewHost(host_));
1284 if (web_contents) 1281 if (web_contents)
1285 web_contents->SetForceDisableOverscrollContent(enabled); 1282 web_contents->SetForceDisableOverscrollContent(enabled);
1286 } 1283 }
1287 1284
1288 } // namespace content 1285 } // namespace content
OLDNEW
« no previous file with comments | « content/browser/databases_table_unittest.cc ('k') | content/browser/dom_storage/dom_storage_area.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698