OLD | NEW |
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 WEBKIT_DATABASE_DATABASE_TRACKER_H_ | 5 #ifndef WEBKIT_DATABASE_DATABASE_TRACKER_H_ |
6 #define WEBKIT_DATABASE_DATABASE_TRACKER_H_ | 6 #define WEBKIT_DATABASE_DATABASE_TRACKER_H_ |
7 | 7 |
8 #include <map> | 8 #include <map> |
9 #include <set> | 9 #include <set> |
10 #include <utility> | 10 #include <utility> |
11 | 11 |
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/ref_counted.h" | 14 #include "base/memory/ref_counted.h" |
15 #include "base/memory/scoped_ptr.h" | 15 #include "base/memory/scoped_ptr.h" |
16 #include "base/observer_list.h" | 16 #include "base/observer_list.h" |
17 #include "base/platform_file.h" | 17 #include "base/platform_file.h" |
18 #include "base/string16.h" | 18 #include "base/string16.h" |
19 #include "base/string_util.h" | 19 #include "base/string_util.h" |
20 #include "base/time.h" | 20 #include "base/time.h" |
21 #include "net/base/completion_callback.h" | 21 #include "net/base/completion_callback.h" |
22 #include "webkit/database/database_connections.h" | 22 #include "webkit/database/database_connections.h" |
| 23 #include "webkit/storage/webkit_storage_export.h" |
23 | 24 |
24 namespace base { | 25 namespace base { |
25 class MessageLoopProxy; | 26 class MessageLoopProxy; |
26 } | 27 } |
27 | 28 |
28 namespace sql { | 29 namespace sql { |
29 class Connection; | 30 class Connection; |
30 class MetaTable; | 31 class MetaTable; |
31 } | 32 } |
32 | 33 |
33 namespace quota { | 34 namespace quota { |
34 class QuotaManagerProxy; | 35 class QuotaManagerProxy; |
35 class SpecialStoragePolicy; | 36 class SpecialStoragePolicy; |
36 } | 37 } |
37 | 38 |
38 namespace webkit_database { | 39 namespace webkit_database { |
39 | 40 |
40 extern const FilePath::CharType kDatabaseDirectoryName[]; | 41 WEBKIT_STORAGE_EXPORT extern const FilePath::CharType kDatabaseDirectoryName[]; |
41 extern const FilePath::CharType kTrackerDatabaseFileName[]; | 42 WEBKIT_STORAGE_EXPORT extern const FilePath::CharType |
| 43 kTrackerDatabaseFileName[]; |
42 | 44 |
43 class DatabasesTable; | 45 class DatabasesTable; |
44 | 46 |
45 // This class is used to store information about all databases in an origin. | 47 // This class is used to store information about all databases in an origin. |
46 class OriginInfo { | 48 class WEBKIT_STORAGE_EXPORT OriginInfo { |
47 public: | 49 public: |
48 OriginInfo(); | 50 OriginInfo(); |
49 OriginInfo(const OriginInfo& origin_info); | 51 OriginInfo(const OriginInfo& origin_info); |
50 ~OriginInfo(); | 52 ~OriginInfo(); |
51 | 53 |
52 const string16& GetOrigin() const { return origin_; } | 54 const string16& GetOrigin() const { return origin_; } |
53 int64 TotalSize() const { return total_size_; } | 55 int64 TotalSize() const { return total_size_; } |
54 void GetAllDatabaseNames(std::vector<string16>* databases) const; | 56 void GetAllDatabaseNames(std::vector<string16>* databases) const; |
55 int64 GetDatabaseSize(const string16& database_name) const; | 57 int64 GetDatabaseSize(const string16& database_name) const; |
56 string16 GetDatabaseDescription(const string16& database_name) const; | 58 string16 GetDatabaseDescription(const string16& database_name) const; |
(...skipping 11 matching lines...) Expand all Loading... |
68 // This class manages the main database and keeps track of open databases. | 70 // This class manages the main database and keeps track of open databases. |
69 // | 71 // |
70 // The data in this class is not thread-safe, so all methods of this class | 72 // The data in this class is not thread-safe, so all methods of this class |
71 // should be called on the same thread. The only exceptions are the ctor(), | 73 // should be called on the same thread. The only exceptions are the ctor(), |
72 // the dtor() and the database_directory() and quota_manager_proxy() getters. | 74 // the dtor() and the database_directory() and quota_manager_proxy() getters. |
73 // | 75 // |
74 // Furthermore, some methods of this class have to read/write data from/to | 76 // Furthermore, some methods of this class have to read/write data from/to |
75 // the disk. Therefore, in a multi-threaded application, all methods of this | 77 // the disk. Therefore, in a multi-threaded application, all methods of this |
76 // class should be called on the thread dedicated to file operations (file | 78 // class should be called on the thread dedicated to file operations (file |
77 // thread in the browser process, for example), if such a thread exists. | 79 // thread in the browser process, for example), if such a thread exists. |
78 class DatabaseTracker | 80 class WEBKIT_STORAGE_EXPORT DatabaseTracker |
79 : public base::RefCountedThreadSafe<DatabaseTracker> { | 81 : public base::RefCountedThreadSafe<DatabaseTracker> { |
80 public: | 82 public: |
81 class Observer { | 83 class Observer { |
82 public: | 84 public: |
83 virtual void OnDatabaseSizeChanged(const string16& origin_identifier, | 85 virtual void OnDatabaseSizeChanged(const string16& origin_identifier, |
84 const string16& database_name, | 86 const string16& database_name, |
85 int64 database_size) = 0; | 87 int64 database_size) = 0; |
86 virtual void OnDatabaseScheduledForDeletion( | 88 virtual void OnDatabaseScheduledForDeletion( |
87 const string16& origin_identifier, | 89 const string16& origin_identifier, |
88 const string16& database_name) = 0; | 90 const string16& database_name) = 0; |
(...skipping 207 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
296 // this map to assign directory names that do not reveal this information. | 298 // this map to assign directory names that do not reveal this information. |
297 OriginDirectoriesMap incognito_origin_directories_; | 299 OriginDirectoriesMap incognito_origin_directories_; |
298 int incognito_origin_directories_generator_; | 300 int incognito_origin_directories_generator_; |
299 | 301 |
300 FRIEND_TEST_ALL_PREFIXES(DatabaseTracker, TestHelper); | 302 FRIEND_TEST_ALL_PREFIXES(DatabaseTracker, TestHelper); |
301 }; | 303 }; |
302 | 304 |
303 } // namespace webkit_database | 305 } // namespace webkit_database |
304 | 306 |
305 #endif // WEBKIT_DATABASE_DATABASE_TRACKER_H_ | 307 #endif // WEBKIT_DATABASE_DATABASE_TRACKER_H_ |
OLD | NEW |