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 <map> |
| 10 |
9 #include "base/basictypes.h" | 11 #include "base/basictypes.h" |
10 #include "base/file_path.h" | 12 #include "base/file_path.h" |
11 #include "base/memory/ref_counted.h" | 13 #include "base/memory/ref_counted.h" |
12 #include "base/memory/scoped_ptr.h" | 14 #include "base/memory/scoped_ptr.h" |
13 #include "content/browser/browser_thread.h" | 15 #include "content/browser/browser_thread.h" |
14 | 16 |
15 class GURL; | 17 class GURL; |
16 class FilePath; | 18 class FilePath; |
17 class WebKitContext; | 19 class WebKitContext; |
18 | 20 |
(...skipping 27 matching lines...) Expand all Loading... |
46 // The indexed db file extension. | 48 // The indexed db file extension. |
47 static const FilePath::CharType kIndexedDBExtension[]; | 49 static const FilePath::CharType kIndexedDBExtension[]; |
48 | 50 |
49 // Get the file name of the indexed db file for the given origin. | 51 // Get the file name of the indexed db file for the given origin. |
50 FilePath GetIndexedDBFilePath(const string16& origin_id) const; | 52 FilePath GetIndexedDBFilePath(const string16& origin_id) const; |
51 | 53 |
52 void set_clear_local_state_on_exit(bool clear_local_state) { | 54 void set_clear_local_state_on_exit(bool clear_local_state) { |
53 clear_local_state_on_exit_ = clear_local_state; | 55 clear_local_state_on_exit_ = clear_local_state; |
54 } | 56 } |
55 | 57 |
56 // Deletes a single indexed db file. | |
57 void DeleteIndexedDBFile(const FilePath& file_path); | |
58 | |
59 // Deletes all indexed db files for the given origin. | 58 // Deletes all indexed db files for the given origin. |
60 void DeleteIndexedDBForOrigin(const string16& origin_id); | 59 void DeleteIndexedDBForOrigin(const GURL& origin_url); |
61 | 60 |
62 // Does a particular origin get unlimited storage? | 61 // Does a particular origin get unlimited storage? |
63 bool IsUnlimitedStorageGranted(const GURL& origin) const; | 62 bool IsUnlimitedStorageGranted(const GURL& origin) const; |
64 | 63 |
| 64 // Methods used in response to QuotaManager requests. |
65 void GetAllOriginIdentifiers(std::vector<string16>* origin_ids); | 65 void GetAllOriginIdentifiers(std::vector<string16>* origin_ids); |
| 66 int64 GetOriginDiskUsage(const GURL& origin_url); |
| 67 |
| 68 // Methods called by IndexedDBDispatcherHost for quota support. |
| 69 void ConnectionOpened(const GURL& origin_url); |
| 70 void ConnectionClosed(const GURL& origin_url); |
| 71 void TransactionComplete(const GURL& origin_url); |
| 72 bool WouldBeOverQuota(const GURL& origin_url, int64 additional_bytes); |
| 73 bool IsOverQuota(const GURL& origin_url); |
66 | 74 |
67 quota::QuotaManagerProxy* quota_manager_proxy(); | 75 quota::QuotaManagerProxy* quota_manager_proxy(); |
68 | 76 |
69 #ifdef UNIT_TEST | 77 #ifdef UNIT_TEST |
70 // For unit tests allow to override the |data_path_|. | 78 // For unit tests allow to override the |data_path_|. |
71 void set_data_path(const FilePath& data_path) { data_path_ = data_path; } | 79 void set_data_path(const FilePath& data_path) { data_path_ = data_path; } |
72 #endif | 80 #endif |
73 | 81 |
74 private: | 82 private: |
| 83 typedef std::map<GURL, int64> OriginToSizeMap; |
| 84 class IndexedDBGetUsageAndQuotaCallback; |
| 85 |
| 86 int64 ReadUsageFromDisk(const GURL& origin_url) const; |
| 87 void EnsureDiskUsageCacheInitialized(const GURL& origin_url); |
| 88 void QueryDiskAndUpdateQuotaUsage(const GURL& origin_url); |
| 89 void GotUpdatedQuota(const GURL& origin_url, int64 usage, int64 quota); |
| 90 void QueryAvailableQuota(const GURL& origin_url); |
| 91 int64 ResetDiskUsageCache(const GURL& origin_url); |
| 92 |
75 scoped_ptr<WebKit::WebIDBFactory> idb_factory_; | 93 scoped_ptr<WebKit::WebIDBFactory> idb_factory_; |
76 | 94 |
77 // Path where the indexed db data is stored | 95 // Path where the indexed db data is stored |
78 FilePath data_path_; | 96 FilePath data_path_; |
79 | 97 |
80 // True if the destructor should delete its files. | 98 // True if the destructor should delete its files. |
81 bool clear_local_state_on_exit_; | 99 bool clear_local_state_on_exit_; |
82 | 100 |
83 scoped_refptr<quota::SpecialStoragePolicy> special_storage_policy_; | 101 scoped_refptr<quota::SpecialStoragePolicy> special_storage_policy_; |
84 | 102 |
85 scoped_refptr<quota::QuotaManagerProxy> quota_manager_proxy_; | 103 scoped_refptr<quota::QuotaManagerProxy> quota_manager_proxy_; |
86 | 104 |
| 105 OriginToSizeMap origin_size_map_; |
| 106 OriginToSizeMap space_available_map_; |
| 107 std::map<GURL, unsigned int> connection_count_; |
| 108 |
87 DISALLOW_COPY_AND_ASSIGN(IndexedDBContext); | 109 DISALLOW_COPY_AND_ASSIGN(IndexedDBContext); |
88 }; | 110 }; |
89 | 111 |
90 #endif // CONTENT_BROWSER_IN_PROCESS_WEBKIT_INDEXED_DB_CONTEXT_H_ | 112 #endif // CONTENT_BROWSER_IN_PROCESS_WEBKIT_INDEXED_DB_CONTEXT_H_ |
OLD | NEW |