Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(716)

Side by Side Diff: content/browser/quota_dispatcher_host.cc

Issue 1394563002: Add trace to the caller of QuotaManager::GetAvailableSpace (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 "base/trace_event/trace_event.h"
10 #include "content/common/quota_messages.h" 11 #include "content/common/quota_messages.h"
11 #include "content/public/browser/quota_permission_context.h" 12 #include "content/public/browser/quota_permission_context.h"
12 #include "net/base/net_util.h" 13 #include "net/base/net_util.h"
13 #include "storage/browser/quota/quota_manager.h" 14 #include "storage/browser/quota/quota_manager.h"
14 #include "url/gurl.h" 15 #include "url/gurl.h"
15 16
16 using storage::QuotaClient; 17 using storage::QuotaClient;
17 using storage::QuotaManager; 18 using storage::QuotaManager;
18 using storage::QuotaStatusCode; 19 using storage::QuotaStatusCode;
19 using storage::StorageType; 20 using storage::StorageType;
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after
64 : public RequestDispatcher { 65 : public RequestDispatcher {
65 public: 66 public:
66 QueryUsageAndQuotaDispatcher( 67 QueryUsageAndQuotaDispatcher(
67 base::WeakPtr<QuotaDispatcherHost> dispatcher_host, 68 base::WeakPtr<QuotaDispatcherHost> dispatcher_host,
68 int request_id) 69 int request_id)
69 : RequestDispatcher(dispatcher_host, request_id), 70 : RequestDispatcher(dispatcher_host, request_id),
70 weak_factory_(this) {} 71 weak_factory_(this) {}
71 ~QueryUsageAndQuotaDispatcher() override {} 72 ~QueryUsageAndQuotaDispatcher() override {}
72 73
73 void QueryStorageUsageAndQuota(const GURL& origin, StorageType type) { 74 void QueryStorageUsageAndQuota(const GURL& origin, StorageType type) {
75 // crbug.com/349708
76 TRACE_EVENT0("io",
77 "QuotaDispatcherHost::QueryUsageAndQuotaDispatcher"
78 "::QueryStorageUsageAndQuota");
79
74 quota_manager()->GetUsageAndQuotaForWebApps( 80 quota_manager()->GetUsageAndQuotaForWebApps(
75 origin, type, 81 origin, type,
76 base::Bind(&QueryUsageAndQuotaDispatcher::DidQueryStorageUsageAndQuota, 82 base::Bind(&QueryUsageAndQuotaDispatcher::DidQueryStorageUsageAndQuota,
77 weak_factory_.GetWeakPtr())); 83 weak_factory_.GetWeakPtr()));
78 } 84 }
79 85
80 private: 86 private:
81 void DidQueryStorageUsageAndQuota( 87 void DidQueryStorageUsageAndQuota(
michaeln 2015/10/09 00:51:42 and this
oshima 2015/10/09 17:14:09 Done.
82 QuotaStatusCode status, int64 usage, int64 quota) { 88 QuotaStatusCode status, int64 usage, int64 quota) {
83 if (!dispatcher_host()) 89 if (!dispatcher_host())
84 return; 90 return;
85 if (status != storage::kQuotaStatusOk) { 91 if (status != storage::kQuotaStatusOk) {
86 dispatcher_host()->Send(new QuotaMsg_DidFail(request_id(), status)); 92 dispatcher_host()->Send(new QuotaMsg_DidFail(request_id(), status));
87 } else { 93 } else {
88 dispatcher_host()->Send(new QuotaMsg_DidQueryStorageUsageAndQuota( 94 dispatcher_host()->Send(new QuotaMsg_DidQueryStorageUsageAndQuota(
89 request_id(), usage, quota)); 95 request_id(), usage, quota));
90 } 96 }
91 Completed(); 97 Completed();
(...skipping 17 matching lines...) Expand all
109 weak_factory_(this) { 115 weak_factory_(this) {
110 // Convert the requested size from uint64 to int64 since the quota backend 116 // Convert the requested size from uint64 to int64 since the quota backend
111 // requires int64 values. 117 // requires int64 values.
112 // TODO(nhiroki): The backend should accept uint64 values. 118 // TODO(nhiroki): The backend should accept uint64 values.
113 requested_quota_ = base::saturated_cast<int64>(params_.requested_size); 119 requested_quota_ = base::saturated_cast<int64>(params_.requested_size);
114 } 120 }
115 ~RequestQuotaDispatcher() override {} 121 ~RequestQuotaDispatcher() override {}
116 122
117 void Start() { 123 void Start() {
118 DCHECK(dispatcher_host()); 124 DCHECK(dispatcher_host());
125 // crbug.com/349708
126 TRACE_EVENT0("io", "QuotaDispatcherHost::RequestQuotaDispatcher::Start");
119 127
120 DCHECK(params_.storage_type == storage::kStorageTypeTemporary || 128 DCHECK(params_.storage_type == storage::kStorageTypeTemporary ||
121 params_.storage_type == storage::kStorageTypePersistent); 129 params_.storage_type == storage::kStorageTypePersistent);
122 if (params_.storage_type == storage::kStorageTypePersistent) { 130 if (params_.storage_type == storage::kStorageTypePersistent) {
123 quota_manager()->GetUsageAndQuotaForWebApps( 131 quota_manager()->GetUsageAndQuotaForWebApps(
124 params_.origin_url, params_.storage_type, 132 params_.origin_url, params_.storage_type,
125 base::Bind(&self_type::DidGetPersistentUsageAndQuota, 133 base::Bind(&self_type::DidGetPersistentUsageAndQuota,
126 weak_factory_.GetWeakPtr())); 134 weak_factory_.GetWeakPtr()));
127 } else { 135 } else {
128 quota_manager()->GetUsageAndQuotaForWebApps( 136 quota_manager()->GetUsageAndQuotaForWebApps(
(...skipping 123 matching lines...) Expand 10 before | Expand all | Expand 10 after
252 return; 260 return;
253 } 261 }
254 262
255 RequestQuotaDispatcher* dispatcher = 263 RequestQuotaDispatcher* dispatcher =
256 new RequestQuotaDispatcher(weak_factory_.GetWeakPtr(), 264 new RequestQuotaDispatcher(weak_factory_.GetWeakPtr(),
257 params); 265 params);
258 dispatcher->Start(); 266 dispatcher->Start();
259 } 267 }
260 268
261 } // namespace content 269 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698