| OLD | NEW |
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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/renderer_host/quota_dispatcher_host.h" | 5 #include "content/browser/renderer_host/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 "content/browser/quota_permission_context.h" | |
| 10 #include "content/common/quota_messages.h" | 9 #include "content/common/quota_messages.h" |
| 10 #include "content/public/browser/quota_permission_context.h" |
| 11 #include "googleurl/src/gurl.h" | 11 #include "googleurl/src/gurl.h" |
| 12 #include "net/base/net_util.h" | 12 #include "net/base/net_util.h" |
| 13 #include "webkit/quota/quota_manager.h" | 13 #include "webkit/quota/quota_manager.h" |
| 14 | 14 |
| 15 using content::QuotaPermissionContext; |
| 15 using quota::QuotaClient; | 16 using quota::QuotaClient; |
| 16 using quota::QuotaManager; | 17 using quota::QuotaManager; |
| 17 using quota::QuotaStatusCode; | 18 using quota::QuotaStatusCode; |
| 18 using quota::StorageType; | 19 using quota::StorageType; |
| 19 | 20 |
| 20 // Created one per request to carry the request's request_id around. | 21 // Created one per request to carry the request's request_id around. |
| 21 // Dispatches requests from renderer/worker to the QuotaManager and | 22 // Dispatches requests from renderer/worker to the QuotaManager and |
| 22 // sends back the response to the renderer/worker. | 23 // sends back the response to the renderer/worker. |
| 23 class QuotaDispatcherHost::RequestDispatcher { | 24 class QuotaDispatcherHost::RequestDispatcher { |
| 24 public: | 25 public: |
| (...skipping 121 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 146 base::Bind(&self_type::DidGetPermissionResponse, | 147 base::Bind(&self_type::DidGetPermissionResponse, |
| 147 weak_factory_.GetWeakPtr())); | 148 weak_factory_.GetWeakPtr())); |
| 148 } | 149 } |
| 149 | 150 |
| 150 void DidGetTemporaryUsageAndQuota(QuotaStatusCode status, | 151 void DidGetTemporaryUsageAndQuota(QuotaStatusCode status, |
| 151 int64 usage_unused, | 152 int64 usage_unused, |
| 152 int64 quota) { | 153 int64 quota) { |
| 153 DidFinish(status, std::min(requested_quota_, quota)); | 154 DidFinish(status, std::min(requested_quota_, quota)); |
| 154 } | 155 } |
| 155 | 156 |
| 156 void DidGetPermissionResponse(QuotaPermissionContext::Response response) { | 157 void DidGetPermissionResponse( |
| 157 if (response != QuotaPermissionContext::kResponseAllow) { | 158 QuotaPermissionContext::QuotaPermissionResponse response) { |
| 159 if (response != QuotaPermissionContext::QUOTA_PERMISSION_RESPONSE_ALLOW) { |
| 158 // User didn't allow the new quota. Just returning the current quota. | 160 // User didn't allow the new quota. Just returning the current quota. |
| 159 DidFinish(quota::kQuotaStatusOk, current_quota_); | 161 DidFinish(quota::kQuotaStatusOk, current_quota_); |
| 160 return; | 162 return; |
| 161 } | 163 } |
| 162 // Now we're allowed to set the new quota. | 164 // Now we're allowed to set the new quota. |
| 163 quota_manager()->SetPersistentHostQuota( | 165 quota_manager()->SetPersistentHostQuota( |
| 164 host_, requested_quota_, | 166 host_, requested_quota_, |
| 165 base::Bind(&self_type::DidSetHostQuota, | 167 base::Bind(&self_type::DidSetHostQuota, |
| 166 weak_factory_.GetWeakPtr())); | 168 weak_factory_.GetWeakPtr())); |
| 167 } | 169 } |
| (...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 246 type != quota::kStorageTypePersistent) { | 248 type != quota::kStorageTypePersistent) { |
| 247 // Unsupported storage types. | 249 // Unsupported storage types. |
| 248 Send(new QuotaMsg_DidFail(request_id, quota::kQuotaErrorNotSupported)); | 250 Send(new QuotaMsg_DidFail(request_id, quota::kQuotaErrorNotSupported)); |
| 249 return; | 251 return; |
| 250 } | 252 } |
| 251 | 253 |
| 252 RequestQuotaDispatcher* dispatcher = new RequestQuotaDispatcher( | 254 RequestQuotaDispatcher* dispatcher = new RequestQuotaDispatcher( |
| 253 this, request_id, origin, type, requested_size, render_view_id); | 255 this, request_id, origin, type, requested_size, render_view_id); |
| 254 dispatcher->Start(); | 256 dispatcher->Start(); |
| 255 } | 257 } |
| OLD | NEW |