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

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

Issue 1549113002: Switch to standard integer types in content/browser/. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: rebase Created 4 years, 12 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
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 <stdint.h>
6
5 #include <map> 7 #include <map>
6 8
7 #include "base/bind.h" 9 #include "base/bind.h"
8 #include "base/files/file_path.h" 10 #include "base/files/file_path.h"
9 #include "base/files/file_util.h" 11 #include "base/files/file_util.h"
10 #include "base/files/scoped_temp_dir.h" 12 #include "base/files/scoped_temp_dir.h"
13 #include "base/macros.h"
11 #include "base/test/test_simple_task_runner.h" 14 #include "base/test/test_simple_task_runner.h"
12 #include "base/threading/thread.h" 15 #include "base/threading/thread.h"
13 #include "content/browser/browser_thread_impl.h" 16 #include "content/browser/browser_thread_impl.h"
14 #include "content/browser/indexed_db/indexed_db_context_impl.h" 17 #include "content/browser/indexed_db/indexed_db_context_impl.h"
15 #include "content/browser/indexed_db/indexed_db_quota_client.h" 18 #include "content/browser/indexed_db/indexed_db_quota_client.h"
16 #include "content/browser/quota/mock_quota_manager.h" 19 #include "content/browser/quota/mock_quota_manager.h"
17 #include "content/public/browser/storage_partition.h" 20 #include "content/public/browser/storage_partition.h"
18 #include "content/public/test/test_browser_context.h" 21 #include "content/public/test/test_browser_context.h"
19 #include "content/public/test/test_browser_thread_bundle.h" 22 #include "content/public/test/test_browser_thread_bundle.h"
20 #include "storage/common/database/database_identifier.h" 23 #include "storage/common/database/database_identifier.h"
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after
67 idb_context()->set_data_path_for_testing(indexeddb_dir); 70 idb_context()->set_data_path_for_testing(indexeddb_dir);
68 } 71 }
69 72
70 ~IndexedDBQuotaClientTest() override { 73 ~IndexedDBQuotaClientTest() override {
71 FlushIndexedDBTaskRunner(); 74 FlushIndexedDBTaskRunner();
72 idb_context_ = NULL; 75 idb_context_ = NULL;
73 browser_context_.reset(); 76 browser_context_.reset();
74 base::MessageLoop::current()->RunUntilIdle(); 77 base::MessageLoop::current()->RunUntilIdle();
75 } 78 }
76 79
77 int64 GetOriginUsage(storage::QuotaClient* client, 80 int64_t GetOriginUsage(storage::QuotaClient* client,
78 const GURL& origin, 81 const GURL& origin,
79 storage::StorageType type) { 82 storage::StorageType type) {
80 usage_ = -1; 83 usage_ = -1;
81 client->GetOriginUsage( 84 client->GetOriginUsage(
82 origin, 85 origin,
83 type, 86 type,
84 base::Bind(&IndexedDBQuotaClientTest::OnGetOriginUsageComplete, 87 base::Bind(&IndexedDBQuotaClientTest::OnGetOriginUsageComplete,
85 weak_factory_.GetWeakPtr())); 88 weak_factory_.GetWeakPtr()));
86 FlushIndexedDBTaskRunner(); 89 FlushIndexedDBTaskRunner();
87 base::MessageLoop::current()->RunUntilIdle(); 90 base::MessageLoop::current()->RunUntilIdle();
88 EXPECT_GT(usage_, -1); 91 EXPECT_GT(usage_, -1);
89 return usage_; 92 return usage_;
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after
141 if (!base::CreateDirectory(file_path_origin)) { 144 if (!base::CreateDirectory(file_path_origin)) {
142 LOG(ERROR) << "failed to base::CreateDirectory " 145 LOG(ERROR) << "failed to base::CreateDirectory "
143 << file_path_origin.value(); 146 << file_path_origin.value();
144 } 147 }
145 file_path_origin = file_path_origin.Append(FILE_PATH_LITERAL("fake_file")); 148 file_path_origin = file_path_origin.Append(FILE_PATH_LITERAL("fake_file"));
146 SetFileSizeTo(file_path_origin, size); 149 SetFileSizeTo(file_path_origin, size);
147 idb_context()->ResetCaches(); 150 idb_context()->ResetCaches();
148 } 151 }
149 152
150 private: 153 private:
151 void OnGetOriginUsageComplete(int64 usage) { usage_ = usage; } 154 void OnGetOriginUsageComplete(int64_t usage) { usage_ = usage; }
152 155
153 void OnGetOriginsComplete(const std::set<GURL>& origins) { 156 void OnGetOriginsComplete(const std::set<GURL>& origins) {
154 origins_ = origins; 157 origins_ = origins;
155 } 158 }
156 159
157 void OnDeleteOriginComplete(storage::QuotaStatusCode code) { 160 void OnDeleteOriginComplete(storage::QuotaStatusCode code) {
158 delete_status_ = code; 161 delete_status_ = code;
159 } 162 }
160 163
161 base::ScopedTempDir temp_dir_; 164 base::ScopedTempDir temp_dir_;
162 int64 usage_; 165 int64_t usage_;
163 std::set<GURL> origins_; 166 std::set<GURL> origins_;
164 scoped_refptr<base::TestSimpleTaskRunner> task_runner_; 167 scoped_refptr<base::TestSimpleTaskRunner> task_runner_;
165 scoped_refptr<IndexedDBContextImpl> idb_context_; 168 scoped_refptr<IndexedDBContextImpl> idb_context_;
166 content::TestBrowserThreadBundle thread_bundle_; 169 content::TestBrowserThreadBundle thread_bundle_;
167 scoped_ptr<TestBrowserContext> browser_context_; 170 scoped_ptr<TestBrowserContext> browser_context_;
168 storage::QuotaStatusCode delete_status_; 171 storage::QuotaStatusCode delete_status_;
169 base::WeakPtrFactory<IndexedDBQuotaClientTest> weak_factory_; 172 base::WeakPtrFactory<IndexedDBQuotaClientTest> weak_factory_;
170 173
171 DISALLOW_COPY_AND_ASSIGN(IndexedDBQuotaClientTest); 174 DISALLOW_COPY_AND_ASSIGN(IndexedDBQuotaClientTest);
172 }; 175 };
(...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after
234 EXPECT_EQ(1000, GetOriginUsage(&client, kOriginA, kTemp)); 237 EXPECT_EQ(1000, GetOriginUsage(&client, kOriginA, kTemp));
235 EXPECT_EQ(50, GetOriginUsage(&client, kOriginB, kTemp)); 238 EXPECT_EQ(50, GetOriginUsage(&client, kOriginB, kTemp));
236 239
237 storage::QuotaStatusCode delete_status = DeleteOrigin(&client, kOriginA); 240 storage::QuotaStatusCode delete_status = DeleteOrigin(&client, kOriginA);
238 EXPECT_EQ(storage::kQuotaStatusOk, delete_status); 241 EXPECT_EQ(storage::kQuotaStatusOk, delete_status);
239 EXPECT_EQ(0, GetOriginUsage(&client, kOriginA, kTemp)); 242 EXPECT_EQ(0, GetOriginUsage(&client, kOriginA, kTemp));
240 EXPECT_EQ(50, GetOriginUsage(&client, kOriginB, kTemp)); 243 EXPECT_EQ(50, GetOriginUsage(&client, kOriginB, kTemp));
241 } 244 }
242 245
243 } // namespace content 246 } // namespace content
OLDNEW
« no previous file with comments | « content/browser/indexed_db/indexed_db_quota_client.cc ('k') | content/browser/indexed_db/indexed_db_transaction.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698