OLD | NEW |
(Empty) | |
| 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 |
| 3 // found in the LICENSE file. |
| 4 |
| 5 #include "webkit/browser/quota/mock_quota_manager_proxy.h" |
| 6 |
| 7 #include "base/message_loop/message_loop.h" |
| 8 #include "base/single_thread_task_runner.h" |
| 9 #include "url/gurl.h" |
| 10 |
| 11 namespace quota { |
| 12 |
| 13 MockQuotaManagerProxy::MockQuotaManagerProxy( |
| 14 MockQuotaManager* quota_manager, |
| 15 base::SingleThreadTaskRunner* task_runner) |
| 16 : QuotaManagerProxy(quota_manager, task_runner), |
| 17 storage_accessed_count_(0), |
| 18 storage_modified_count_(0), |
| 19 last_notified_type_(kStorageTypeUnknown), |
| 20 last_notified_delta_(0), |
| 21 registered_client_(NULL) {} |
| 22 |
| 23 void MockQuotaManagerProxy::RegisterClient(QuotaClient* client) { |
| 24 DCHECK(!registered_client_); |
| 25 registered_client_ = client; |
| 26 } |
| 27 |
| 28 void MockQuotaManagerProxy::SimulateQuotaManagerDestroyed() { |
| 29 if (registered_client_) { |
| 30 // We cannot call this in the destructor as the client (indirectly) |
| 31 // holds a refptr of the proxy. |
| 32 registered_client_->OnQuotaManagerDestroyed(); |
| 33 registered_client_ = NULL; |
| 34 } |
| 35 } |
| 36 |
| 37 void MockQuotaManagerProxy::NotifyStorageAccessed( |
| 38 QuotaClient::ID client_id, const GURL& origin, StorageType type) { |
| 39 ++storage_accessed_count_; |
| 40 last_notified_origin_ = origin; |
| 41 last_notified_type_ = type; |
| 42 } |
| 43 |
| 44 void MockQuotaManagerProxy::NotifyStorageModified( |
| 45 QuotaClient::ID client_id, const GURL& origin, |
| 46 StorageType type, int64 delta) { |
| 47 ++storage_modified_count_; |
| 48 last_notified_origin_ = origin; |
| 49 last_notified_type_ = type; |
| 50 last_notified_delta_ = delta; |
| 51 if (mock_manager()) |
| 52 mock_manager()->UpdateUsage(origin, type, delta); |
| 53 } |
| 54 |
| 55 MockQuotaManagerProxy::~MockQuotaManagerProxy() { |
| 56 DCHECK(!registered_client_); |
| 57 } |
| 58 |
| 59 } // namespace quota |
OLD | NEW |