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

Side by Side Diff: webkit/quota/quota_temporary_storage_evictor_unittest.cc

Issue 8070001: Use base::Callback in Quota related code. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: rebase Created 9 years, 2 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
« no previous file with comments | « webkit/quota/quota_temporary_storage_evictor.cc ('k') | webkit/quota/quota_types.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 "testing/gtest/include/gtest/gtest.h"
6
7 #include <list> 5 #include <list>
8 #include <map> 6 #include <map>
7 #include <utility>
9 8
10 #include "base/bind.h" 9 #include "base/bind.h"
11 #include "base/memory/scoped_ptr.h" 10 #include "base/memory/scoped_ptr.h"
12 #include "base/message_loop.h" 11 #include "base/message_loop.h"
13 #include "base/message_loop_proxy.h" 12 #include "base/message_loop_proxy.h"
14 #include "base/task.h" 13 #include "base/task.h"
14 #include "testing/gtest/include/gtest/gtest.h"
15 #include "webkit/quota/mock_storage_client.h" 15 #include "webkit/quota/mock_storage_client.h"
16 #include "webkit/quota/quota_manager.h" 16 #include "webkit/quota/quota_manager.h"
17 #include "webkit/quota/quota_temporary_storage_evictor.h" 17 #include "webkit/quota/quota_temporary_storage_evictor.h"
18 18
19 namespace quota { 19 namespace quota {
20 20
21 class QuotaTemporaryStorageEvictorTest; 21 class QuotaTemporaryStorageEvictorTest;
22 22
23 namespace { 23 namespace {
24 24
25 class MockQuotaEvictionHandler : public quota::QuotaEvictionHandler { 25 class MockQuotaEvictionHandler : public quota::QuotaEvictionHandler {
26 public: 26 public:
27 MockQuotaEvictionHandler(QuotaTemporaryStorageEvictorTest *test) 27 explicit MockQuotaEvictionHandler(QuotaTemporaryStorageEvictorTest *test)
28 : quota_(0), 28 : quota_(0),
29 unlimited_usage_(0), 29 unlimited_usage_(0),
30 available_space_(0), 30 available_space_(0),
31 error_on_evict_origin_data_(false), 31 error_on_evict_origin_data_(false),
32 error_on_get_usage_and_quota_(false), 32 error_on_get_usage_and_quota_(false),
33 test_(test) {} 33 test_(test) {}
34 34
35 virtual void EvictOriginData( 35 virtual void EvictOriginData(
36 const GURL& origin, 36 const GURL& origin,
37 StorageType type, 37 StorageType type,
38 EvictOriginDataCallback* callback) OVERRIDE { 38 const EvictOriginDataCallback& callback) OVERRIDE {
39 if (error_on_evict_origin_data_) { 39 if (error_on_evict_origin_data_) {
40 callback->Run(quota::kQuotaErrorInvalidModification); 40 callback.Run(quota::kQuotaErrorInvalidModification);
41 delete callback;
42 return; 41 return;
43 } 42 }
44 int64 origin_usage = EnsureOriginRemoved(origin); 43 int64 origin_usage = EnsureOriginRemoved(origin);
45 if (origin_usage >= 0) 44 if (origin_usage >= 0)
46 available_space_ += origin_usage; 45 available_space_ += origin_usage;
47 callback->Run(quota::kQuotaStatusOk); 46 callback.Run(quota::kQuotaStatusOk);
48 delete callback;
49 } 47 }
50 48
51 virtual void GetUsageAndQuotaForEviction( 49 virtual void GetUsageAndQuotaForEviction(
52 const GetUsageAndQuotaForEvictionCallback& callback) OVERRIDE { 50 const GetUsageAndQuotaForEvictionCallback& callback) OVERRIDE {
53 if (error_on_get_usage_and_quota_) { 51 if (error_on_get_usage_and_quota_) {
54 callback.Run(quota::kQuotaErrorInvalidAccess, QuotaAndUsage()); 52 callback.Run(quota::kQuotaErrorInvalidAccess, QuotaAndUsage());
55 return; 53 return;
56 } 54 }
57 if (task_for_get_usage_and_quota_.get()) 55 if (task_for_get_usage_and_quota_.get())
58 task_for_get_usage_and_quota_->Run(); 56 task_for_get_usage_and_quota_->Run();
(...skipping 371 matching lines...) Expand 10 before | Expand all | Expand 10 after
430 quota_eviction_handler()->set_available_space(1000000000); 428 quota_eviction_handler()->set_available_space(1000000000);
431 EXPECT_EQ(3000 + 200 + 500000, quota_eviction_handler()->GetUsage()); 429 EXPECT_EQ(3000 + 200 + 500000, quota_eviction_handler()->GetUsage());
432 set_repeated_eviction(false); 430 set_repeated_eviction(false);
433 temporary_storage_evictor()->Start(); 431 temporary_storage_evictor()->Start();
434 MessageLoop::current()->RunAllPending(); 432 MessageLoop::current()->RunAllPending();
435 // Nothing should have been evicted. 433 // Nothing should have been evicted.
436 EXPECT_EQ(3000 + 200 + 500000, quota_eviction_handler()->GetUsage()); 434 EXPECT_EQ(3000 + 200 + 500000, quota_eviction_handler()->GetUsage());
437 } 435 }
438 436
439 } // namespace quota 437 } // namespace quota
OLDNEW
« no previous file with comments | « webkit/quota/quota_temporary_storage_evictor.cc ('k') | webkit/quota/quota_types.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698