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_IMPL_H_ | 5 #ifndef CONTENT_BROWSER_IN_PROCESS_WEBKIT_INDEXED_DB_CONTEXT_IMPL_H_ |
6 #define CONTENT_BROWSER_IN_PROCESS_WEBKIT_INDEXED_DB_CONTEXT_IMPL_H_ | 6 #define CONTENT_BROWSER_IN_PROCESS_WEBKIT_INDEXED_DB_CONTEXT_IMPL_H_ |
7 #pragma once | 7 #pragma once |
8 | 8 |
9 #include <map> | 9 #include <map> |
10 #include <set> | 10 #include <set> |
11 | 11 |
12 #include "base/compiler_specific.h" | 12 #include "base/compiler_specific.h" |
13 #include "base/file_path.h" | 13 #include "base/file_path.h" |
14 #include "base/gtest_prod_util.h" | 14 #include "base/gtest_prod_util.h" |
15 #include "base/memory/scoped_ptr.h" | 15 #include "base/memory/scoped_ptr.h" |
16 #include "content/public/browser/indexed_db_context.h" | 16 #include "content/public/browser/indexed_db_context.h" |
17 #include "googleurl/src/gurl.h" | 17 #include "googleurl/src/gurl.h" |
18 #include "webkit/quota/quota_types.h" | 18 #include "webkit/quota/quota_types.h" |
19 | 19 |
20 class GURL; | 20 class GURL; |
21 class FilePath; | 21 class FilePath; |
22 class WebKitContext; | |
23 | 22 |
24 namespace WebKit { | 23 namespace WebKit { |
25 class WebIDBFactory; | 24 class WebIDBFactory; |
26 } | 25 } |
27 | 26 |
28 namespace base { | 27 namespace base { |
29 class MessageLoopProxy; | 28 class MessageLoopProxy; |
30 } | 29 } |
31 | 30 |
32 namespace quota { | 31 namespace quota { |
33 class QuotaManagerProxy; | 32 class QuotaManagerProxy; |
34 class SpecialStoragePolicy; | 33 class SpecialStoragePolicy; |
35 } | 34 } |
36 | 35 |
37 class CONTENT_EXPORT IndexedDBContextImpl | 36 class CONTENT_EXPORT IndexedDBContextImpl |
38 : NON_EXPORTED_BASE(public content::IndexedDBContext) { | 37 : NON_EXPORTED_BASE(public content::IndexedDBContext) { |
39 public: | 38 public: |
40 IndexedDBContextImpl(WebKitContext* webkit_context, | 39 // If |data_path| is empty, nothing will be saved to disk. |
| 40 IndexedDBContextImpl(const FilePath& data_path, |
41 quota::SpecialStoragePolicy* special_storage_policy, | 41 quota::SpecialStoragePolicy* special_storage_policy, |
42 quota::QuotaManagerProxy* quota_manager_proxy, | 42 quota::QuotaManagerProxy* quota_manager_proxy, |
43 base::MessageLoopProxy* webkit_thread_loop); | 43 base::MessageLoopProxy* webkit_thread_loop); |
44 | 44 |
45 virtual ~IndexedDBContextImpl(); | 45 virtual ~IndexedDBContextImpl(); |
46 | 46 |
47 WebKit::WebIDBFactory* GetIDBFactory(); | 47 WebKit::WebIDBFactory* GetIDBFactory(); |
48 | 48 |
49 // The indexed db directory. | 49 // The indexed db directory. |
50 static const FilePath::CharType kIndexedDBDirectory[]; | 50 static const FilePath::CharType kIndexedDBDirectory[]; |
(...skipping 20 matching lines...) Expand all Loading... |
71 | 71 |
72 // Methods called by IndexedDBDispatcherHost for quota support. | 72 // Methods called by IndexedDBDispatcherHost for quota support. |
73 void ConnectionOpened(const GURL& origin_url); | 73 void ConnectionOpened(const GURL& origin_url); |
74 void ConnectionClosed(const GURL& origin_url); | 74 void ConnectionClosed(const GURL& origin_url); |
75 void TransactionComplete(const GURL& origin_url); | 75 void TransactionComplete(const GURL& origin_url); |
76 bool WouldBeOverQuota(const GURL& origin_url, int64 additional_bytes); | 76 bool WouldBeOverQuota(const GURL& origin_url, int64 additional_bytes); |
77 bool IsOverQuota(const GURL& origin_url); | 77 bool IsOverQuota(const GURL& origin_url); |
78 | 78 |
79 quota::QuotaManagerProxy* quota_manager_proxy(); | 79 quota::QuotaManagerProxy* quota_manager_proxy(); |
80 | 80 |
| 81 FilePath data_path() const { return data_path_; } |
| 82 |
81 // For unit tests allow to override the |data_path_|. | 83 // For unit tests allow to override the |data_path_|. |
82 void set_data_path_for_testing(const FilePath& data_path) { | 84 void set_data_path_for_testing(const FilePath& data_path) { |
83 data_path_ = data_path; | 85 data_path_ = data_path; |
84 } | 86 } |
85 | 87 |
86 private: | 88 private: |
87 FRIEND_TEST_ALL_PREFIXES(IndexedDBBrowserTest, ClearLocalState); | 89 FRIEND_TEST_ALL_PREFIXES(IndexedDBBrowserTest, ClearLocalState); |
88 FRIEND_TEST_ALL_PREFIXES(IndexedDBBrowserTest, ClearSessionOnlyDatabases); | 90 FRIEND_TEST_ALL_PREFIXES(IndexedDBBrowserTest, ClearSessionOnlyDatabases); |
89 FRIEND_TEST_ALL_PREFIXES(IndexedDBBrowserTest, SaveSessionState); | 91 FRIEND_TEST_ALL_PREFIXES(IndexedDBBrowserTest, SaveSessionState); |
90 friend class IndexedDBQuotaClientTest; | 92 friend class IndexedDBQuotaClientTest; |
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
125 scoped_refptr<quota::QuotaManagerProxy> quota_manager_proxy_; | 127 scoped_refptr<quota::QuotaManagerProxy> quota_manager_proxy_; |
126 scoped_ptr<std::set<GURL> > origin_set_; | 128 scoped_ptr<std::set<GURL> > origin_set_; |
127 OriginToSizeMap origin_size_map_; | 129 OriginToSizeMap origin_size_map_; |
128 OriginToSizeMap space_available_map_; | 130 OriginToSizeMap space_available_map_; |
129 std::map<GURL, unsigned int> connection_count_; | 131 std::map<GURL, unsigned int> connection_count_; |
130 | 132 |
131 DISALLOW_COPY_AND_ASSIGN(IndexedDBContextImpl); | 133 DISALLOW_COPY_AND_ASSIGN(IndexedDBContextImpl); |
132 }; | 134 }; |
133 | 135 |
134 #endif // CONTENT_BROWSER_IN_PROCESS_WEBKIT_INDEXED_DB_CONTEXT_IMPL_H_ | 136 #endif // CONTENT_BROWSER_IN_PROCESS_WEBKIT_INDEXED_DB_CONTEXT_IMPL_H_ |
OLD | NEW |