Chromium Code Reviews| 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 <stdint.h> | 7 #include <stdint.h> |
| 8 | 8 |
| 9 #include <memory> | |
|
danakj
2016/11/30 00:34:00
should include base/memory/ptr_util.h for WrapUniq
| |
| 10 | |
| 9 #include "base/bind.h" | 11 #include "base/bind.h" |
| 10 #include "base/memory/weak_ptr.h" | 12 #include "base/memory/weak_ptr.h" |
| 11 #include "base/numerics/safe_conversions.h" | 13 #include "base/numerics/safe_conversions.h" |
| 12 #include "base/trace_event/trace_event.h" | 14 #include "base/trace_event/trace_event.h" |
| 13 #include "content/common/quota_messages.h" | 15 #include "content/common/quota_messages.h" |
| 14 #include "content/public/browser/quota_permission_context.h" | 16 #include "content/public/browser/quota_permission_context.h" |
| 15 #include "net/base/url_util.h" | 17 #include "net/base/url_util.h" |
| 16 #include "storage/browser/quota/quota_manager.h" | 18 #include "storage/browser/quota/quota_manager.h" |
| 17 #include "url/gurl.h" | 19 #include "url/gurl.h" |
| 18 | 20 |
| 19 using storage::QuotaClient; | 21 using storage::QuotaClient; |
| 20 using storage::QuotaManager; | 22 using storage::QuotaManager; |
| 21 using storage::QuotaStatusCode; | 23 using storage::QuotaStatusCode; |
| 22 using storage::StorageType; | 24 using storage::StorageType; |
| 23 | 25 |
| 24 namespace content { | 26 namespace content { |
| 25 | 27 |
| 26 // Created one per request to carry the request's request_id around. | 28 // Created one per request to carry the request's request_id around. |
| 27 // Dispatches requests from renderer/worker to the QuotaManager and | 29 // Dispatches requests from renderer/worker to the QuotaManager and |
| 28 // sends back the response to the renderer/worker. | 30 // sends back the response to the renderer/worker. |
| 29 class QuotaDispatcherHost::RequestDispatcher { | 31 class QuotaDispatcherHost::RequestDispatcher { |
| 30 public: | 32 public: |
| 31 RequestDispatcher(base::WeakPtr<QuotaDispatcherHost> dispatcher_host, | 33 RequestDispatcher(base::WeakPtr<QuotaDispatcherHost> dispatcher_host, |
| 32 int request_id) | 34 int request_id) |
| 33 : dispatcher_host_(dispatcher_host), | 35 : dispatcher_host_(dispatcher_host), |
| 34 render_process_id_(dispatcher_host->process_id_), | 36 render_process_id_(dispatcher_host->process_id_), |
| 35 request_id_(request_id) { | 37 request_id_(request_id) { |
| 36 dispatcher_host_->outstanding_requests_.AddWithID(this, request_id_); | 38 dispatcher_host_->outstanding_requests_.AddWithID(base::WrapUnique(this), |
| 39 request_id_); | |
| 37 } | 40 } |
| 38 virtual ~RequestDispatcher() {} | 41 virtual ~RequestDispatcher() {} |
| 39 | 42 |
| 40 protected: | 43 protected: |
| 41 // Subclass must call this when it's done with the request. | 44 // Subclass must call this when it's done with the request. |
| 42 void Completed() { | 45 void Completed() { |
| 43 if (dispatcher_host_) | 46 if (dispatcher_host_) |
| 44 dispatcher_host_->outstanding_requests_.Remove(request_id_); | 47 dispatcher_host_->outstanding_requests_.Remove(request_id_); |
| 45 } | 48 } |
| 46 | 49 |
| (...skipping 219 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 266 return; | 269 return; |
| 267 } | 270 } |
| 268 | 271 |
| 269 RequestQuotaDispatcher* dispatcher = | 272 RequestQuotaDispatcher* dispatcher = |
| 270 new RequestQuotaDispatcher(weak_factory_.GetWeakPtr(), | 273 new RequestQuotaDispatcher(weak_factory_.GetWeakPtr(), |
| 271 params); | 274 params); |
| 272 dispatcher->Start(); | 275 dispatcher->Start(); |
| 273 } | 276 } |
| 274 | 277 |
| 275 } // namespace content | 278 } // namespace content |
| OLD | NEW |