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

Side by Side Diff: content/browser/in_process_webkit/indexed_db_context_impl.h

Issue 12163003: Add FilePath to base namespace. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 7 years, 10 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 | « content/browser/fileapi/fileapi_message_filter.h ('k') | content/browser/safe_util_win.h » ('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) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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 7
8 #include <map> 8 #include <map>
9 #include <set> 9 #include <set>
10 10
11 #include "base/compiler_specific.h" 11 #include "base/compiler_specific.h"
12 #include "base/file_path.h" 12 #include "base/file_path.h"
13 #include "base/gtest_prod_util.h" 13 #include "base/gtest_prod_util.h"
14 #include "base/memory/scoped_ptr.h" 14 #include "base/memory/scoped_ptr.h"
15 #include "content/public/browser/indexed_db_context.h" 15 #include "content/public/browser/indexed_db_context.h"
16 #include "googleurl/src/gurl.h" 16 #include "googleurl/src/gurl.h"
17 #include "webkit/quota/quota_types.h" 17 #include "webkit/quota/quota_types.h"
18 18
19 class GURL; 19 class GURL;
20 class FilePath;
21 20
22 namespace WebKit { 21 namespace WebKit {
23 class WebIDBDatabase; 22 class WebIDBDatabase;
24 class WebIDBFactory; 23 class WebIDBFactory;
25 } 24 }
26 25
27 namespace base { 26 namespace base {
27 class FilePath;
28 class MessageLoopProxy; 28 class MessageLoopProxy;
29 } 29 }
30 30
31 namespace quota { 31 namespace quota {
32 class QuotaManagerProxy; 32 class QuotaManagerProxy;
33 class SpecialStoragePolicy; 33 class SpecialStoragePolicy;
34 } 34 }
35 35
36 namespace content { 36 namespace content {
37 37
38 class CONTENT_EXPORT IndexedDBContextImpl 38 class CONTENT_EXPORT IndexedDBContextImpl
39 : NON_EXPORTED_BASE(public IndexedDBContext) { 39 : NON_EXPORTED_BASE(public IndexedDBContext) {
40 public: 40 public:
41 // If |data_path| is empty, nothing will be saved to disk. 41 // If |data_path| is empty, nothing will be saved to disk.
42 IndexedDBContextImpl(const FilePath& data_path, 42 IndexedDBContextImpl(const base::FilePath& data_path,
43 quota::SpecialStoragePolicy* special_storage_policy, 43 quota::SpecialStoragePolicy* special_storage_policy,
44 quota::QuotaManagerProxy* quota_manager_proxy, 44 quota::QuotaManagerProxy* quota_manager_proxy,
45 base::MessageLoopProxy* webkit_thread_loop); 45 base::MessageLoopProxy* webkit_thread_loop);
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 base::FilePath::CharType kIndexedDBDirectory[];
51 51
52 // The indexed db file extension. 52 // The indexed db file extension.
53 static const FilePath::CharType kIndexedDBExtension[]; 53 static const base::FilePath::CharType kIndexedDBExtension[];
54 54
55 // Disables the exit-time deletion of session-only data. 55 // Disables the exit-time deletion of session-only data.
56 void SetForceKeepSessionState() { 56 void SetForceKeepSessionState() {
57 force_keep_session_state_ = true; 57 force_keep_session_state_ = true;
58 } 58 }
59 59
60 // IndexedDBContext implementation: 60 // IndexedDBContext implementation:
61 virtual std::vector<GURL> GetAllOrigins() OVERRIDE; 61 virtual std::vector<GURL> GetAllOrigins() OVERRIDE;
62 virtual int64 GetOriginDiskUsage(const GURL& origin_url) OVERRIDE; 62 virtual int64 GetOriginDiskUsage(const GURL& origin_url) OVERRIDE;
63 virtual base::Time GetOriginLastModified(const GURL& origin_url) OVERRIDE; 63 virtual base::Time GetOriginLastModified(const GURL& origin_url) OVERRIDE;
64 virtual void DeleteForOrigin(const GURL& origin_url) OVERRIDE; 64 virtual void DeleteForOrigin(const GURL& origin_url) OVERRIDE;
65 virtual FilePath GetFilePathForTesting( 65 virtual base::FilePath GetFilePathForTesting(
66 const string16& origin_id) const OVERRIDE; 66 const string16& origin_id) const OVERRIDE;
67 67
68 // Methods called by IndexedDBDispatcherHost for quota support. 68 // Methods called by IndexedDBDispatcherHost for quota support.
69 void ConnectionOpened(const GURL& origin_url, WebKit::WebIDBDatabase*); 69 void ConnectionOpened(const GURL& origin_url, WebKit::WebIDBDatabase*);
70 void ConnectionClosed(const GURL& origin_url, WebKit::WebIDBDatabase*); 70 void ConnectionClosed(const GURL& origin_url, WebKit::WebIDBDatabase*);
71 void TransactionComplete(const GURL& origin_url); 71 void TransactionComplete(const GURL& origin_url);
72 bool WouldBeOverQuota(const GURL& origin_url, int64 additional_bytes); 72 bool WouldBeOverQuota(const GURL& origin_url, int64 additional_bytes);
73 bool IsOverQuota(const GURL& origin_url); 73 bool IsOverQuota(const GURL& origin_url);
74 74
75 quota::QuotaManagerProxy* quota_manager_proxy(); 75 quota::QuotaManagerProxy* quota_manager_proxy();
76 76
77 FilePath data_path() const { return data_path_; } 77 base::FilePath data_path() const { return data_path_; }
78 78
79 // For unit tests allow to override the |data_path_|. 79 // For unit tests allow to override the |data_path_|.
80 void set_data_path_for_testing(const FilePath& data_path) { 80 void set_data_path_for_testing(const base::FilePath& data_path) {
81 data_path_ = data_path; 81 data_path_ = data_path;
82 } 82 }
83 83
84 protected: 84 protected:
85 virtual ~IndexedDBContextImpl(); 85 virtual ~IndexedDBContextImpl();
86 86
87 private: 87 private:
88 FRIEND_TEST_ALL_PREFIXES(IndexedDBTest, ClearLocalState); 88 FRIEND_TEST_ALL_PREFIXES(IndexedDBTest, ClearLocalState);
89 FRIEND_TEST_ALL_PREFIXES(IndexedDBTest, ClearSessionOnlyDatabases); 89 FRIEND_TEST_ALL_PREFIXES(IndexedDBTest, ClearSessionOnlyDatabases);
90 FRIEND_TEST_ALL_PREFIXES(IndexedDBTest, SetForceKeepSessionState); 90 FRIEND_TEST_ALL_PREFIXES(IndexedDBTest, SetForceKeepSessionState);
91 FRIEND_TEST_ALL_PREFIXES(IndexedDBTest, ForceCloseOpenDatabasesOnDelete); 91 FRIEND_TEST_ALL_PREFIXES(IndexedDBTest, ForceCloseOpenDatabasesOnDelete);
92 friend class IndexedDBQuotaClientTest; 92 friend class IndexedDBQuotaClientTest;
93 93
94 typedef std::map<GURL, int64> OriginToSizeMap; 94 typedef std::map<GURL, int64> OriginToSizeMap;
95 class IndexedDBGetUsageAndQuotaCallback; 95 class IndexedDBGetUsageAndQuotaCallback;
96 96
97 FilePath GetIndexedDBFilePath(const string16& origin_id) const; 97 base::FilePath GetIndexedDBFilePath(const string16& origin_id) const;
98 int64 ReadUsageFromDisk(const GURL& origin_url) const; 98 int64 ReadUsageFromDisk(const GURL& origin_url) const;
99 void EnsureDiskUsageCacheInitialized(const GURL& origin_url); 99 void EnsureDiskUsageCacheInitialized(const GURL& origin_url);
100 void QueryDiskAndUpdateQuotaUsage(const GURL& origin_url); 100 void QueryDiskAndUpdateQuotaUsage(const GURL& origin_url);
101 void GotUsageAndQuota(const GURL& origin_url, quota::QuotaStatusCode, 101 void GotUsageAndQuota(const GURL& origin_url, quota::QuotaStatusCode,
102 int64 usage, int64 quota); 102 int64 usage, int64 quota);
103 void GotUpdatedQuota(const GURL& origin_url, int64 usage, int64 quota); 103 void GotUpdatedQuota(const GURL& origin_url, int64 usage, int64 quota);
104 void QueryAvailableQuota(const GURL& origin_url); 104 void QueryAvailableQuota(const GURL& origin_url);
105 105
106 std::set<GURL>* GetOriginSet(); 106 std::set<GURL>* GetOriginSet();
107 bool AddToOriginSet(const GURL& origin_url) { 107 bool AddToOriginSet(const GURL& origin_url) {
108 return GetOriginSet()->insert(origin_url).second; 108 return GetOriginSet()->insert(origin_url).second;
109 } 109 }
110 void RemoveFromOriginSet(const GURL& origin_url) { 110 void RemoveFromOriginSet(const GURL& origin_url) {
111 GetOriginSet()->erase(origin_url); 111 GetOriginSet()->erase(origin_url);
112 } 112 }
113 bool IsInOriginSet(const GURL& origin_url) { 113 bool IsInOriginSet(const GURL& origin_url) {
114 std::set<GURL>* set = GetOriginSet(); 114 std::set<GURL>* set = GetOriginSet();
115 return set->find(origin_url) != set->end(); 115 return set->find(origin_url) != set->end();
116 } 116 }
117 117
118 // Only for testing. 118 // Only for testing.
119 void ResetCaches(); 119 void ResetCaches();
120 120
121 scoped_ptr<WebKit::WebIDBFactory> idb_factory_; 121 scoped_ptr<WebKit::WebIDBFactory> idb_factory_;
122 FilePath data_path_; 122 base::FilePath data_path_;
123 // If true, nothing (not even session-only data) should be deleted on exit. 123 // If true, nothing (not even session-only data) should be deleted on exit.
124 bool force_keep_session_state_; 124 bool force_keep_session_state_;
125 scoped_refptr<quota::SpecialStoragePolicy> special_storage_policy_; 125 scoped_refptr<quota::SpecialStoragePolicy> special_storage_policy_;
126 scoped_refptr<quota::QuotaManagerProxy> quota_manager_proxy_; 126 scoped_refptr<quota::QuotaManagerProxy> quota_manager_proxy_;
127 scoped_ptr<std::set<GURL> > origin_set_; 127 scoped_ptr<std::set<GURL> > origin_set_;
128 OriginToSizeMap origin_size_map_; 128 OriginToSizeMap origin_size_map_;
129 OriginToSizeMap space_available_map_; 129 OriginToSizeMap space_available_map_;
130 typedef std::set<WebKit::WebIDBDatabase*> ConnectionSet; 130 typedef std::set<WebKit::WebIDBDatabase*> ConnectionSet;
131 std::map<GURL, ConnectionSet> connections_; 131 std::map<GURL, ConnectionSet> connections_;
132 132
133 DISALLOW_COPY_AND_ASSIGN(IndexedDBContextImpl); 133 DISALLOW_COPY_AND_ASSIGN(IndexedDBContextImpl);
134 }; 134 };
135 135
136 } // namespace content 136 } // namespace content
137 137
138 #endif // CONTENT_BROWSER_IN_PROCESS_WEBKIT_INDEXED_DB_CONTEXT_IMPL_H_ 138 #endif // CONTENT_BROWSER_IN_PROCESS_WEBKIT_INDEXED_DB_CONTEXT_IMPL_H_
OLDNEW
« no previous file with comments | « content/browser/fileapi/fileapi_message_filter.h ('k') | content/browser/safe_util_win.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698