| 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 "content/child/quota_dispatcher.h" | 5 #include "content/child/quota_dispatcher.h" |
| 6 | 6 |
| 7 #include "base/basictypes.h" | 7 #include "base/basictypes.h" |
| 8 #include "base/lazy_instance.h" | 8 #include "base/lazy_instance.h" |
| 9 #include "base/threading/thread_local.h" | 9 #include "base/threading/thread_local.h" |
| 10 #include "content/child/child_thread.h" | 10 #include "content/child/child_thread.h" |
| (...skipping 24 matching lines...) Expand all Loading... |
| 35 class WebStorageQuotaDispatcherCallback : public QuotaDispatcher::Callback { | 35 class WebStorageQuotaDispatcherCallback : public QuotaDispatcher::Callback { |
| 36 public: | 36 public: |
| 37 WebStorageQuotaDispatcherCallback(blink::WebStorageQuotaCallbacks* callback) | 37 WebStorageQuotaDispatcherCallback(blink::WebStorageQuotaCallbacks* callback) |
| 38 : callbacks_(callback) { | 38 : callbacks_(callback) { |
| 39 DCHECK(callbacks_); | 39 DCHECK(callbacks_); |
| 40 } | 40 } |
| 41 virtual ~WebStorageQuotaDispatcherCallback() {} | 41 virtual ~WebStorageQuotaDispatcherCallback() {} |
| 42 virtual void DidQueryStorageUsageAndQuota(int64 usage, int64 quota) OVERRIDE { | 42 virtual void DidQueryStorageUsageAndQuota(int64 usage, int64 quota) OVERRIDE { |
| 43 callbacks_->didQueryStorageUsageAndQuota(usage, quota); | 43 callbacks_->didQueryStorageUsageAndQuota(usage, quota); |
| 44 } | 44 } |
| 45 virtual void DidGrantStorageQuota(int64 granted_quota) OVERRIDE { | 45 virtual void DidGrantStorageQuota(int64 usage, int64 granted_quota) OVERRIDE { |
| 46 callbacks_->didGrantStorageQuota(granted_quota); | 46 callbacks_->didGrantStorageQuota(granted_quota); |
| 47 } | 47 } |
| 48 virtual void DidFail(quota::QuotaStatusCode error) OVERRIDE { | 48 virtual void DidFail(quota::QuotaStatusCode error) OVERRIDE { |
| 49 callbacks_->didFail(static_cast<WebStorageQuotaError>(error)); | 49 callbacks_->didFail(static_cast<WebStorageQuotaError>(error)); |
| 50 } | 50 } |
| 51 | 51 |
| 52 private: | 52 private: |
| 53 // Not owned (self-destructed). | 53 // Not owned (self-destructed). |
| 54 blink::WebStorageQuotaCallbacks* callbacks_; | 54 blink::WebStorageQuotaCallbacks* callbacks_; |
| 55 }; | 55 }; |
| (...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 134 | 134 |
| 135 // static | 135 // static |
| 136 QuotaDispatcher::Callback* | 136 QuotaDispatcher::Callback* |
| 137 QuotaDispatcher::CreateWebStorageQuotaCallbacksWrapper( | 137 QuotaDispatcher::CreateWebStorageQuotaCallbacksWrapper( |
| 138 blink::WebStorageQuotaCallbacks* callbacks) { | 138 blink::WebStorageQuotaCallbacks* callbacks) { |
| 139 return new WebStorageQuotaDispatcherCallback(callbacks); | 139 return new WebStorageQuotaDispatcherCallback(callbacks); |
| 140 } | 140 } |
| 141 | 141 |
| 142 void QuotaDispatcher::DidGrantStorageQuota( | 142 void QuotaDispatcher::DidGrantStorageQuota( |
| 143 int request_id, | 143 int request_id, |
| 144 int64 current_usage, |
| 144 int64 granted_quota) { | 145 int64 granted_quota) { |
| 145 Callback* callback = pending_quota_callbacks_.Lookup(request_id); | 146 Callback* callback = pending_quota_callbacks_.Lookup(request_id); |
| 146 DCHECK(callback); | 147 DCHECK(callback); |
| 147 callback->DidGrantStorageQuota(granted_quota); | 148 callback->DidGrantStorageQuota(current_usage, granted_quota); |
| 148 pending_quota_callbacks_.Remove(request_id); | 149 pending_quota_callbacks_.Remove(request_id); |
| 149 } | 150 } |
| 150 | 151 |
| 151 void QuotaDispatcher::DidQueryStorageUsageAndQuota( | 152 void QuotaDispatcher::DidQueryStorageUsageAndQuota( |
| 152 int request_id, | 153 int request_id, |
| 153 int64 current_usage, | 154 int64 current_usage, |
| 154 int64 current_quota) { | 155 int64 current_quota) { |
| 155 Callback* callback = pending_quota_callbacks_.Lookup(request_id); | 156 Callback* callback = pending_quota_callbacks_.Lookup(request_id); |
| 156 DCHECK(callback); | 157 DCHECK(callback); |
| 157 callback->DidQueryStorageUsageAndQuota(current_usage, current_quota); | 158 callback->DidQueryStorageUsageAndQuota(current_usage, current_quota); |
| (...skipping 13 matching lines...) Expand all Loading... |
| 171 int(quota::kStorageTypeTemporary), mismatching_enums); | 172 int(quota::kStorageTypeTemporary), mismatching_enums); |
| 172 COMPILE_ASSERT(int(blink::WebStorageQuotaTypePersistent) == \ | 173 COMPILE_ASSERT(int(blink::WebStorageQuotaTypePersistent) == \ |
| 173 int(quota::kStorageTypePersistent), mismatching_enums); | 174 int(quota::kStorageTypePersistent), mismatching_enums); |
| 174 | 175 |
| 175 COMPILE_ASSERT(int(blink::WebStorageQuotaErrorNotSupported) == \ | 176 COMPILE_ASSERT(int(blink::WebStorageQuotaErrorNotSupported) == \ |
| 176 int(quota::kQuotaErrorNotSupported), mismatching_enums); | 177 int(quota::kQuotaErrorNotSupported), mismatching_enums); |
| 177 COMPILE_ASSERT(int(blink::WebStorageQuotaErrorAbort) == \ | 178 COMPILE_ASSERT(int(blink::WebStorageQuotaErrorAbort) == \ |
| 178 int(quota::kQuotaErrorAbort), mismatching_enums); | 179 int(quota::kQuotaErrorAbort), mismatching_enums); |
| 179 | 180 |
| 180 } // namespace content | 181 } // namespace content |
| OLD | NEW |