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

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

Issue 492873002: Collapse fileapi, webkit_blob, webkit_database, quota, and webkit_common namespaces into single sto… (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: fix chromeos build Created 6 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 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 <list> 5 #include <list>
6 #include <map> 6 #include <map>
7 #include <utility> 7 #include <utility>
8 8
9 #include "base/bind.h" 9 #include "base/bind.h"
10 #include "base/callback.h" 10 #include "base/callback.h"
11 #include "base/memory/scoped_ptr.h" 11 #include "base/memory/scoped_ptr.h"
12 #include "base/memory/weak_ptr.h" 12 #include "base/memory/weak_ptr.h"
13 #include "base/message_loop/message_loop_proxy.h" 13 #include "base/message_loop/message_loop_proxy.h"
14 #include "base/run_loop.h" 14 #include "base/run_loop.h"
15 #include "content/public/test/mock_storage_client.h" 15 #include "content/public/test/mock_storage_client.h"
16 #include "testing/gtest/include/gtest/gtest.h" 16 #include "testing/gtest/include/gtest/gtest.h"
17 #include "webkit/browser/quota/quota_manager.h" 17 #include "webkit/browser/quota/quota_manager.h"
18 #include "webkit/browser/quota/quota_temporary_storage_evictor.h" 18 #include "webkit/browser/quota/quota_temporary_storage_evictor.h"
19 19
20 using quota::QuotaTemporaryStorageEvictor; 20 using storage::QuotaTemporaryStorageEvictor;
21 using quota::StorageType; 21 using storage::StorageType;
22 using quota::UsageAndQuota; 22 using storage::UsageAndQuota;
23 23
24 namespace content { 24 namespace content {
25 25
26 class QuotaTemporaryStorageEvictorTest; 26 class QuotaTemporaryStorageEvictorTest;
27 27
28 namespace { 28 namespace {
29 29
30 class MockQuotaEvictionHandler : public quota::QuotaEvictionHandler { 30 class MockQuotaEvictionHandler : public storage::QuotaEvictionHandler {
31 public: 31 public:
32 explicit MockQuotaEvictionHandler(QuotaTemporaryStorageEvictorTest *test) 32 explicit MockQuotaEvictionHandler(QuotaTemporaryStorageEvictorTest *test)
33 : quota_(0), 33 : quota_(0),
34 available_space_(0), 34 available_space_(0),
35 error_on_evict_origin_data_(false), 35 error_on_evict_origin_data_(false),
36 error_on_get_usage_and_quota_(false) {} 36 error_on_get_usage_and_quota_(false) {}
37 37
38 virtual void EvictOriginData( 38 virtual void EvictOriginData(
39 const GURL& origin, 39 const GURL& origin,
40 StorageType type, 40 StorageType type,
41 const EvictOriginDataCallback& callback) OVERRIDE { 41 const EvictOriginDataCallback& callback) OVERRIDE {
42 if (error_on_evict_origin_data_) { 42 if (error_on_evict_origin_data_) {
43 callback.Run(quota::kQuotaErrorInvalidModification); 43 callback.Run(storage::kQuotaErrorInvalidModification);
44 return; 44 return;
45 } 45 }
46 int64 origin_usage = EnsureOriginRemoved(origin); 46 int64 origin_usage = EnsureOriginRemoved(origin);
47 if (origin_usage >= 0) 47 if (origin_usage >= 0)
48 available_space_ += origin_usage; 48 available_space_ += origin_usage;
49 callback.Run(quota::kQuotaStatusOk); 49 callback.Run(storage::kQuotaStatusOk);
50 } 50 }
51 51
52 virtual void GetUsageAndQuotaForEviction( 52 virtual void GetUsageAndQuotaForEviction(
53 const UsageAndQuotaCallback& callback) OVERRIDE { 53 const UsageAndQuotaCallback& callback) OVERRIDE {
54 if (error_on_get_usage_and_quota_) { 54 if (error_on_get_usage_and_quota_) {
55 callback.Run(quota::kQuotaErrorInvalidAccess, UsageAndQuota()); 55 callback.Run(storage::kQuotaErrorInvalidAccess, UsageAndQuota());
56 return; 56 return;
57 } 57 }
58 if (!task_for_get_usage_and_quota_.is_null()) 58 if (!task_for_get_usage_and_quota_.is_null())
59 task_for_get_usage_and_quota_.Run(); 59 task_for_get_usage_and_quota_.Run();
60 UsageAndQuota quota_and_usage(-1, GetUsage(), quota_, available_space_); 60 UsageAndQuota quota_and_usage(-1, GetUsage(), quota_, available_space_);
61 callback.Run(quota::kQuotaStatusOk, quota_and_usage); 61 callback.Run(storage::kQuotaStatusOk, quota_and_usage);
62 } 62 }
63 63
64 virtual void GetLRUOrigin( 64 virtual void GetLRUOrigin(
65 StorageType type, 65 StorageType type,
66 const GetLRUOriginCallback& callback) OVERRIDE { 66 const GetLRUOriginCallback& callback) OVERRIDE {
67 if (origin_order_.empty()) 67 if (origin_order_.empty())
68 callback.Run(GURL()); 68 callback.Run(GURL());
69 else 69 else
70 callback.Run(GURL(origin_order_.front())); 70 callback.Run(GURL(origin_order_.front()));
71 } 71 }
(...skipping 333 matching lines...) Expand 10 before | Expand all | Expand 10 after
405 EXPECT_EQ(150 + 300, quota_eviction_handler()->GetUsage()); 405 EXPECT_EQ(150 + 300, quota_eviction_handler()->GetUsage());
406 406
407 EXPECT_EQ(0, statistics().num_errors_on_evicting_origin); 407 EXPECT_EQ(0, statistics().num_errors_on_evicting_origin);
408 EXPECT_EQ(0, statistics().num_errors_on_getting_usage_and_quota); 408 EXPECT_EQ(0, statistics().num_errors_on_getting_usage_and_quota);
409 EXPECT_EQ(2, statistics().num_evicted_origins); 409 EXPECT_EQ(2, statistics().num_evicted_origins);
410 EXPECT_EQ(1, statistics().num_eviction_rounds); 410 EXPECT_EQ(1, statistics().num_eviction_rounds);
411 EXPECT_EQ(0, statistics().num_skipped_eviction_rounds); 411 EXPECT_EQ(0, statistics().num_skipped_eviction_rounds);
412 } 412 }
413 413
414 } // namespace content 414 } // namespace content
OLDNEW
« no previous file with comments | « content/browser/quota/quota_reservation_manager_unittest.cc ('k') | content/browser/quota/storage_monitor_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698