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 #ifndef CONTENT_CHILD_QUOTA_DISPATCHER_H_ | 5 #ifndef CONTENT_CHILD_QUOTA_DISPATCHER_H_ |
6 #define CONTENT_CHILD_QUOTA_DISPATCHER_H_ | 6 #define CONTENT_CHILD_QUOTA_DISPATCHER_H_ |
7 | 7 |
| 8 #include <stdint.h> |
| 9 |
8 #include <map> | 10 #include <map> |
9 #include <set> | 11 #include <set> |
10 | 12 |
11 #include "base/basictypes.h" | |
12 #include "base/id_map.h" | 13 #include "base/id_map.h" |
| 14 #include "base/macros.h" |
13 #include "base/memory/ref_counted.h" | 15 #include "base/memory/ref_counted.h" |
14 #include "content/public/child/worker_thread.h" | 16 #include "content/public/child/worker_thread.h" |
15 #include "storage/common/quota/quota_types.h" | 17 #include "storage/common/quota/quota_types.h" |
16 | 18 |
17 class GURL; | 19 class GURL; |
18 | 20 |
19 namespace IPC { | 21 namespace IPC { |
20 class Message; | 22 class Message; |
21 } | 23 } |
22 | 24 |
23 namespace blink { | 25 namespace blink { |
24 class WebStorageQuotaCallbacks; | 26 class WebStorageQuotaCallbacks; |
25 } | 27 } |
26 | 28 |
27 namespace content { | 29 namespace content { |
28 | 30 |
29 class ThreadSafeSender; | 31 class ThreadSafeSender; |
30 class QuotaMessageFilter; | 32 class QuotaMessageFilter; |
31 | 33 |
32 // Dispatches and sends quota related messages sent to/from a child | 34 // Dispatches and sends quota related messages sent to/from a child |
33 // process from/to the main browser process. There is one instance | 35 // process from/to the main browser process. There is one instance |
34 // per each thread. Thread-specific instance can be obtained by | 36 // per each thread. Thread-specific instance can be obtained by |
35 // ThreadSpecificInstance(). | 37 // ThreadSpecificInstance(). |
36 class QuotaDispatcher : public WorkerThread::Observer { | 38 class QuotaDispatcher : public WorkerThread::Observer { |
37 public: | 39 public: |
38 class Callback { | 40 class Callback { |
39 public: | 41 public: |
40 virtual ~Callback() {} | 42 virtual ~Callback() {} |
41 virtual void DidQueryStorageUsageAndQuota(int64 usage, int64 quota) = 0; | 43 virtual void DidQueryStorageUsageAndQuota(int64_t usage, int64_t quota) = 0; |
42 virtual void DidGrantStorageQuota(int64 usage, int64 granted_quota) = 0; | 44 virtual void DidGrantStorageQuota(int64_t usage, int64_t granted_quota) = 0; |
43 virtual void DidFail(storage::QuotaStatusCode status) = 0; | 45 virtual void DidFail(storage::QuotaStatusCode status) = 0; |
44 }; | 46 }; |
45 | 47 |
46 QuotaDispatcher(ThreadSafeSender* thread_safe_sender, | 48 QuotaDispatcher(ThreadSafeSender* thread_safe_sender, |
47 QuotaMessageFilter* quota_message_filter); | 49 QuotaMessageFilter* quota_message_filter); |
48 ~QuotaDispatcher() override; | 50 ~QuotaDispatcher() override; |
49 | 51 |
50 // |thread_safe_sender| and |quota_message_filter| are used if | 52 // |thread_safe_sender| and |quota_message_filter| are used if |
51 // calling this leads to construction. | 53 // calling this leads to construction. |
52 static QuotaDispatcher* ThreadSpecificInstance( | 54 static QuotaDispatcher* ThreadSpecificInstance( |
53 ThreadSafeSender* thread_safe_sender, | 55 ThreadSafeSender* thread_safe_sender, |
54 QuotaMessageFilter* quota_message_filter); | 56 QuotaMessageFilter* quota_message_filter); |
55 | 57 |
56 // WorkerThread::Observer implementation. | 58 // WorkerThread::Observer implementation. |
57 void WillStopCurrentWorkerThread() override; | 59 void WillStopCurrentWorkerThread() override; |
58 | 60 |
59 void OnMessageReceived(const IPC::Message& msg); | 61 void OnMessageReceived(const IPC::Message& msg); |
60 | 62 |
61 void QueryStorageUsageAndQuota(const GURL& gurl, | 63 void QueryStorageUsageAndQuota(const GURL& gurl, |
62 storage::StorageType type, | 64 storage::StorageType type, |
63 Callback* callback); | 65 Callback* callback); |
64 void RequestStorageQuota(int render_view_id, | 66 void RequestStorageQuota(int render_view_id, |
65 const GURL& gurl, | 67 const GURL& gurl, |
66 storage::StorageType type, | 68 storage::StorageType type, |
67 uint64 requested_size, | 69 uint64_t requested_size, |
68 Callback* callback); | 70 Callback* callback); |
69 | 71 |
70 // Creates a new Callback instance for WebStorageQuotaCallbacks. | 72 // Creates a new Callback instance for WebStorageQuotaCallbacks. |
71 static Callback* CreateWebStorageQuotaCallbacksWrapper( | 73 static Callback* CreateWebStorageQuotaCallbacksWrapper( |
72 blink::WebStorageQuotaCallbacks callbacks); | 74 blink::WebStorageQuotaCallbacks callbacks); |
73 | 75 |
74 private: | 76 private: |
75 // Message handlers. | 77 // Message handlers. |
76 void DidQueryStorageUsageAndQuota(int request_id, | 78 void DidQueryStorageUsageAndQuota(int request_id, |
77 int64 current_usage, | 79 int64_t current_usage, |
78 int64 current_quota); | 80 int64_t current_quota); |
79 void DidGrantStorageQuota(int request_id, | 81 void DidGrantStorageQuota(int request_id, |
80 int64 current_usage, | 82 int64_t current_usage, |
81 int64 granted_quota); | 83 int64_t granted_quota); |
82 void DidFail(int request_id, storage::QuotaStatusCode error); | 84 void DidFail(int request_id, storage::QuotaStatusCode error); |
83 | 85 |
84 IDMap<Callback, IDMapOwnPointer> pending_quota_callbacks_; | 86 IDMap<Callback, IDMapOwnPointer> pending_quota_callbacks_; |
85 | 87 |
86 scoped_refptr<ThreadSafeSender> thread_safe_sender_; | 88 scoped_refptr<ThreadSafeSender> thread_safe_sender_; |
87 scoped_refptr<QuotaMessageFilter> quota_message_filter_; | 89 scoped_refptr<QuotaMessageFilter> quota_message_filter_; |
88 | 90 |
89 DISALLOW_COPY_AND_ASSIGN(QuotaDispatcher); | 91 DISALLOW_COPY_AND_ASSIGN(QuotaDispatcher); |
90 }; | 92 }; |
91 | 93 |
92 } // namespace content | 94 } // namespace content |
93 | 95 |
94 #endif // CONTENT_CHILD_QUOTA_DISPATCHER_H_ | 96 #endif // CONTENT_CHILD_QUOTA_DISPATCHER_H_ |
OLD | NEW |