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: content/browser/in_process_webkit/indexed_db_quota_client_unittest.cc

Issue 7533013: Quota: Add quota::StorageType to the GetOriginsCallback definition. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Rebasing onto today's ToT. Created 9 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) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 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 <map> 5 #include <map>
6 6
7 #include "base/file_path.h" 7 #include "base/file_path.h"
8 #include "base/file_util.h" 8 #include "base/file_util.h"
9 #include "base/memory/scoped_callback_factory.h" 9 #include "base/memory/scoped_callback_factory.h"
10 #include "base/message_loop.h" 10 #include "base/message_loop.h"
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after
67 &IndexedDBQuotaClientTest::OnGetOriginUsageComplete)); 67 &IndexedDBQuotaClientTest::OnGetOriginUsageComplete));
68 MessageLoop::current()->RunAllPending(); 68 MessageLoop::current()->RunAllPending();
69 EXPECT_GT(usage_, -1); 69 EXPECT_GT(usage_, -1);
70 return usage_; 70 return usage_;
71 } 71 }
72 72
73 const std::set<GURL>& GetOriginsForType( 73 const std::set<GURL>& GetOriginsForType(
74 quota::QuotaClient* client, 74 quota::QuotaClient* client,
75 quota::StorageType type) { 75 quota::StorageType type) {
76 origins_.clear(); 76 origins_.clear();
77 type_ = quota::kStorageTypeTemporary;
77 client->GetOriginsForType(type, 78 client->GetOriginsForType(type,
78 callback_factory_.NewCallback( 79 callback_factory_.NewCallback(
79 &IndexedDBQuotaClientTest::OnGetOriginsComplete)); 80 &IndexedDBQuotaClientTest::OnGetOriginsComplete));
80 MessageLoop::current()->RunAllPending(); 81 MessageLoop::current()->RunAllPending();
81 return origins_; 82 return origins_;
82 } 83 }
83 84
84 const std::set<GURL>& GetOriginsForHost( 85 const std::set<GURL>& GetOriginsForHost(
85 quota::QuotaClient* client, 86 quota::QuotaClient* client,
86 quota::StorageType type, 87 quota::StorageType type,
87 const std::string& host) { 88 const std::string& host) {
88 origins_.clear(); 89 origins_.clear();
90 type_ = quota::kStorageTypeTemporary;
89 client->GetOriginsForHost(type, host, 91 client->GetOriginsForHost(type, host,
90 callback_factory_.NewCallback( 92 callback_factory_.NewCallback(
91 &IndexedDBQuotaClientTest::OnGetOriginsComplete)); 93 &IndexedDBQuotaClientTest::OnGetOriginsComplete));
92 MessageLoop::current()->RunAllPending(); 94 MessageLoop::current()->RunAllPending();
93 return origins_; 95 return origins_;
94 } 96 }
95 97
96 IndexedDBContext* idb_context() { return idb_context_.get(); } 98 IndexedDBContext* idb_context() { return idb_context_.get(); }
97 99
98 void SetFileSizeTo(const FilePath& path, int size) { 100 void SetFileSizeTo(const FilePath& path, int size) {
(...skipping 10 matching lines...) Expand all
109 } 111 }
110 file_path_origin = file_path_origin.Append(FILE_PATH_LITERAL("fake_file")); 112 file_path_origin = file_path_origin.Append(FILE_PATH_LITERAL("fake_file"));
111 SetFileSizeTo(file_path_origin, size); 113 SetFileSizeTo(file_path_origin, size);
112 } 114 }
113 115
114 private: 116 private:
115 void OnGetOriginUsageComplete(int64 usage) { 117 void OnGetOriginUsageComplete(int64 usage) {
116 usage_ = usage; 118 usage_ = usage;
117 } 119 }
118 120
119 void OnGetOriginsComplete(const std::set<GURL>& origins) { 121 void OnGetOriginsComplete(const std::set<GURL>& origins,
122 quota::StorageType type) {
120 origins_ = origins; 123 origins_ = origins;
124 type_ = type_;
121 } 125 }
122 126
123 ScopedTempDir temp_dir_; 127 ScopedTempDir temp_dir_;
124 int64 usage_; 128 int64 usage_;
125 std::set<GURL> origins_; 129 std::set<GURL> origins_;
130 quota::StorageType type_;
126 scoped_refptr<IndexedDBContext> idb_context_; 131 scoped_refptr<IndexedDBContext> idb_context_;
127 base::ScopedCallbackFactory<IndexedDBQuotaClientTest> callback_factory_; 132 base::ScopedCallbackFactory<IndexedDBQuotaClientTest> callback_factory_;
128 MessageLoop message_loop_; 133 MessageLoop message_loop_;
129 BrowserThread webkit_thread_; 134 BrowserThread webkit_thread_;
130 }; 135 };
131 136
132 137
133 TEST_F(IndexedDBQuotaClientTest, GetOriginUsage) { 138 TEST_F(IndexedDBQuotaClientTest, GetOriginUsage) {
134 IndexedDBQuotaClient client( 139 IndexedDBQuotaClient client(
135 base::MessageLoopProxy::CreateForCurrentThread(), 140 base::MessageLoopProxy::CreateForCurrentThread(),
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after
183 EXPECT_TRUE(GetOriginsForType(&client, kTemp).empty()); 188 EXPECT_TRUE(GetOriginsForType(&client, kTemp).empty());
184 EXPECT_TRUE(GetOriginsForType(&client, kPerm).empty()); 189 EXPECT_TRUE(GetOriginsForType(&client, kPerm).empty());
185 190
186 AddFakeIndexedDB(kOriginA, 1000); 191 AddFakeIndexedDB(kOriginA, 1000);
187 std::set<GURL> origins = GetOriginsForType(&client, kTemp); 192 std::set<GURL> origins = GetOriginsForType(&client, kTemp);
188 EXPECT_EQ(origins.size(), 1ul); 193 EXPECT_EQ(origins.size(), 1ul);
189 EXPECT_TRUE(origins.find(kOriginA) != origins.end()); 194 EXPECT_TRUE(origins.find(kOriginA) != origins.end());
190 195
191 EXPECT_TRUE(GetOriginsForType(&client, kPerm).empty()); 196 EXPECT_TRUE(GetOriginsForType(&client, kPerm).empty());
192 } 197 }
OLDNEW
« no previous file with comments | « content/browser/in_process_webkit/indexed_db_quota_client.cc ('k') | webkit/appcache/appcache_quota_client.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698