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 "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 "content/common/quota_messages.h" | 10 #include "content/common/quota_messages.h" |
11 #include "content/public/browser/quota_permission_context.h" | 11 #include "content/public/browser/quota_permission_context.h" |
12 #include "net/base/net_util.h" | 12 #include "net/base/net_util.h" |
13 #include "url/gurl.h" | 13 #include "url/gurl.h" |
14 #include "webkit/browser/quota/quota_manager.h" | 14 #include "webkit/browser/quota/quota_manager.h" |
15 | 15 |
16 using quota::QuotaClient; | 16 using quota::QuotaClient; |
17 using quota::QuotaManager; | 17 using quota::QuotaManager; |
18 using quota::QuotaStatusCode; | 18 using quota::QuotaStatusCode; |
19 using quota::StorageType; | 19 using quota::StorageType; |
20 | 20 |
21 namespace content { | 21 namespace content { |
| 22 namespace { |
| 23 const uint32 kFilteredMessageClasses[] = { |
| 24 QuotaMsgStart, |
| 25 }; |
| 26 } // namespace |
22 | 27 |
23 // 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. |
24 // Dispatches requests from renderer/worker to the QuotaManager and | 29 // Dispatches requests from renderer/worker to the QuotaManager and |
25 // sends back the response to the renderer/worker. | 30 // sends back the response to the renderer/worker. |
26 class QuotaDispatcherHost::RequestDispatcher { | 31 class QuotaDispatcherHost::RequestDispatcher { |
27 public: | 32 public: |
28 RequestDispatcher(base::WeakPtr<QuotaDispatcherHost> dispatcher_host, | 33 RequestDispatcher(base::WeakPtr<QuotaDispatcherHost> dispatcher_host, |
29 int request_id) | 34 int request_id) |
30 : dispatcher_host_(dispatcher_host), | 35 : dispatcher_host_(dispatcher_host), |
31 render_process_id_(dispatcher_host->process_id_), | 36 render_process_id_(dispatcher_host->process_id_), |
(...skipping 182 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
214 int64 current_quota_; | 219 int64 current_quota_; |
215 int64 requested_quota_; | 220 int64 requested_quota_; |
216 const int render_view_id_; | 221 const int render_view_id_; |
217 base::WeakPtrFactory<self_type> weak_factory_; | 222 base::WeakPtrFactory<self_type> weak_factory_; |
218 }; | 223 }; |
219 | 224 |
220 QuotaDispatcherHost::QuotaDispatcherHost( | 225 QuotaDispatcherHost::QuotaDispatcherHost( |
221 int process_id, | 226 int process_id, |
222 QuotaManager* quota_manager, | 227 QuotaManager* quota_manager, |
223 QuotaPermissionContext* permission_context) | 228 QuotaPermissionContext* permission_context) |
224 : process_id_(process_id), | 229 : BrowserMessageFilter( |
| 230 kFilteredMessageClasses, arraysize(kFilteredMessageClasses)), |
| 231 process_id_(process_id), |
225 quota_manager_(quota_manager), | 232 quota_manager_(quota_manager), |
226 permission_context_(permission_context), | 233 permission_context_(permission_context), |
227 weak_factory_(this) { | 234 weak_factory_(this) { |
228 } | 235 } |
229 | 236 |
230 bool QuotaDispatcherHost::OnMessageReceived( | 237 bool QuotaDispatcherHost::OnMessageReceived( |
231 const IPC::Message& message, bool* message_was_ok) { | 238 const IPC::Message& message, bool* message_was_ok) { |
232 *message_was_ok = true; | 239 *message_was_ok = true; |
233 bool handled = true; | 240 bool handled = true; |
234 IPC_BEGIN_MESSAGE_MAP_EX(QuotaDispatcherHost, message, *message_was_ok) | 241 IPC_BEGIN_MESSAGE_MAP_EX(QuotaDispatcherHost, message, *message_was_ok) |
(...skipping 30 matching lines...) Expand all Loading... |
265 return; | 272 return; |
266 } | 273 } |
267 | 274 |
268 RequestQuotaDispatcher* dispatcher = new RequestQuotaDispatcher( | 275 RequestQuotaDispatcher* dispatcher = new RequestQuotaDispatcher( |
269 weak_factory_.GetWeakPtr(), request_id, origin, type, | 276 weak_factory_.GetWeakPtr(), request_id, origin, type, |
270 requested_size, render_view_id); | 277 requested_size, render_view_id); |
271 dispatcher->Start(); | 278 dispatcher->Start(); |
272 } | 279 } |
273 | 280 |
274 } // namespace content | 281 } // namespace content |
OLD | NEW |