OLD | NEW |
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 "webkit/quota/mock_quota_manager.h" | 5 #include "webkit/quota/mock_quota_manager.h" |
6 | 6 |
7 #include <set> | 7 #include <set> |
8 #include <string> | 8 #include <string> |
9 #include <vector> | 9 #include <vector> |
10 | 10 |
11 #include "base/memory/ref_counted.h" | 11 #include "base/memory/ref_counted.h" |
12 #include "base/memory/scoped_ptr.h" | 12 #include "base/memory/scoped_ptr.h" |
13 #include "googleurl/src/gurl.h" | 13 #include "googleurl/src/gurl.h" |
14 #include "webkit/quota/quota_client.h" | 14 #include "webkit/quota/quota_client.h" |
15 #include "webkit/quota/quota_manager.h" | 15 #include "webkit/quota/quota_manager.h" |
16 #include "webkit/quota/quota_task.h" | 16 #include "webkit/quota/quota_task.h" |
17 #include "webkit/quota/quota_types.h" | 17 #include "webkit/quota/quota_types.h" |
18 | 18 |
19 namespace quota { | 19 namespace quota { |
20 | 20 |
21 class MockQuotaManager::GetModifiedSinceTask : public QuotaThreadTask { | 21 class MockQuotaManager::GetModifiedSinceTask : public QuotaThreadTask { |
22 public: | 22 public: |
23 GetModifiedSinceTask(MockQuotaManager* manager, | 23 GetModifiedSinceTask(MockQuotaManager* manager, |
24 const std::set<GURL>& origins, | 24 const std::set<GURL>& origins, |
| 25 StorageType type, |
25 GetOriginsCallback* callback) | 26 GetOriginsCallback* callback) |
26 : QuotaThreadTask(manager, manager->io_thread_), | 27 : QuotaThreadTask(manager, manager->io_thread_), |
27 origins_(origins), | 28 origins_(origins), |
| 29 type_(type), |
28 callback_(callback) {} | 30 callback_(callback) {} |
29 | 31 |
30 protected: | 32 protected: |
31 virtual void RunOnTargetThread() OVERRIDE {} | 33 virtual void RunOnTargetThread() OVERRIDE {} |
32 | 34 |
33 virtual void Completed() OVERRIDE { | 35 virtual void Completed() OVERRIDE { |
34 callback_->Run(origins_); | 36 callback_->Run(origins_, type_); |
35 } | 37 } |
36 | 38 |
37 virtual void Aborted() OVERRIDE { | 39 virtual void Aborted() OVERRIDE { |
38 callback_->Run(std::set<GURL>()); | 40 callback_->Run(std::set<GURL>(), type_); |
39 } | 41 } |
40 | 42 |
41 private: | 43 private: |
42 std::set<GURL> origins_; | 44 std::set<GURL> origins_; |
| 45 StorageType type_; |
43 scoped_ptr<GetOriginsCallback> callback_; | 46 scoped_ptr<GetOriginsCallback> callback_; |
44 | 47 |
45 DISALLOW_COPY_AND_ASSIGN(GetModifiedSinceTask); | 48 DISALLOW_COPY_AND_ASSIGN(GetModifiedSinceTask); |
46 }; | 49 }; |
47 | 50 |
48 class MockQuotaManager::DeleteOriginDataTask : public QuotaThreadTask { | 51 class MockQuotaManager::DeleteOriginDataTask : public QuotaThreadTask { |
49 public: | 52 public: |
50 DeleteOriginDataTask(MockQuotaManager* manager, | 53 DeleteOriginDataTask(MockQuotaManager* manager, |
51 StatusCallback* callback) | 54 StatusCallback* callback) |
52 : QuotaThreadTask(manager, manager->io_thread_), | 55 : QuotaThreadTask(manager, manager->io_thread_), |
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
109 | 112 |
110 void MockQuotaManager::GetOriginsModifiedSince(StorageType type, | 113 void MockQuotaManager::GetOriginsModifiedSince(StorageType type, |
111 base::Time modified_since, GetOriginsCallback* callback) { | 114 base::Time modified_since, GetOriginsCallback* callback) { |
112 std::set<GURL> origins_to_return; | 115 std::set<GURL> origins_to_return; |
113 for (std::vector<OriginInfo>::const_iterator current = origins_.begin(); | 116 for (std::vector<OriginInfo>::const_iterator current = origins_.begin(); |
114 current != origins_.end(); | 117 current != origins_.end(); |
115 ++current) { | 118 ++current) { |
116 if (current->type == type && current->modified >= modified_since) | 119 if (current->type == type && current->modified >= modified_since) |
117 origins_to_return.insert(current->origin); | 120 origins_to_return.insert(current->origin); |
118 } | 121 } |
119 make_scoped_refptr(new GetModifiedSinceTask(this, origins_to_return, | 122 make_scoped_refptr(new GetModifiedSinceTask(this, origins_to_return, type, |
120 callback))->Start(); | 123 callback))->Start(); |
121 } | 124 } |
122 | 125 |
123 void MockQuotaManager::DeleteOriginData(const GURL& origin, StorageType type, | 126 void MockQuotaManager::DeleteOriginData(const GURL& origin, StorageType type, |
124 StatusCallback* callback) { | 127 StatusCallback* callback) { |
125 for (std::vector<OriginInfo>::iterator current = origins_.begin(); | 128 for (std::vector<OriginInfo>::iterator current = origins_.begin(); |
126 current != origins_.end(); | 129 current != origins_.end(); |
127 ++current) { | 130 ++current) { |
128 if (current->origin == origin && current->type == type) { | 131 if (current->origin == origin && current->type == type) { |
129 origins_.erase(current); | 132 origins_.erase(current); |
130 break; | 133 break; |
131 } | 134 } |
132 } | 135 } |
133 make_scoped_refptr(new DeleteOriginDataTask(this, callback))->Start(); | 136 make_scoped_refptr(new DeleteOriginDataTask(this, callback))->Start(); |
134 } | 137 } |
135 | 138 |
136 } // namespace quota | 139 } // namespace quota |
OLD | NEW |