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

Side by Side Diff: content/browser/quota/usage_tracker_unittest.cc

Issue 1159623009: content: Remove use of MessageLoopProxy and deprecated MessageLoop APIs (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Test build fix. Created 5 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
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 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 "base/bind.h" 5 #include "base/bind.h"
6 #include "base/location.h"
6 #include "base/run_loop.h" 7 #include "base/run_loop.h"
8 #include "base/single_thread_task_runner.h"
9 #include "base/thread_task_runner_handle.h"
7 #include "content/public/test/mock_special_storage_policy.h" 10 #include "content/public/test/mock_special_storage_policy.h"
8 #include "net/base/net_util.h" 11 #include "net/base/net_util.h"
9 #include "storage/browser/quota/usage_tracker.h" 12 #include "storage/browser/quota/usage_tracker.h"
10 #include "testing/gtest/include/gtest/gtest.h" 13 #include "testing/gtest/include/gtest/gtest.h"
11 14
12 using storage::kQuotaStatusOk; 15 using storage::kQuotaStatusOk;
13 using storage::kStorageTypeTemporary; 16 using storage::kStorageTypeTemporary;
14 using storage::QuotaClient; 17 using storage::QuotaClient;
15 using storage::QuotaClientList; 18 using storage::QuotaClientList;
16 using storage::SpecialStoragePolicy; 19 using storage::SpecialStoragePolicy;
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
49 52
50 ID id() const override { return kFileSystem; } 53 ID id() const override { return kFileSystem; }
51 54
52 void OnQuotaManagerDestroyed() override {} 55 void OnQuotaManagerDestroyed() override {}
53 56
54 void GetOriginUsage(const GURL& origin, 57 void GetOriginUsage(const GURL& origin,
55 StorageType type, 58 StorageType type,
56 const GetUsageCallback& callback) override { 59 const GetUsageCallback& callback) override {
57 EXPECT_EQ(kStorageTypeTemporary, type); 60 EXPECT_EQ(kStorageTypeTemporary, type);
58 int64 usage = GetUsage(origin); 61 int64 usage = GetUsage(origin);
59 base::MessageLoop::current()->PostTask(FROM_HERE, 62 base::ThreadTaskRunnerHandle::Get()->PostTask(FROM_HERE,
60 base::Bind(callback, usage)); 63 base::Bind(callback, usage));
61 } 64 }
62 65
63 void GetOriginsForType(StorageType type, 66 void GetOriginsForType(StorageType type,
64 const GetOriginsCallback& callback) override { 67 const GetOriginsCallback& callback) override {
65 EXPECT_EQ(kStorageTypeTemporary, type); 68 EXPECT_EQ(kStorageTypeTemporary, type);
66 std::set<GURL> origins; 69 std::set<GURL> origins;
67 for (UsageMap::const_iterator itr = usage_map_.begin(); 70 for (UsageMap::const_iterator itr = usage_map_.begin();
68 itr != usage_map_.end(); ++itr) { 71 itr != usage_map_.end(); ++itr) {
69 origins.insert(itr->first); 72 origins.insert(itr->first);
70 } 73 }
71 base::MessageLoop::current()->PostTask(FROM_HERE, 74 base::ThreadTaskRunnerHandle::Get()->PostTask(
72 base::Bind(callback, origins)); 75 FROM_HERE, base::Bind(callback, origins));
73 } 76 }
74 77
75 void GetOriginsForHost(StorageType type, 78 void GetOriginsForHost(StorageType type,
76 const std::string& host, 79 const std::string& host,
77 const GetOriginsCallback& callback) override { 80 const GetOriginsCallback& callback) override {
78 EXPECT_EQ(kStorageTypeTemporary, type); 81 EXPECT_EQ(kStorageTypeTemporary, type);
79 std::set<GURL> origins; 82 std::set<GURL> origins;
80 for (UsageMap::const_iterator itr = usage_map_.begin(); 83 for (UsageMap::const_iterator itr = usage_map_.begin();
81 itr != usage_map_.end(); ++itr) { 84 itr != usage_map_.end(); ++itr) {
82 if (net::GetHostOrSpecFromURL(itr->first) == host) 85 if (net::GetHostOrSpecFromURL(itr->first) == host)
83 origins.insert(itr->first); 86 origins.insert(itr->first);
84 } 87 }
85 base::MessageLoop::current()->PostTask(FROM_HERE, 88 base::ThreadTaskRunnerHandle::Get()->PostTask(
86 base::Bind(callback, origins)); 89 FROM_HERE, base::Bind(callback, origins));
87 } 90 }
88 91
89 void DeleteOriginData(const GURL& origin, 92 void DeleteOriginData(const GURL& origin,
90 StorageType type, 93 StorageType type,
91 const DeletionCallback& callback) override { 94 const DeletionCallback& callback) override {
92 EXPECT_EQ(kStorageTypeTemporary, type); 95 EXPECT_EQ(kStorageTypeTemporary, type);
93 usage_map_.erase(origin); 96 usage_map_.erase(origin);
94 base::MessageLoop::current()->PostTask( 97 base::ThreadTaskRunnerHandle::Get()->PostTask(
95 FROM_HERE, base::Bind(callback, kQuotaStatusOk)); 98 FROM_HERE, base::Bind(callback, kQuotaStatusOk));
96 } 99 }
97 100
98 bool DoesSupport(storage::StorageType type) const override { 101 bool DoesSupport(storage::StorageType type) const override {
99 return type == storage::kStorageTypeTemporary; 102 return type == storage::kStorageTypeTemporary;
100 } 103 }
101 104
102 int64 GetUsage(const GURL& origin) { 105 int64 GetUsage(const GURL& origin) {
103 UsageMap::const_iterator found = usage_map_.find(origin); 106 UsageMap::const_iterator found = usage_map_.find(origin);
104 if (found == usage_map_.end()) 107 if (found == usage_map_.end())
(...skipping 220 matching lines...) Expand 10 before | Expand all | Expand 10 after
325 328
326 GetGlobalLimitedUsage(&limited_usage); 329 GetGlobalLimitedUsage(&limited_usage);
327 GetGlobalUsage(&total_usage, &unlimited_usage); 330 GetGlobalUsage(&total_usage, &unlimited_usage);
328 EXPECT_EQ(1 + 16, limited_usage); 331 EXPECT_EQ(1 + 16, limited_usage);
329 EXPECT_EQ(1 + 2 + 16 + 32, total_usage); 332 EXPECT_EQ(1 + 2 + 16 + 32, total_usage);
330 EXPECT_EQ(2 + 32, unlimited_usage); 333 EXPECT_EQ(2 + 32, unlimited_usage);
331 } 334 }
332 335
333 336
334 } // namespace content 337 } // namespace content
OLDNEW
« no previous file with comments | « content/browser/quota/storage_monitor_unittest.cc ('k') | content/browser/renderer_host/compositor_impl_android.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698