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

Side by Side Diff: trunk/src/content/child/quota_dispatcher.h

Issue 21039004: Revert 214172 "Revert 214162 "Make Platform::queryStorageUsageAn..." (Closed) Base URL: svn://svn.chromium.org/chrome/
Patch Set: Created 7 years, 4 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 | Annotate | Revision Log
« no previous file with comments | « trunk/src/content/child/child_thread.cc ('k') | trunk/src/content/child/quota_dispatcher.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 <map> 8 #include <map>
9 #include <set> 9 #include <set>
10 10
11 #include "base/basictypes.h" 11 #include "base/basictypes.h"
12 #include "base/id_map.h" 12 #include "base/id_map.h"
13 #include "ipc/ipc_listener.h" 13 #include "base/memory/ref_counted.h"
14 #include "webkit/child/worker_task_runner.h"
14 #include "webkit/common/quota/quota_types.h" 15 #include "webkit/common/quota/quota_types.h"
15 16
16 class GURL; 17 class GURL;
17 18
18 namespace IPC { 19 namespace IPC {
19 class Message; 20 class Message;
20 } 21 }
21 22
22 namespace WebKit { 23 namespace WebKit {
23 class WebStorageQuotaCallbacks; 24 class WebStorageQuotaCallbacks;
24 } 25 }
25 26
26 namespace content { 27 namespace content {
27 28
29 class ThreadSafeSender;
30 class QuotaMessageFilter;
31
28 // Dispatches and sends quota related messages sent to/from a child 32 // Dispatches and sends quota related messages sent to/from a child
29 // process from/to the main browser process. There is one instance 33 // process from/to the main browser process. There is one instance
30 // per child process. Messages are dispatched on the main child thread. 34 // per each thread. Thread-specific instance can be obtained by
31 class QuotaDispatcher : public IPC::Listener { 35 // ThreadSpecificInstance().
36 class QuotaDispatcher : public webkit_glue::WorkerTaskRunner::Observer {
32 public: 37 public:
33 class Callback { 38 class Callback {
34 public: 39 public:
35 virtual ~Callback() {} 40 virtual ~Callback() {}
36 virtual void DidQueryStorageUsageAndQuota(int64 usage, int64 quota) = 0; 41 virtual void DidQueryStorageUsageAndQuota(int64 usage, int64 quota) = 0;
37 virtual void DidGrantStorageQuota(int64 granted_quota) = 0; 42 virtual void DidGrantStorageQuota(int64 granted_quota) = 0;
38 virtual void DidFail(quota::QuotaStatusCode status) = 0; 43 virtual void DidFail(quota::QuotaStatusCode status) = 0;
39 }; 44 };
40 45
41 QuotaDispatcher(); 46 QuotaDispatcher(ThreadSafeSender* thread_safe_sender,
47 QuotaMessageFilter* quota_message_filter);
42 virtual ~QuotaDispatcher(); 48 virtual ~QuotaDispatcher();
43 49
44 // IPC::Listener implementation. 50 // |thread_safe_sender| and |quota_message_filter| are used if
45 virtual bool OnMessageReceived(const IPC::Message& msg) OVERRIDE; 51 // calling this leads to construction.
52 static QuotaDispatcher* ThreadSpecificInstance(
53 ThreadSafeSender* thread_safe_sender,
54 QuotaMessageFilter* quota_message_filter);
55
56 // webkit_glue::WorkerTaskRunner::Observer implementation.
57 virtual void OnWorkerRunLoopStopped() OVERRIDE;
58
59 void OnMessageReceived(const IPC::Message& msg);
46 60
47 void QueryStorageUsageAndQuota(const GURL& gurl, 61 void QueryStorageUsageAndQuota(const GURL& gurl,
48 quota::StorageType type, 62 quota::StorageType type,
49 Callback* callback); 63 Callback* callback);
50 void RequestStorageQuota(int render_view_id, 64 void RequestStorageQuota(int render_view_id,
51 const GURL& gurl, 65 const GURL& gurl,
52 quota::StorageType type, 66 quota::StorageType type,
53 int64 requested_size, 67 int64 requested_size,
54 Callback* callback); 68 Callback* callback);
55 69
56 // Creates a new Callback instance for WebStorageQuotaCallbacks. 70 // Creates a new Callback instance for WebStorageQuotaCallbacks.
57 static Callback* CreateWebStorageQuotaCallbacksWrapper( 71 static Callback* CreateWebStorageQuotaCallbacksWrapper(
58 WebKit::WebStorageQuotaCallbacks* callbacks); 72 WebKit::WebStorageQuotaCallbacks* callbacks);
59 73
60 private: 74 private:
61 // Message handlers. 75 // Message handlers.
62 void DidQueryStorageUsageAndQuota(int request_id, 76 void DidQueryStorageUsageAndQuota(int request_id,
63 int64 current_usage, 77 int64 current_usage,
64 int64 current_quota); 78 int64 current_quota);
65 void DidGrantStorageQuota(int request_id, 79 void DidGrantStorageQuota(int request_id,
66 int64 granted_quota); 80 int64 granted_quota);
67 void DidFail(int request_id, quota::QuotaStatusCode error); 81 void DidFail(int request_id,
82 quota::QuotaStatusCode error);
68 83
69 IDMap<Callback, IDMapOwnPointer> pending_quota_callbacks_; 84 IDMap<Callback, IDMapOwnPointer> pending_quota_callbacks_;
70 85
86 scoped_refptr<ThreadSafeSender> thread_safe_sender_;
87 scoped_refptr<QuotaMessageFilter> quota_message_filter_;
88
71 DISALLOW_COPY_AND_ASSIGN(QuotaDispatcher); 89 DISALLOW_COPY_AND_ASSIGN(QuotaDispatcher);
72 }; 90 };
73 91
74 } // namespace content 92 } // namespace content
75 93
76 #endif // CONTENT_CHILD_QUOTA_DISPATCHER_H_ 94 #endif // CONTENT_CHILD_QUOTA_DISPATCHER_H_
OLDNEW
« no previous file with comments | « trunk/src/content/child/child_thread.cc ('k') | trunk/src/content/child/quota_dispatcher.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698