OLD | NEW |
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 "content/public/test/mock_storage_client.h" | 5 #include "content/public/test/mock_storage_client.h" |
6 | 6 |
7 #include "base/basictypes.h" | 7 #include "base/basictypes.h" |
8 #include "base/bind.h" | 8 #include "base/bind.h" |
9 #include "base/memory/scoped_ptr.h" | 9 #include "base/memory/scoped_ptr.h" |
10 #include "base/memory/singleton.h" | 10 #include "base/memory/singleton.h" |
11 #include "base/message_loop/message_loop_proxy.h" | 11 #include "base/message_loop/message_loop_proxy.h" |
12 #include "base/stl_util.h" | 12 #include "base/stl_util.h" |
13 #include "net/base/net_util.h" | 13 #include "net/base/net_util.h" |
14 #include "webkit/browser/quota/quota_manager_proxy.h" | 14 #include "webkit/browser/quota/quota_manager_proxy.h" |
15 | 15 |
16 using quota::kQuotaErrorInvalidModification; | 16 using storage::kQuotaErrorInvalidModification; |
17 using quota::kQuotaStatusOk; | 17 using storage::kQuotaStatusOk; |
18 | 18 |
19 namespace content { | 19 namespace content { |
20 | 20 |
21 using std::make_pair; | 21 using std::make_pair; |
22 | 22 |
23 MockStorageClient::MockStorageClient( | 23 MockStorageClient::MockStorageClient( |
24 QuotaManagerProxy* quota_manager_proxy, | 24 QuotaManagerProxy* quota_manager_proxy, |
25 const MockOriginData* mock_data, QuotaClient::ID id, size_t mock_data_size) | 25 const MockOriginData* mock_data, QuotaClient::ID id, size_t mock_data_size) |
26 : quota_manager_proxy_(quota_manager_proxy), | 26 : quota_manager_proxy_(quota_manager_proxy), |
27 id_(id), | 27 id_(id), |
(...skipping 89 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
117 | 117 |
118 void MockStorageClient::DeleteOriginData( | 118 void MockStorageClient::DeleteOriginData( |
119 const GURL& origin, StorageType type, | 119 const GURL& origin, StorageType type, |
120 const DeletionCallback& callback) { | 120 const DeletionCallback& callback) { |
121 base::MessageLoopProxy::current()->PostTask( | 121 base::MessageLoopProxy::current()->PostTask( |
122 FROM_HERE, | 122 FROM_HERE, |
123 base::Bind(&MockStorageClient::RunDeleteOriginData, | 123 base::Bind(&MockStorageClient::RunDeleteOriginData, |
124 weak_factory_.GetWeakPtr(), origin, type, callback)); | 124 weak_factory_.GetWeakPtr(), origin, type, callback)); |
125 } | 125 } |
126 | 126 |
127 bool MockStorageClient::DoesSupport(quota::StorageType type) const { | 127 bool MockStorageClient::DoesSupport(storage::StorageType type) const { |
128 return true; | 128 return true; |
129 } | 129 } |
130 | 130 |
131 void MockStorageClient::RunGetOriginUsage( | 131 void MockStorageClient::RunGetOriginUsage( |
132 const GURL& origin_url, StorageType type, | 132 const GURL& origin_url, StorageType type, |
133 const GetUsageCallback& callback) { | 133 const GetUsageCallback& callback) { |
134 OriginDataMap::iterator find = origin_data_.find(make_pair(origin_url, type)); | 134 OriginDataMap::iterator find = origin_data_.find(make_pair(origin_url, type)); |
135 if (find == origin_data_.end()) { | 135 if (find == origin_data_.end()) { |
136 callback.Run(0); | 136 callback.Run(0); |
137 } else { | 137 } else { |
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
180 int64 delta = itr->second; | 180 int64 delta = itr->second; |
181 quota_manager_proxy_-> | 181 quota_manager_proxy_-> |
182 NotifyStorageModified(id(), origin_url, type, -delta); | 182 NotifyStorageModified(id(), origin_url, type, -delta); |
183 origin_data_.erase(itr); | 183 origin_data_.erase(itr); |
184 } | 184 } |
185 | 185 |
186 callback.Run(kQuotaStatusOk); | 186 callback.Run(kQuotaStatusOk); |
187 } | 187 } |
188 | 188 |
189 } // namespace content | 189 } // namespace content |
OLD | NEW |