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 #include "content/browser/browser_thread.h" |
14 | 14 |
| 15 #include <map> |
| 16 |
15 class GURL; | 17 class GURL; |
16 class FilePath; | 18 class FilePath; |
17 class WebKitContext; | 19 class WebKitContext; |
18 | 20 |
19 namespace WebKit { | 21 namespace WebKit { |
20 class WebIDBFactory; | 22 class WebIDBFactory; |
21 } | 23 } |
22 | 24 |
23 namespace base { | 25 namespace base { |
24 class MessageLoopProxy; | 26 class MessageLoopProxy; |
(...skipping 24 matching lines...) Expand all Loading... |
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. | 58 // Deletes a single indexed db file. |
57 void DeleteIndexedDBFile(const FilePath& file_path); | 59 void DeleteIndexedDBFile(const FilePath& file_path); |
58 | 60 |
59 // Deletes all indexed db files for the given origin. | 61 // Deletes all indexed db files for the given origin. Only works for |
| 62 // extensions, not any origin. |
60 void DeleteIndexedDBForOrigin(const string16& origin_id); | 63 void DeleteIndexedDBForOrigin(const string16& origin_id); |
61 | 64 |
| 65 // TODO(dgrogan): Once we can delete IndexedDB directories out from |
| 66 // underneath open webkit instances, merge this and DeleteIndexedDBForOrigin. |
| 67 void EvictOrigin(const GURL& origin_url); |
| 68 |
62 // Does a particular origin get unlimited storage? | 69 // Does a particular origin get unlimited storage? |
63 bool IsUnlimitedStorageGranted(const GURL& origin) const; | 70 bool IsUnlimitedStorageGranted(const GURL& origin) const; |
64 | 71 |
65 void GetAllOriginIdentifiers(std::vector<string16>* origin_ids); | 72 void GetAllOriginIdentifiers(std::vector<string16>* origin_ids); |
66 | 73 |
| 74 void NewConnection(const GURL& origin_url); |
| 75 void TransactionComplete(const GURL& origin_url); |
| 76 void ConnectionClosed(const GURL& origin_url); |
| 77 int64 InitializeDiskUsage(const GURL& origin_url); |
| 78 void GotUpdatedQuota(const GURL& origin_url, int64 usage, int64 quota); |
| 79 bool WouldBeOverQuota(const GURL& origin_url, int64 additional_bytes); |
| 80 bool IsOverQuota(const GURL& origin_url); |
| 81 |
| 82 void QueryDiskAndUpdateQuotaUsage(const GURL& origin_url); |
| 83 |
67 quota::QuotaManagerProxy* quota_manager_proxy(); | 84 quota::QuotaManagerProxy* quota_manager_proxy(); |
68 | 85 |
69 #ifdef UNIT_TEST | 86 #ifdef UNIT_TEST |
70 // For unit tests allow to override the |data_path_|. | 87 // For unit tests allow to override the |data_path_|. |
71 void set_data_path(const FilePath& data_path) { data_path_ = data_path; } | 88 void set_data_path(const FilePath& data_path) { data_path_ = data_path; } |
72 #endif | 89 #endif |
73 | 90 |
74 private: | 91 private: |
75 scoped_ptr<WebKit::WebIDBFactory> idb_factory_; | 92 scoped_ptr<WebKit::WebIDBFactory> idb_factory_; |
76 | 93 |
77 // Path where the indexed db data is stored | 94 // Path where the indexed db data is stored |
78 FilePath data_path_; | 95 FilePath data_path_; |
79 | 96 |
80 // True if the destructor should delete its files. | 97 // True if the destructor should delete its files. |
81 bool clear_local_state_on_exit_; | 98 bool clear_local_state_on_exit_; |
82 | 99 |
83 scoped_refptr<quota::SpecialStoragePolicy> special_storage_policy_; | 100 scoped_refptr<quota::SpecialStoragePolicy> special_storage_policy_; |
84 | 101 |
85 scoped_refptr<quota::QuotaManagerProxy> quota_manager_proxy_; | 102 scoped_refptr<quota::QuotaManagerProxy> quota_manager_proxy_; |
86 | 103 |
87 DISALLOW_COPY_AND_ASSIGN(IndexedDBContext); | 104 DISALLOW_COPY_AND_ASSIGN(IndexedDBContext); |
| 105 |
| 106 typedef std::map<GURL, int64> OriginToSizeMap; |
| 107 OriginToSizeMap origin_size_map_; |
| 108 OriginToSizeMap origin_allocated_quota_map_; |
| 109 |
| 110 std::map<GURL, unsigned int> connection_count_; |
| 111 |
| 112 int64 ReadUsageFromDisk(const GURL& origin_url) const; |
| 113 void QueryAvailableQuota(const GURL& origin_url); |
88 }; | 114 }; |
89 | 115 |
90 #endif // CONTENT_BROWSER_IN_PROCESS_WEBKIT_INDEXED_DB_CONTEXT_H_ | 116 #endif // CONTENT_BROWSER_IN_PROCESS_WEBKIT_INDEXED_DB_CONTEXT_H_ |
OLD | NEW |