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 StorageType type, |
26 GetOriginsCallback* callback) | 26 GetOriginsCallback callback) |
awong
2011/09/29 18:05:15
const &.
tzik
2011/10/11 04:53:57
Done.
| |
27 : QuotaThreadTask(manager, manager->io_thread_), | 27 : QuotaThreadTask(manager, manager->io_thread_), |
28 origins_(origins), | 28 origins_(origins), |
29 type_(type), | 29 type_(type), |
30 callback_(callback) {} | 30 callback_(callback) {} |
31 | 31 |
32 protected: | 32 protected: |
33 virtual void RunOnTargetThread() OVERRIDE {} | 33 virtual void RunOnTargetThread() OVERRIDE {} |
34 | 34 |
35 virtual void Completed() OVERRIDE { | 35 virtual void Completed() OVERRIDE { |
36 callback_->Run(origins_, type_); | 36 callback_.Run(origins_, type_); |
37 } | 37 } |
38 | 38 |
39 virtual void Aborted() OVERRIDE { | 39 virtual void Aborted() OVERRIDE { |
40 callback_->Run(std::set<GURL>(), type_); | 40 callback_.Run(std::set<GURL>(), type_); |
41 } | 41 } |
42 | 42 |
43 private: | 43 private: |
44 std::set<GURL> origins_; | 44 std::set<GURL> origins_; |
45 StorageType type_; | 45 StorageType type_; |
46 scoped_ptr<GetOriginsCallback> callback_; | 46 GetOriginsCallback callback_; |
47 | 47 |
48 DISALLOW_COPY_AND_ASSIGN(GetModifiedSinceTask); | 48 DISALLOW_COPY_AND_ASSIGN(GetModifiedSinceTask); |
49 }; | 49 }; |
50 | 50 |
51 class MockQuotaManager::DeleteOriginDataTask : public QuotaThreadTask { | 51 class MockQuotaManager::DeleteOriginDataTask : public QuotaThreadTask { |
52 public: | 52 public: |
53 DeleteOriginDataTask(MockQuotaManager* manager, | 53 DeleteOriginDataTask(MockQuotaManager* manager, |
54 StatusCallback* callback) | 54 StatusCallback callback) |
awong
2011/09/29 18:05:15
const &.
tzik
2011/10/11 04:53:57
Done.
| |
55 : QuotaThreadTask(manager, manager->io_thread_), | 55 : QuotaThreadTask(manager, manager->io_thread_), |
56 callback_(callback) {} | 56 callback_(callback) {} |
57 | 57 |
58 protected: | 58 protected: |
59 virtual void RunOnTargetThread() OVERRIDE {} | 59 virtual void RunOnTargetThread() OVERRIDE {} |
60 | 60 |
61 virtual void Completed() OVERRIDE { | 61 virtual void Completed() OVERRIDE { |
62 callback_->Run(quota::kQuotaStatusOk); | 62 callback_.Run(quota::kQuotaStatusOk); |
63 } | 63 } |
64 | 64 |
65 virtual void Aborted() OVERRIDE { | 65 virtual void Aborted() OVERRIDE { |
66 callback_->Run(quota::kQuotaErrorAbort); | 66 callback_.Run(quota::kQuotaErrorAbort); |
67 } | 67 } |
68 | 68 |
69 private: | 69 private: |
70 scoped_ptr<StatusCallback> callback_; | 70 StatusCallback callback_; |
71 | 71 |
72 DISALLOW_COPY_AND_ASSIGN(DeleteOriginDataTask); | 72 DISALLOW_COPY_AND_ASSIGN(DeleteOriginDataTask); |
73 }; | 73 }; |
74 | 74 |
75 MockQuotaManager::OriginInfo::OriginInfo( | 75 MockQuotaManager::OriginInfo::OriginInfo( |
76 const GURL& origin, | 76 const GURL& origin, |
77 StorageType type, | 77 StorageType type, |
78 base::Time modified) | 78 base::Time modified) |
79 : origin(origin), | 79 : origin(origin), |
80 type(type), | 80 type(type), |
(...skipping 23 matching lines...) Expand all Loading... | |
104 for (std::vector<OriginInfo>::const_iterator current = origins_.begin(); | 104 for (std::vector<OriginInfo>::const_iterator current = origins_.begin(); |
105 current != origins_.end(); | 105 current != origins_.end(); |
106 ++current) { | 106 ++current) { |
107 if (current->origin == origin && current->type == type) | 107 if (current->origin == origin && current->type == type) |
108 return true; | 108 return true; |
109 } | 109 } |
110 return false; | 110 return false; |
111 } | 111 } |
112 | 112 |
113 void MockQuotaManager::GetOriginsModifiedSince(StorageType type, | 113 void MockQuotaManager::GetOriginsModifiedSince(StorageType type, |
114 base::Time modified_since, GetOriginsCallback* callback) { | 114 base::Time modified_since, GetOriginsCallback callback) { |
awong
2011/09/29 18:05:15
const &.
tzik
2011/10/11 04:53:57
Done.
| |
115 std::set<GURL> origins_to_return; | 115 std::set<GURL> origins_to_return; |
116 for (std::vector<OriginInfo>::const_iterator current = origins_.begin(); | 116 for (std::vector<OriginInfo>::const_iterator current = origins_.begin(); |
117 current != origins_.end(); | 117 current != origins_.end(); |
118 ++current) { | 118 ++current) { |
119 if (current->type == type && current->modified >= modified_since) | 119 if (current->type == type && current->modified >= modified_since) |
120 origins_to_return.insert(current->origin); | 120 origins_to_return.insert(current->origin); |
121 } | 121 } |
122 make_scoped_refptr(new GetModifiedSinceTask(this, origins_to_return, type, | 122 make_scoped_refptr(new GetModifiedSinceTask(this, origins_to_return, type, |
123 callback))->Start(); | 123 callback))->Start(); |
124 } | 124 } |
125 | 125 |
126 void MockQuotaManager::DeleteOriginData(const GURL& origin, StorageType type, | 126 void MockQuotaManager::DeleteOriginData(const GURL& origin, StorageType type, |
127 StatusCallback* callback) { | 127 StatusCallback callback) { |
awong
2011/09/29 18:05:15
const &.
tzik
2011/10/11 04:53:57
Done.
| |
128 for (std::vector<OriginInfo>::iterator current = origins_.begin(); | 128 for (std::vector<OriginInfo>::iterator current = origins_.begin(); |
129 current != origins_.end(); | 129 current != origins_.end(); |
130 ++current) { | 130 ++current) { |
131 if (current->origin == origin && current->type == type) { | 131 if (current->origin == origin && current->type == type) { |
132 origins_.erase(current); | 132 origins_.erase(current); |
133 break; | 133 break; |
134 } | 134 } |
135 } | 135 } |
136 make_scoped_refptr(new DeleteOriginDataTask(this, callback))->Start(); | 136 make_scoped_refptr(new DeleteOriginDataTask(this, callback))->Start(); |
137 } | 137 } |
138 | 138 |
139 } // namespace quota | 139 } // namespace quota |
OLD | NEW |