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

Side by Side Diff: content/browser/indexed_db/indexed_db_quota_client_unittest.cc

Issue 16879013: Use chromium logic for database identifier<->origin conversions (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: remove webkit/base/origin_url_conversions Created 7 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 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/bind.h" 7 #include "base/bind.h"
8 #include "base/file_util.h" 8 #include "base/file_util.h"
9 #include "base/files/file_path.h" 9 #include "base/files/file_path.h"
10 #include "base/files/scoped_temp_dir.h" 10 #include "base/files/scoped_temp_dir.h"
11 #include "base/message_loop.h" 11 #include "base/message_loop.h"
12 #include "base/message_loop/message_loop_proxy.h" 12 #include "base/message_loop/message_loop_proxy.h"
13 #include "content/browser/browser_thread_impl.h" 13 #include "content/browser/browser_thread_impl.h"
14 #include "content/browser/indexed_db/indexed_db_context_impl.h" 14 #include "content/browser/indexed_db/indexed_db_context_impl.h"
15 #include "content/browser/indexed_db/indexed_db_quota_client.h" 15 #include "content/browser/indexed_db/indexed_db_quota_client.h"
16 #include "content/public/browser/storage_partition.h" 16 #include "content/public/browser/storage_partition.h"
17 #include "content/public/test/test_browser_context.h" 17 #include "content/public/test/test_browser_context.h"
18 #include "testing/gtest/include/gtest/gtest.h" 18 #include "testing/gtest/include/gtest/gtest.h"
19 #include "webkit/base/origin_url_conversions.h" 19 #include "webkit/common/database/database_identifier.h"
20 20
21 // Declared to shorten the line lengths. 21 // Declared to shorten the line lengths.
22 static const quota::StorageType kTemp = quota::kStorageTypeTemporary; 22 static const quota::StorageType kTemp = quota::kStorageTypeTemporary;
23 static const quota::StorageType kPerm = quota::kStorageTypePersistent; 23 static const quota::StorageType kPerm = quota::kStorageTypePersistent;
24 24
25 namespace content { 25 namespace content {
26 26
27 // Base class for our test fixtures. 27 // Base class for our test fixtures.
28 class IndexedDBQuotaClientTest : public testing::Test { 28 class IndexedDBQuotaClientTest : public testing::Test {
29 public: 29 public:
(...skipping 91 matching lines...) Expand 10 before | Expand all | Expand 10 after
121 121
122 IndexedDBContextImpl* idb_context() { return idb_context_.get(); } 122 IndexedDBContextImpl* idb_context() { return idb_context_.get(); }
123 123
124 void SetFileSizeTo(const base::FilePath& path, int size) { 124 void SetFileSizeTo(const base::FilePath& path, int size) {
125 std::string junk(size, 'a'); 125 std::string junk(size, 'a');
126 ASSERT_EQ(size, file_util::WriteFile(path, junk.c_str(), size)); 126 ASSERT_EQ(size, file_util::WriteFile(path, junk.c_str(), size));
127 } 127 }
128 128
129 void AddFakeIndexedDB(const GURL& origin, int size) { 129 void AddFakeIndexedDB(const GURL& origin, int size) {
130 base::FilePath file_path_origin = idb_context()->GetFilePathForTesting( 130 base::FilePath file_path_origin = idb_context()->GetFilePathForTesting(
131 webkit_base::GetOriginIdentifierFromURL(origin)); 131 webkit_database::GetIdentifierFromOrigin(origin));
132 if (!file_util::CreateDirectory(file_path_origin)) { 132 if (!file_util::CreateDirectory(file_path_origin)) {
133 LOG(ERROR) << "failed to file_util::CreateDirectory " 133 LOG(ERROR) << "failed to file_util::CreateDirectory "
134 << file_path_origin.value(); 134 << file_path_origin.value();
135 } 135 }
136 file_path_origin = file_path_origin.Append(FILE_PATH_LITERAL("fake_file")); 136 file_path_origin = file_path_origin.Append(FILE_PATH_LITERAL("fake_file"));
137 SetFileSizeTo(file_path_origin, size); 137 SetFileSizeTo(file_path_origin, size);
138 idb_context()->ResetCaches(); 138 idb_context()->ResetCaches();
139 } 139 }
140 140
141 private: 141 private:
(...skipping 89 matching lines...) Expand 10 before | Expand all | Expand 10 after
231 EXPECT_EQ(1000, GetOriginUsage(&client, kOriginA, kTemp)); 231 EXPECT_EQ(1000, GetOriginUsage(&client, kOriginA, kTemp));
232 EXPECT_EQ(50, GetOriginUsage(&client, kOriginB, kTemp)); 232 EXPECT_EQ(50, GetOriginUsage(&client, kOriginB, kTemp));
233 233
234 quota::QuotaStatusCode delete_status = DeleteOrigin(&client, kOriginA); 234 quota::QuotaStatusCode delete_status = DeleteOrigin(&client, kOriginA);
235 EXPECT_EQ(quota::kQuotaStatusOk, delete_status); 235 EXPECT_EQ(quota::kQuotaStatusOk, delete_status);
236 EXPECT_EQ(0, GetOriginUsage(&client, kOriginA, kTemp)); 236 EXPECT_EQ(0, GetOriginUsage(&client, kOriginA, kTemp));
237 EXPECT_EQ(50, GetOriginUsage(&client, kOriginB, kTemp)); 237 EXPECT_EQ(50, GetOriginUsage(&client, kOriginB, kTemp));
238 } 238 }
239 239
240 } // namespace content 240 } // namespace content
OLDNEW
« no previous file with comments | « content/browser/indexed_db/indexed_db_internals_ui.cc ('k') | content/browser/indexed_db/indexed_db_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698