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_BROWSER_IN_PROCESS_WEBKIT_INDEXED_DB_CONTEXT_H_ | 5 #ifndef CONTENT_BROWSER_IN_PROCESS_WEBKIT_INDEXED_DB_CONTEXT_H_ |
6 #define CONTENT_BROWSER_IN_PROCESS_WEBKIT_INDEXED_DB_CONTEXT_H_ | 6 #define CONTENT_BROWSER_IN_PROCESS_WEBKIT_INDEXED_DB_CONTEXT_H_ |
7 #pragma once | 7 #pragma once |
8 | 8 |
9 #include "base/basictypes.h" | 9 #include "base/basictypes.h" |
10 #include "base/file_path.h" | 10 #include "base/file_path.h" |
11 #include "base/memory/ref_counted.h" | 11 #include "base/memory/ref_counted.h" |
12 #include "base/memory/scoped_ptr.h" | 12 #include "base/memory/scoped_ptr.h" |
13 #include "content/browser/browser_thread.h" | |
13 | 14 |
14 class GURL; | 15 class GURL; |
15 class FilePath; | 16 class FilePath; |
16 class WebKitContext; | 17 class WebKitContext; |
17 | 18 |
18 namespace WebKit { | 19 namespace WebKit { |
19 class WebIDBFactory; | 20 class WebIDBFactory; |
20 } | 21 } |
21 | 22 |
23 namespace base { | |
24 class MessageLoopProxy; | |
25 } | |
26 | |
22 namespace quota { | 27 namespace quota { |
28 class QuotaManagerProxy; | |
23 class SpecialStoragePolicy; | 29 class SpecialStoragePolicy; |
24 } | 30 } |
25 | 31 |
26 class IndexedDBContext { | 32 struct DeleteOnWebKitThread; |
33 | |
34 class IndexedDBContext : | |
35 public base::RefCountedThreadSafe<IndexedDBContext, | |
36 DeleteOnWebKitThread> { | |
jam
2011/05/28 03:08:51
if you want to handle the leak in unittests, then
dgrogan
2011/05/31 23:26:07
Thanks. Done.
| |
27 public: | 37 public: |
28 IndexedDBContext(WebKitContext* webkit_context, | 38 IndexedDBContext(WebKitContext* webkit_context, |
29 quota::SpecialStoragePolicy* special_storage_policy); | 39 quota::SpecialStoragePolicy* special_storage_policy, |
40 quota::QuotaManagerProxy* quota_manager_proxy, | |
41 base::MessageLoopProxy* webkit_thread_loop); | |
42 | |
30 ~IndexedDBContext(); | 43 ~IndexedDBContext(); |
31 | 44 |
32 WebKit::WebIDBFactory* GetIDBFactory(); | 45 WebKit::WebIDBFactory* GetIDBFactory(); |
33 | 46 |
34 // The indexed db directory. | 47 // The indexed db directory. |
35 static const FilePath::CharType kIndexedDBDirectory[]; | 48 static const FilePath::CharType kIndexedDBDirectory[]; |
36 | 49 |
37 // The indexed db file extension. | 50 // The indexed db file extension. |
38 static const FilePath::CharType kIndexedDBExtension[]; | 51 static const FilePath::CharType kIndexedDBExtension[]; |
39 | 52 |
(...skipping 22 matching lines...) Expand all Loading... | |
62 scoped_ptr<WebKit::WebIDBFactory> idb_factory_; | 75 scoped_ptr<WebKit::WebIDBFactory> idb_factory_; |
63 | 76 |
64 // Path where the indexed db data is stored | 77 // Path where the indexed db data is stored |
65 FilePath data_path_; | 78 FilePath data_path_; |
66 | 79 |
67 // True if the destructor should delete its files. | 80 // True if the destructor should delete its files. |
68 bool clear_local_state_on_exit_; | 81 bool clear_local_state_on_exit_; |
69 | 82 |
70 scoped_refptr<quota::SpecialStoragePolicy> special_storage_policy_; | 83 scoped_refptr<quota::SpecialStoragePolicy> special_storage_policy_; |
71 | 84 |
85 scoped_refptr<quota::QuotaManagerProxy> quota_manager_proxy_; | |
86 | |
72 DISALLOW_COPY_AND_ASSIGN(IndexedDBContext); | 87 DISALLOW_COPY_AND_ASSIGN(IndexedDBContext); |
73 }; | 88 }; |
74 | 89 |
90 // This was copied from browser_thread.h and modified. | |
91 struct DeleteOnWebKitThread { | |
92 static void Destruct(const IndexedDBContext* x) { | |
93 BrowserThread::ID thread = BrowserThread::WEBKIT; | |
94 if (BrowserThread::CurrentlyOn(thread)) { | |
95 delete x; | |
96 } else { | |
97 if (!BrowserThread::DeleteSoon(thread, FROM_HERE, x)) { | |
98 #if defined(UNIT_TEST) | |
99 LOG(INFO) << "DeleteSoon failed on thread, deleting locally" << thread; | |
100 delete x; | |
101 #endif // UNIT_TEST | |
102 } | |
103 } | |
104 } | |
105 }; | |
106 | |
75 #endif // CONTENT_BROWSER_IN_PROCESS_WEBKIT_INDEXED_DB_CONTEXT_H_ | 107 #endif // CONTENT_BROWSER_IN_PROCESS_WEBKIT_INDEXED_DB_CONTEXT_H_ |
OLD | NEW |