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 <memory> | |
8 | |
7 #include "base/lazy_instance.h" | 9 #include "base/lazy_instance.h" |
8 #include "base/macros.h" | 10 #include "base/macros.h" |
9 #include "base/threading/thread_local.h" | 11 #include "base/threading/thread_local.h" |
10 #include "content/child/quota_message_filter.h" | 12 #include "content/child/quota_message_filter.h" |
11 #include "content/child/thread_safe_sender.h" | 13 #include "content/child/thread_safe_sender.h" |
12 #include "content/common/quota_messages.h" | 14 #include "content/common/quota_messages.h" |
13 #include "third_party/WebKit/public/platform/WebStorageQuotaCallbacks.h" | 15 #include "third_party/WebKit/public/platform/WebStorageQuotaCallbacks.h" |
14 #include "third_party/WebKit/public/platform/WebStorageQuotaType.h" | 16 #include "third_party/WebKit/public/platform/WebStorageQuotaType.h" |
15 #include "third_party/WebKit/public/web/WebUserGestureIndicator.h" | 17 #include "third_party/WebKit/public/web/WebUserGestureIndicator.h" |
16 #include "url/gurl.h" | 18 #include "url/gurl.h" |
(...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
101 DidQueryStorageUsageAndQuota); | 103 DidQueryStorageUsageAndQuota); |
102 IPC_MESSAGE_HANDLER(QuotaMsg_DidFail, DidFail); | 104 IPC_MESSAGE_HANDLER(QuotaMsg_DidFail, DidFail); |
103 IPC_MESSAGE_UNHANDLED(handled = false) | 105 IPC_MESSAGE_UNHANDLED(handled = false) |
104 IPC_END_MESSAGE_MAP() | 106 IPC_END_MESSAGE_MAP() |
105 DCHECK(handled) << "Unhandled message:" << msg.type(); | 107 DCHECK(handled) << "Unhandled message:" << msg.type(); |
106 } | 108 } |
107 | 109 |
108 void QuotaDispatcher::QueryStorageUsageAndQuota( | 110 void QuotaDispatcher::QueryStorageUsageAndQuota( |
109 const GURL& origin_url, | 111 const GURL& origin_url, |
110 StorageType type, | 112 StorageType type, |
111 Callback* callback) { | 113 Callback* callback) { |
danakj
2016/11/18 00:15:33
and this
| |
112 DCHECK(callback); | 114 DCHECK(callback); |
113 int request_id = quota_message_filter_->GenerateRequestID(CurrentWorkerId()); | 115 int request_id = quota_message_filter_->GenerateRequestID(CurrentWorkerId()); |
114 pending_quota_callbacks_.AddWithID(callback, request_id); | 116 pending_quota_callbacks_.AddWithID( |
117 std::unique_ptr<Callback>(callback), request_id); | |
115 thread_safe_sender_->Send(new QuotaHostMsg_QueryStorageUsageAndQuota( | 118 thread_safe_sender_->Send(new QuotaHostMsg_QueryStorageUsageAndQuota( |
116 request_id, origin_url, type)); | 119 request_id, origin_url, type)); |
117 } | 120 } |
118 | 121 |
119 void QuotaDispatcher::RequestStorageQuota(int render_view_id, | 122 void QuotaDispatcher::RequestStorageQuota(int render_view_id, |
120 const GURL& origin_url, | 123 const GURL& origin_url, |
121 StorageType type, | 124 StorageType type, |
122 uint64_t requested_size, | 125 uint64_t requested_size, |
123 Callback* callback) { | 126 Callback* callback) { |
danakj
2016/11/18 00:15:33
and.. this?
| |
124 DCHECK(callback); | 127 DCHECK(callback); |
125 DCHECK(CurrentWorkerId() == 0); | 128 DCHECK(CurrentWorkerId() == 0); |
126 int request_id = quota_message_filter_->GenerateRequestID(CurrentWorkerId()); | 129 int request_id = quota_message_filter_->GenerateRequestID(CurrentWorkerId()); |
127 pending_quota_callbacks_.AddWithID(callback, request_id); | 130 pending_quota_callbacks_.AddWithID( |
131 std::unique_ptr<Callback>(callback), request_id); | |
128 | 132 |
129 StorageQuotaParams params; | 133 StorageQuotaParams params; |
130 params.render_view_id = render_view_id; | 134 params.render_view_id = render_view_id; |
131 params.request_id = request_id; | 135 params.request_id = request_id; |
132 params.origin_url = origin_url; | 136 params.origin_url = origin_url; |
133 params.storage_type = type; | 137 params.storage_type = type; |
134 params.requested_size = requested_size; | 138 params.requested_size = requested_size; |
135 params.user_gesture = | 139 params.user_gesture = |
136 blink::WebUserGestureIndicator::isProcessingUserGesture(); | 140 blink::WebUserGestureIndicator::isProcessingUserGesture(); |
137 thread_safe_sender_->Send(new QuotaHostMsg_RequestStorageQuota(params)); | 141 thread_safe_sender_->Send(new QuotaHostMsg_RequestStorageQuota(params)); |
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
179 "mismatching enums: kStorageTypePersistent"); | 183 "mismatching enums: kStorageTypePersistent"); |
180 | 184 |
181 static_assert(int(blink::WebStorageQuotaErrorNotSupported) == | 185 static_assert(int(blink::WebStorageQuotaErrorNotSupported) == |
182 int(storage::kQuotaErrorNotSupported), | 186 int(storage::kQuotaErrorNotSupported), |
183 "mismatching enums: kQuotaErrorNotSupported"); | 187 "mismatching enums: kQuotaErrorNotSupported"); |
184 static_assert(int(blink::WebStorageQuotaErrorAbort) == | 188 static_assert(int(blink::WebStorageQuotaErrorAbort) == |
185 int(storage::kQuotaErrorAbort), | 189 int(storage::kQuotaErrorAbort), |
186 "mismatching enums: kQuotaErrorAbort"); | 190 "mismatching enums: kQuotaErrorAbort"); |
187 | 191 |
188 } // namespace content | 192 } // namespace content |
OLD | NEW |