| 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_path.h" | 12 #include "base/files/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/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.h" | 20 #include "base/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/common/database/database_connections.h" | 23 #include "webkit/common/database/database_connections.h" |
| 23 #include "webkit/storage/webkit_storage_export.h" | |
| 24 | 24 |
| 25 namespace base { | 25 namespace base { |
| 26 class MessageLoopProxy; | 26 class MessageLoopProxy; |
| 27 } | 27 } |
| 28 | 28 |
| 29 namespace sql { | 29 namespace sql { |
| 30 class Connection; | 30 class Connection; |
| 31 class MetaTable; | 31 class MetaTable; |
| 32 } | 32 } |
| 33 | 33 |
| 34 namespace quota { | 34 namespace quota { |
| 35 class QuotaManagerProxy; | 35 class QuotaManagerProxy; |
| 36 class SpecialStoragePolicy; | 36 class SpecialStoragePolicy; |
| 37 } | 37 } |
| 38 | 38 |
| 39 namespace webkit_database { | 39 namespace webkit_database { |
| 40 | 40 |
| 41 WEBKIT_STORAGE_EXPORT extern const base::FilePath::CharType | 41 WEBKIT_STORAGE_BROWSER_EXPORT extern const base::FilePath::CharType |
| 42 kDatabaseDirectoryName[]; | 42 kDatabaseDirectoryName[]; |
| 43 WEBKIT_STORAGE_EXPORT extern const base::FilePath::CharType | 43 WEBKIT_STORAGE_BROWSER_EXPORT extern const base::FilePath::CharType |
| 44 kTrackerDatabaseFileName[]; | 44 kTrackerDatabaseFileName[]; |
| 45 | 45 |
| 46 class DatabasesTable; | 46 class DatabasesTable; |
| 47 | 47 |
| 48 // This class is used to store information about all databases in an origin. | 48 // This class is used to store information about all databases in an origin. |
| 49 class WEBKIT_STORAGE_EXPORT OriginInfo { | 49 class WEBKIT_STORAGE_BROWSER_EXPORT OriginInfo { |
| 50 public: | 50 public: |
| 51 OriginInfo(); | 51 OriginInfo(); |
| 52 OriginInfo(const OriginInfo& origin_info); | 52 OriginInfo(const OriginInfo& origin_info); |
| 53 ~OriginInfo(); | 53 ~OriginInfo(); |
| 54 | 54 |
| 55 const base::string16& GetOrigin() const { return origin_; } | 55 const base::string16& GetOrigin() const { return origin_; } |
| 56 int64 TotalSize() const { return total_size_; } | 56 int64 TotalSize() const { return total_size_; } |
| 57 void GetAllDatabaseNames(std::vector<base::string16>* databases) const; | 57 void GetAllDatabaseNames(std::vector<base::string16>* databases) const; |
| 58 int64 GetDatabaseSize(const base::string16& database_name) const; | 58 int64 GetDatabaseSize(const base::string16& database_name) const; |
| 59 base::string16 GetDatabaseDescription( | 59 base::string16 GetDatabaseDescription( |
| (...skipping 13 matching lines...) Expand all Loading... |
| 73 // This class manages the main database and keeps track of open databases. | 73 // This class manages the main database and keeps track of open databases. |
| 74 // | 74 // |
| 75 // The data in this class is not thread-safe, so all methods of this class | 75 // The data in this class is not thread-safe, so all methods of this class |
| 76 // should be called on the same thread. The only exceptions are the ctor(), | 76 // should be called on the same thread. The only exceptions are the ctor(), |
| 77 // the dtor() and the database_directory() and quota_manager_proxy() getters. | 77 // the dtor() and the database_directory() and quota_manager_proxy() getters. |
| 78 // | 78 // |
| 79 // Furthermore, some methods of this class have to read/write data from/to | 79 // Furthermore, some methods of this class have to read/write data from/to |
| 80 // the disk. Therefore, in a multi-threaded application, all methods of this | 80 // the disk. Therefore, in a multi-threaded application, all methods of this |
| 81 // class should be called on the thread dedicated to file operations (file | 81 // class should be called on the thread dedicated to file operations (file |
| 82 // thread in the browser process, for example), if such a thread exists. | 82 // thread in the browser process, for example), if such a thread exists. |
| 83 class WEBKIT_STORAGE_EXPORT DatabaseTracker | 83 class WEBKIT_STORAGE_BROWSER_EXPORT DatabaseTracker |
| 84 : public base::RefCountedThreadSafe<DatabaseTracker> { | 84 : public base::RefCountedThreadSafe<DatabaseTracker> { |
| 85 public: | 85 public: |
| 86 class Observer { | 86 class Observer { |
| 87 public: | 87 public: |
| 88 virtual void OnDatabaseSizeChanged(const base::string16& origin_identifier, | 88 virtual void OnDatabaseSizeChanged(const base::string16& origin_identifier, |
| 89 const base::string16& database_name, | 89 const base::string16& database_name, |
| 90 int64 database_size) = 0; | 90 int64 database_size) = 0; |
| 91 virtual void OnDatabaseScheduledForDeletion( | 91 virtual void OnDatabaseScheduledForDeletion( |
| 92 const base::string16& origin_identifier, | 92 const base::string16& origin_identifier, |
| 93 const base::string16& database_name) = 0; | 93 const base::string16& database_name) = 0; |
| (...skipping 209 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 303 // this map to assign directory names that do not reveal this information. | 303 // this map to assign directory names that do not reveal this information. |
| 304 OriginDirectoriesMap incognito_origin_directories_; | 304 OriginDirectoriesMap incognito_origin_directories_; |
| 305 int incognito_origin_directories_generator_; | 305 int incognito_origin_directories_generator_; |
| 306 | 306 |
| 307 FRIEND_TEST_ALL_PREFIXES(DatabaseTracker, TestHelper); | 307 FRIEND_TEST_ALL_PREFIXES(DatabaseTracker, TestHelper); |
| 308 }; | 308 }; |
| 309 | 309 |
| 310 } // namespace webkit_database | 310 } // namespace webkit_database |
| 311 | 311 |
| 312 #endif // WEBKIT_BROWSER_DATABASE_DATABASE_TRACKER_H_ | 312 #endif // WEBKIT_BROWSER_DATABASE_DATABASE_TRACKER_H_ |
| OLD | NEW |