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

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

Issue 12213066: Use base namespace for FilePath in content/browser (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 7 years, 10 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_path.h" 8 #include "base/file_path.h"
9 #include "base/file_util.h" 9 #include "base/file_util.h"
10 #include "base/files/scoped_temp_dir.h" 10 #include "base/files/scoped_temp_dir.h"
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after
48 io_thread_(BrowserThread::IO, &message_loop_) { 48 io_thread_(BrowserThread::IO, &message_loop_) {
49 browser_context_.reset(new TestBrowserContext()); 49 browser_context_.reset(new TestBrowserContext());
50 idb_context_ = static_cast<IndexedDBContextImpl*>( 50 idb_context_ = static_cast<IndexedDBContextImpl*>(
51 BrowserContext::GetDefaultStoragePartition(browser_context_.get())-> 51 BrowserContext::GetDefaultStoragePartition(browser_context_.get())->
52 GetIndexedDBContext()); 52 GetIndexedDBContext());
53 message_loop_.RunUntilIdle(); 53 message_loop_.RunUntilIdle();
54 setup_temp_dir(); 54 setup_temp_dir();
55 } 55 }
56 void setup_temp_dir() { 56 void setup_temp_dir() {
57 ASSERT_TRUE(temp_dir_.CreateUniqueTempDir()); 57 ASSERT_TRUE(temp_dir_.CreateUniqueTempDir());
58 FilePath indexeddb_dir = temp_dir_.path().Append( 58 base::FilePath indexeddb_dir = temp_dir_.path().Append(
59 IndexedDBContextImpl::kIndexedDBDirectory); 59 IndexedDBContextImpl::kIndexedDBDirectory);
60 ASSERT_TRUE(file_util::CreateDirectory(indexeddb_dir)); 60 ASSERT_TRUE(file_util::CreateDirectory(indexeddb_dir));
61 idb_context()->set_data_path_for_testing(indexeddb_dir); 61 idb_context()->set_data_path_for_testing(indexeddb_dir);
62 } 62 }
63 63
64 ~IndexedDBQuotaClientTest() { 64 ~IndexedDBQuotaClientTest() {
65 // IndexedDBContext needs to be destructed on 65 // IndexedDBContext needs to be destructed on
66 // BrowserThread::WEBKIT_DEPRECATED, which is also a member variable of this 66 // BrowserThread::WEBKIT_DEPRECATED, which is also a member variable of this
67 // class. Cause IndexedDBContext's destruction now to ensure that it 67 // class. Cause IndexedDBContext's destruction now to ensure that it
68 // doesn't outlive BrowserThread::WEBKIT_DEPRECATED. 68 // doesn't outlive BrowserThread::WEBKIT_DEPRECATED.
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after
118 client->DeleteOriginData( 118 client->DeleteOriginData(
119 origin_url, kTemp, 119 origin_url, kTemp,
120 base::Bind(&IndexedDBQuotaClientTest::OnDeleteOriginComplete, 120 base::Bind(&IndexedDBQuotaClientTest::OnDeleteOriginComplete,
121 weak_factory_.GetWeakPtr())); 121 weak_factory_.GetWeakPtr()));
122 MessageLoop::current()->RunUntilIdle(); 122 MessageLoop::current()->RunUntilIdle();
123 return delete_status_; 123 return delete_status_;
124 } 124 }
125 125
126 IndexedDBContextImpl* idb_context() { return idb_context_.get(); } 126 IndexedDBContextImpl* idb_context() { return idb_context_.get(); }
127 127
128 void SetFileSizeTo(const FilePath& path, int size) { 128 void SetFileSizeTo(const base::FilePath& path, int size) {
129 std::string junk(size, 'a'); 129 std::string junk(size, 'a');
130 ASSERT_EQ(size, file_util::WriteFile(path, junk.c_str(), size)); 130 ASSERT_EQ(size, file_util::WriteFile(path, junk.c_str(), size));
131 } 131 }
132 132
133 void AddFakeIndexedDB(const GURL& origin, int size) { 133 void AddFakeIndexedDB(const GURL& origin, int size) {
134 FilePath file_path_origin = idb_context()->GetFilePathForTesting( 134 base::FilePath file_path_origin = idb_context()->GetFilePathForTesting(
135 DatabaseUtil::GetOriginIdentifier(origin)); 135 DatabaseUtil::GetOriginIdentifier(origin));
136 if (!file_util::CreateDirectory(file_path_origin)) { 136 if (!file_util::CreateDirectory(file_path_origin)) {
137 LOG(ERROR) << "failed to file_util::CreateDirectory " 137 LOG(ERROR) << "failed to file_util::CreateDirectory "
138 << file_path_origin.value(); 138 << file_path_origin.value();
139 } 139 }
140 file_path_origin = file_path_origin.Append(FILE_PATH_LITERAL("fake_file")); 140 file_path_origin = file_path_origin.Append(FILE_PATH_LITERAL("fake_file"));
141 SetFileSizeTo(file_path_origin, size); 141 SetFileSizeTo(file_path_origin, size);
142 idb_context()->ResetCaches(); 142 idb_context()->ResetCaches();
143 } 143 }
144 144
(...skipping 99 matching lines...) Expand 10 before | Expand all | Expand 10 after
244 EXPECT_EQ(1000, GetOriginUsage(&client, kOriginA, kTemp)); 244 EXPECT_EQ(1000, GetOriginUsage(&client, kOriginA, kTemp));
245 EXPECT_EQ(50, GetOriginUsage(&client, kOriginB, kTemp)); 245 EXPECT_EQ(50, GetOriginUsage(&client, kOriginB, kTemp));
246 246
247 quota::QuotaStatusCode delete_status = DeleteOrigin(&client, kOriginA); 247 quota::QuotaStatusCode delete_status = DeleteOrigin(&client, kOriginA);
248 EXPECT_EQ(quota::kQuotaStatusOk, delete_status); 248 EXPECT_EQ(quota::kQuotaStatusOk, delete_status);
249 EXPECT_EQ(0, GetOriginUsage(&client, kOriginA, kTemp)); 249 EXPECT_EQ(0, GetOriginUsage(&client, kOriginA, kTemp));
250 EXPECT_EQ(50, GetOriginUsage(&client, kOriginB, kTemp)); 250 EXPECT_EQ(50, GetOriginUsage(&client, kOriginB, kTemp));
251 } 251 }
252 252
253 } // namespace content 253 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698