| 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 "content/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 using storage::kStorageTypeUnknown; |  | 
|  12  |  | 
|  13 namespace content { |  | 
|  14  |  | 
|  15 MockQuotaManagerProxy::MockQuotaManagerProxy( |  | 
|  16     MockQuotaManager* quota_manager, |  | 
|  17     base::SingleThreadTaskRunner* task_runner) |  | 
|  18     : QuotaManagerProxy(quota_manager, task_runner), |  | 
|  19       storage_accessed_count_(0), |  | 
|  20       storage_modified_count_(0), |  | 
|  21       last_notified_type_(kStorageTypeUnknown), |  | 
|  22       last_notified_delta_(0), |  | 
|  23       registered_client_(NULL) {} |  | 
|  24  |  | 
|  25 void MockQuotaManagerProxy::RegisterClient(QuotaClient* client) { |  | 
|  26   DCHECK(!registered_client_); |  | 
|  27   registered_client_ = client; |  | 
|  28 } |  | 
|  29  |  | 
|  30 void MockQuotaManagerProxy::SimulateQuotaManagerDestroyed() { |  | 
|  31   if (registered_client_) { |  | 
|  32     // We cannot call this in the destructor as the client (indirectly) |  | 
|  33     // holds a refptr of the proxy. |  | 
|  34     registered_client_->OnQuotaManagerDestroyed(); |  | 
|  35     registered_client_ = NULL; |  | 
|  36   } |  | 
|  37 } |  | 
|  38  |  | 
|  39 void MockQuotaManagerProxy::GetUsageAndQuota( |  | 
|  40     base::SequencedTaskRunner* original_task_runner, |  | 
|  41     const GURL& origin, |  | 
|  42     StorageType type, |  | 
|  43     const QuotaManager::GetUsageAndQuotaCallback& callback) { |  | 
|  44   if (mock_manager()) { |  | 
|  45     mock_manager()->GetUsageAndQuota(origin, type, callback); |  | 
|  46   } |  | 
|  47 } |  | 
|  48  |  | 
|  49 void MockQuotaManagerProxy::NotifyStorageAccessed( |  | 
|  50     QuotaClient::ID client_id, const GURL& origin, StorageType type) { |  | 
|  51   ++storage_accessed_count_; |  | 
|  52   last_notified_origin_ = origin; |  | 
|  53   last_notified_type_ = type; |  | 
|  54 } |  | 
|  55  |  | 
|  56 void MockQuotaManagerProxy::NotifyStorageModified(QuotaClient::ID client_id, |  | 
|  57                                                   const GURL& origin, |  | 
|  58                                                   StorageType type, |  | 
|  59                                                   int64_t delta) { |  | 
|  60   ++storage_modified_count_; |  | 
|  61   last_notified_origin_ = origin; |  | 
|  62   last_notified_type_ = type; |  | 
|  63   last_notified_delta_ = delta; |  | 
|  64   if (mock_manager()) |  | 
|  65     mock_manager()->UpdateUsage(origin, type, delta); |  | 
|  66 } |  | 
|  67  |  | 
|  68 MockQuotaManagerProxy::~MockQuotaManagerProxy() { |  | 
|  69   DCHECK(!registered_client_); |  | 
|  70 } |  | 
|  71  |  | 
|  72 }  // namespace content |  | 
| OLD | NEW |