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_BROWSER_DATABASE_DATABASE_TRACKER_H_ | 5 #ifndef WEBKIT_BROWSER_DATABASE_DATABASE_TRACKER_H_ |
6 #define WEBKIT_BROWSER_DATABASE_DATABASE_TRACKER_H_ | 6 #define WEBKIT_BROWSER_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/files/file.h" | 12 #include "base/files/file.h" |
13 #include "base/files/file_path.h" | 13 #include "base/files/file_path.h" |
14 #include "base/gtest_prod_util.h" | 14 #include "base/gtest_prod_util.h" |
15 #include "base/memory/ref_counted.h" | 15 #include "base/memory/ref_counted.h" |
16 #include "base/memory/scoped_ptr.h" | 16 #include "base/memory/scoped_ptr.h" |
17 #include "base/observer_list.h" | 17 #include "base/observer_list.h" |
18 #include "base/strings/string16.h" | 18 #include "base/strings/string16.h" |
19 #include "base/strings/string_util.h" | 19 #include "base/strings/string_util.h" |
20 #include "base/time/time.h" | 20 #include "base/time/time.h" |
21 #include "net/base/completion_callback.h" | 21 #include "net/base/completion_callback.h" |
22 #include "webkit/browser/webkit_storage_browser_export.h" | 22 #include "webkit/browser/storage_export.h" |
23 #include "webkit/common/database/database_connections.h" | 23 #include "webkit/common/database/database_connections.h" |
24 | 24 |
25 namespace base { | 25 namespace base { |
26 class MessageLoopProxy; | 26 class MessageLoopProxy; |
27 } | 27 } |
28 | 28 |
29 namespace content { | 29 namespace content { |
30 class DatabaseTracker_TestHelper_Test; | 30 class DatabaseTracker_TestHelper_Test; |
31 class MockDatabaseTracker; | 31 class MockDatabaseTracker; |
32 } | 32 } |
33 | 33 |
34 namespace sql { | 34 namespace sql { |
35 class Connection; | 35 class Connection; |
36 class MetaTable; | 36 class MetaTable; |
37 } | 37 } |
38 | 38 |
39 namespace storage { | 39 namespace storage { |
40 class QuotaManagerProxy; | 40 class QuotaManagerProxy; |
41 class SpecialStoragePolicy; | 41 class SpecialStoragePolicy; |
42 } | 42 } |
43 | 43 |
44 namespace storage { | 44 namespace storage { |
45 | 45 |
46 WEBKIT_STORAGE_BROWSER_EXPORT extern const base::FilePath::CharType | 46 STORAGE_EXPORT extern const base::FilePath::CharType |
47 kDatabaseDirectoryName[]; | 47 kDatabaseDirectoryName[]; |
48 WEBKIT_STORAGE_BROWSER_EXPORT extern const base::FilePath::CharType | 48 STORAGE_EXPORT extern const base::FilePath::CharType |
49 kTrackerDatabaseFileName[]; | 49 kTrackerDatabaseFileName[]; |
50 | 50 |
51 class DatabasesTable; | 51 class DatabasesTable; |
52 | 52 |
53 // This class is used to store information about all databases in an origin. | 53 // This class is used to store information about all databases in an origin. |
54 class WEBKIT_STORAGE_BROWSER_EXPORT OriginInfo { | 54 class STORAGE_EXPORT OriginInfo { |
55 public: | 55 public: |
56 OriginInfo(); | 56 OriginInfo(); |
57 OriginInfo(const OriginInfo& origin_info); | 57 OriginInfo(const OriginInfo& origin_info); |
58 ~OriginInfo(); | 58 ~OriginInfo(); |
59 | 59 |
60 const std::string& GetOriginIdentifier() const { return origin_identifier_; } | 60 const std::string& GetOriginIdentifier() const { return origin_identifier_; } |
61 int64 TotalSize() const { return total_size_; } | 61 int64 TotalSize() const { return total_size_; } |
62 void GetAllDatabaseNames(std::vector<base::string16>* databases) const; | 62 void GetAllDatabaseNames(std::vector<base::string16>* databases) const; |
63 int64 GetDatabaseSize(const base::string16& database_name) const; | 63 int64 GetDatabaseSize(const base::string16& database_name) const; |
64 base::string16 GetDatabaseDescription( | 64 base::string16 GetDatabaseDescription( |
(...skipping 13 matching lines...) Expand all Loading... |
78 // This class manages the main database and keeps track of open databases. | 78 // This class manages the main database and keeps track of open databases. |
79 // | 79 // |
80 // The data in this class is not thread-safe, so all methods of this class | 80 // The data in this class is not thread-safe, so all methods of this class |
81 // should be called on the same thread. The only exceptions are the ctor(), | 81 // should be called on the same thread. The only exceptions are the ctor(), |
82 // the dtor() and the database_directory() and quota_manager_proxy() getters. | 82 // the dtor() and the database_directory() and quota_manager_proxy() getters. |
83 // | 83 // |
84 // Furthermore, some methods of this class have to read/write data from/to | 84 // Furthermore, some methods of this class have to read/write data from/to |
85 // the disk. Therefore, in a multi-threaded application, all methods of this | 85 // the disk. Therefore, in a multi-threaded application, all methods of this |
86 // class should be called on the thread dedicated to file operations (file | 86 // class should be called on the thread dedicated to file operations (file |
87 // thread in the browser process, for example), if such a thread exists. | 87 // thread in the browser process, for example), if such a thread exists. |
88 class WEBKIT_STORAGE_BROWSER_EXPORT DatabaseTracker | 88 class STORAGE_EXPORT DatabaseTracker |
89 : public base::RefCountedThreadSafe<DatabaseTracker> { | 89 : public base::RefCountedThreadSafe<DatabaseTracker> { |
90 public: | 90 public: |
91 class Observer { | 91 class Observer { |
92 public: | 92 public: |
93 virtual void OnDatabaseSizeChanged(const std::string& origin_identifier, | 93 virtual void OnDatabaseSizeChanged(const std::string& origin_identifier, |
94 const base::string16& database_name, | 94 const base::string16& database_name, |
95 int64 database_size) = 0; | 95 int64 database_size) = 0; |
96 virtual void OnDatabaseScheduledForDeletion( | 96 virtual void OnDatabaseScheduledForDeletion( |
97 const std::string& origin_identifier, | 97 const std::string& origin_identifier, |
98 const base::string16& database_name) = 0; | 98 const base::string16& database_name) = 0; |
(...skipping 211 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
310 // this map to assign directory names that do not reveal this information. | 310 // this map to assign directory names that do not reveal this information. |
311 OriginDirectoriesMap incognito_origin_directories_; | 311 OriginDirectoriesMap incognito_origin_directories_; |
312 int incognito_origin_directories_generator_; | 312 int incognito_origin_directories_generator_; |
313 | 313 |
314 FRIEND_TEST_ALL_PREFIXES(DatabaseTracker, TestHelper); | 314 FRIEND_TEST_ALL_PREFIXES(DatabaseTracker, TestHelper); |
315 }; | 315 }; |
316 | 316 |
317 } // namespace storage | 317 } // namespace storage |
318 | 318 |
319 #endif // WEBKIT_BROWSER_DATABASE_DATABASE_TRACKER_H_ | 319 #endif // WEBKIT_BROWSER_DATABASE_DATABASE_TRACKER_H_ |
OLD | NEW |