OLD | NEW |
1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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/browser/quota_dispatcher_host.h" | 5 #include "content/browser/quota_dispatcher_host.h" |
6 | 6 |
7 #include "base/bind.h" | 7 #include "base/bind.h" |
8 #include "base/memory/weak_ptr.h" | 8 #include "base/memory/weak_ptr.h" |
9 #include "base/numerics/safe_conversions.h" | 9 #include "base/numerics/safe_conversions.h" |
10 #include "content/common/quota_messages.h" | 10 #include "content/common/quota_messages.h" |
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
61 }; | 61 }; |
62 | 62 |
63 class QuotaDispatcherHost::QueryUsageAndQuotaDispatcher | 63 class QuotaDispatcherHost::QueryUsageAndQuotaDispatcher |
64 : public RequestDispatcher { | 64 : public RequestDispatcher { |
65 public: | 65 public: |
66 QueryUsageAndQuotaDispatcher( | 66 QueryUsageAndQuotaDispatcher( |
67 base::WeakPtr<QuotaDispatcherHost> dispatcher_host, | 67 base::WeakPtr<QuotaDispatcherHost> dispatcher_host, |
68 int request_id) | 68 int request_id) |
69 : RequestDispatcher(dispatcher_host, request_id), | 69 : RequestDispatcher(dispatcher_host, request_id), |
70 weak_factory_(this) {} | 70 weak_factory_(this) {} |
71 virtual ~QueryUsageAndQuotaDispatcher() {} | 71 ~QueryUsageAndQuotaDispatcher() override {} |
72 | 72 |
73 void QueryStorageUsageAndQuota(const GURL& origin, StorageType type) { | 73 void QueryStorageUsageAndQuota(const GURL& origin, StorageType type) { |
74 quota_manager()->GetUsageAndQuotaForWebApps( | 74 quota_manager()->GetUsageAndQuotaForWebApps( |
75 origin, type, | 75 origin, type, |
76 base::Bind(&QueryUsageAndQuotaDispatcher::DidQueryStorageUsageAndQuota, | 76 base::Bind(&QueryUsageAndQuotaDispatcher::DidQueryStorageUsageAndQuota, |
77 weak_factory_.GetWeakPtr())); | 77 weak_factory_.GetWeakPtr())); |
78 } | 78 } |
79 | 79 |
80 private: | 80 private: |
81 void DidQueryStorageUsageAndQuota( | 81 void DidQueryStorageUsageAndQuota( |
(...skipping 23 matching lines...) Expand all Loading... |
105 params_(params), | 105 params_(params), |
106 current_usage_(0), | 106 current_usage_(0), |
107 current_quota_(0), | 107 current_quota_(0), |
108 requested_quota_(0), | 108 requested_quota_(0), |
109 weak_factory_(this) { | 109 weak_factory_(this) { |
110 // Convert the requested size from uint64 to int64 since the quota backend | 110 // Convert the requested size from uint64 to int64 since the quota backend |
111 // requires int64 values. | 111 // requires int64 values. |
112 // TODO(nhiroki): The backend should accept uint64 values. | 112 // TODO(nhiroki): The backend should accept uint64 values. |
113 requested_quota_ = base::saturated_cast<int64>(params_.requested_size); | 113 requested_quota_ = base::saturated_cast<int64>(params_.requested_size); |
114 } | 114 } |
115 virtual ~RequestQuotaDispatcher() {} | 115 ~RequestQuotaDispatcher() override {} |
116 | 116 |
117 void Start() { | 117 void Start() { |
118 DCHECK(dispatcher_host()); | 118 DCHECK(dispatcher_host()); |
119 | 119 |
120 DCHECK(params_.storage_type == storage::kStorageTypeTemporary || | 120 DCHECK(params_.storage_type == storage::kStorageTypeTemporary || |
121 params_.storage_type == storage::kStorageTypePersistent || | 121 params_.storage_type == storage::kStorageTypePersistent || |
122 params_.storage_type == storage::kStorageTypeSyncable); | 122 params_.storage_type == storage::kStorageTypeSyncable); |
123 if (params_.storage_type == storage::kStorageTypePersistent) { | 123 if (params_.storage_type == storage::kStorageTypePersistent) { |
124 quota_manager()->GetUsageAndQuotaForWebApps( | 124 quota_manager()->GetUsageAndQuotaForWebApps( |
125 params_.origin_url, params_.storage_type, | 125 params_.origin_url, params_.storage_type, |
(...skipping 127 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
253 return; | 253 return; |
254 } | 254 } |
255 | 255 |
256 RequestQuotaDispatcher* dispatcher = | 256 RequestQuotaDispatcher* dispatcher = |
257 new RequestQuotaDispatcher(weak_factory_.GetWeakPtr(), | 257 new RequestQuotaDispatcher(weak_factory_.GetWeakPtr(), |
258 params); | 258 params); |
259 dispatcher->Start(); | 259 dispatcher->Start(); |
260 } | 260 } |
261 | 261 |
262 } // namespace content | 262 } // namespace content |
OLD | NEW |